Skip to content

Commit

Permalink
Fix some style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hoppergee committed Jul 28, 2021
1 parent 64aa93d commit 9a033f2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion spec/rails_app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RailsApp::Application.routes.draw do
root :to => "home#index"
root to: "home#index"

resources :posts do
resources :comments
Expand Down
30 changes: 23 additions & 7 deletions spec/support/dummy_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,45 @@
class DummyView < ActionView::Base
module FakeRequest
class Request
attr_accessor :path, :fullpath, :protocol, :host_with_port, :_request_method
attr_accessor :path,
:fullpath,
:protocol,
:host_with_port,
:_request_method
def get?
_request_method == nil ? true : _request_method == "GET"
return true if _request_method.nil?

_request_method == "GET"
end

def post?
_request_method == nil ? false : _request_method == "POST"
return false if _request_method.nil?

_request_method == "POST"
end

def put?
_request_method == nil ? false : _request_method == "PUT"
return false if _request_method.nil?

_request_method == "PUT"
end

def patch?
_request_method == nil ? false : _request_method == "PATCH"
return false if _request_method.nil?

_request_method == "PATCH"
end

def delete?
_request_method == nil ? false : _request_method == "DELETE"
return false if _request_method.nil?

_request_method == "DELETE"
end

def head?
_request_method == nil ? false : _request_method == "HEAD"
return false if _request_method.nil?

_request_method == "HEAD"
end
end
def request
Expand Down
11 changes: 7 additions & 4 deletions spec/unit/view_extensions/breadcrumb_trail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,12 @@

it "match current path with :http_verbs" do
view = DummyView.new
view.breadcrumb("posts", "/posts", http_verbs: [:get, :post])
view.breadcrumb("posts", "/posts", http_verbs: %i[get post])
view.set_path("/posts")
view.set_request_method(:post)

expect(view.breadcrumb_trail.map(&:to_a)).to eq([["posts", "/posts", true]])
trail = view.breadcrumb_trail.map(&:to_a)
expect(trail).to eq([["posts", "/posts", true]])
end

it "fail to match current path with :http_verbs" do
Expand All @@ -296,7 +297,8 @@
view.set_path("/posts")
view.set_request_method(:post)

expect(view.breadcrumb_trail.map(&:to_a)).to eq([["posts", "/posts", false]])
trail = view.breadcrumb_trail.map(&:to_a)
expect(trail).to eq([["posts", "/posts", false]])
end

it "match current path with :http_verbs => :all" do
Expand All @@ -305,6 +307,7 @@
view.set_path("/posts")
view.set_request_method(:delete)

expect(view.breadcrumb_trail.map(&:to_a)).to eq([["posts", "/posts", true]])
trail = view.breadcrumb_trail.map(&:to_a)
expect(trail).to eq([["posts", "/posts", true]])
end
end

0 comments on commit 9a033f2

Please sign in to comment.