Skip to content

Commit

Permalink
Adding an empty controller{} fails when before get
Browse files Browse the repository at this point in the history
Test output when uncommented:
```
$ bundle exec rspec -fd

RedirectIfRequestedConcern
  is expected not to be redirect
  is expected to have attributes {:body => "Test controller, test method"}
  with redirect_me=yes
    example at ./spec/app/controllers/concerns/redirect_if_requested_concern_spec.rb:27 (FAILED - 1)

HomeController
  #show
    example at ./spec/app/controllers/home_controller_spec.rb:15 (FAILED - 2)
    example at ./spec/app/controllers/home_controller_spec.rb:16 (FAILED - 3)
    with redirect_me=yes
      example at ./spec/app/controllers/home_controller_spec.rb:21 (FAILED - 4)

Failures:

  1) RedirectIfRequestedConcern with redirect_me=yes
     Failure/Error: redirect_to url_for(redirected_from_concern: true) if params[:redirect_me] == 'yes'

     ActionController::UrlGenerationError:
       No route matches {:action=>"test", :controller=>"anonymous", :redirected_from_concern=>true}
     # ./app/controllers/concerns/redirect_if_requested_concern.rb:11:in `redirect_if_requested'
     # /Users/henryblyth/.rbenv/versions/2.6.7/gemsets/rails-bug-app/gems/actiontext-6.1.3.2/lib/action_text/rendering.rb:20:in `with_renderer'
     # /Users/henryblyth/.rbenv/versions/2.6.7/gemsets/rails-bug-app/gems/actiontext-6.1.3.2/lib/action_text/engine.rb:55:in `block (4 levels) in <class:Engine>'
     # ./spec/app/controllers/concerns/redirect_if_requested_concern_spec.rb:16:in `block (2 levels) in <top (required)>'

  2) HomeController#show
     Failure/Error: before { get :show, params: params, session: nil }

     ActionController::UrlGenerationError:
       No route matches {:action=>"show", :controller=>"home"}
     # ./spec/app/controllers/home_controller_spec.rb:9:in `block (3 levels) in <main>'

  3) HomeController#show
     Failure/Error: before { get :show, params: params, session: nil }

     ActionController::UrlGenerationError:
       No route matches {:action=>"show", :controller=>"home"}
     # ./spec/app/controllers/home_controller_spec.rb:9:in `block (3 levels) in <main>'

  4) HomeController#show with redirect_me=yes
     Failure/Error: before { get :show, params: params, session: nil }

     ActionController::UrlGenerationError:
       No route matches {:action=>"show", :controller=>"home", :redirect_me=>"yes"}
     # ./spec/app/controllers/home_controller_spec.rb:9:in `block (3 levels) in <main>'

Finished in 0.57528 seconds (files took 1.84 seconds to load)
6 examples, 4 failures

Failed examples:

rspec ./spec/app/controllers/concerns/redirect_if_requested_concern_spec.rb:27 # RedirectIfRequestedConcern with redirect_me=yes
rspec ./spec/app/controllers/home_controller_spec.rb:15 # HomeController#show
rspec ./spec/app/controllers/home_controller_spec.rb:16 # HomeController#show
rspec ./spec/app/controllers/home_controller_spec.rb:21 # HomeController#show with redirect_me=yes
```
  • Loading branch information
henrahmagix committed Jun 8, 2021
1 parent c887222 commit cbd5cf7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/app/controllers/home_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
describe '#show' do
subject { response }

# controller {} # uncomment this to make all tests below fail at `get :show` with `ActionController::UrlGenerationError`

before { get :show, params: params, session: nil }

controller {} # but here is fine, after `before`

let(:params) { {} }

it { is_expected.not_to be_redirect }
Expand Down

0 comments on commit cbd5cf7

Please # to comment.