Rspec-rails: Failing to render action with rails 6.0.0.beta3

Created on 30 Mar 2019  路  10Comments  路  Source: rspec/rspec-rails

What Ruby, Rails and RSpec versions are you using?

Ruby version: 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
Rails version: 6.0.0.beta3
RSpec version: RSpec 3.8
- rspec-core 3.8.0
- rspec-expectations 3.8.2
- rspec-mocks 3.8.0
- rspec-rails 3.8.2
- rspec-support 3.8.0

Observed behaviour

This is a new project started in a docker container. The steps are pretty much as follows:

  • start a new project with rails new PROJECTNAME
  • add rspec-rails to the development and test group in the Gemfile
  • rails g rspec:install
  • rails g scaffold Account firstname lastname
  • rails db:migrate
  • rspec spec/controllers/
    -- I ommitted the docker-compose exec SERVICENAME in front of the last 4 commands above

The specs have a problem with rendering Templates. Without further modifications, here is the interesting part of the output:

Failures:

  1) AccountsController GET #new returns a success response
     Failure/Error: get :new, params: {}#, session: valid_session

     ActionView::Template::Error:
       wrong number of arguments (given 2, expected 1)
     # ./spec/controllers/accounts_controller_spec.rb:62:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # ArgumentError:
     #   wrong number of arguments (given 2, expected 1)
     #   ./spec/controllers/accounts_controller_spec.rb:62:in `block (3 levels) in <top (required)>'

Finished in 0.03763 seconds (files took 1.73 seconds to load)
12 examples, 1 failure, 11 pending

Expected behaviour

  • The generated spec should be green
  • rendering templates should work

Can you provide an example app?


Please find the example here:
https://github.com/pip139/issue-demo

Most helpful comment

Here is the workaround for the above error message. FYI: Still have 1 error dealing with webpacker.
# 3/22/2019: Modified following rspec section. gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails', branch: '4-0-dev' gem 'rspec-core', git: 'https://github.com/rspec/rspec-core' gem 'rspec-mocks', git: 'https://github.com/rspec/rspec-mocks' gem 'rspec-support', git: 'https://github.com/rspec/rspec-support' gem 'rspec-expectations', git: 'https://github.com/rspec/rspec-expectations'

All 10 comments

Here is the workaround for the above error message. FYI: Still have 1 error dealing with webpacker.
# 3/22/2019: Modified following rspec section. gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails', branch: '4-0-dev' gem 'rspec-core', git: 'https://github.com/rspec/rspec-core' gem 'rspec-mocks', git: 'https://github.com/rspec/rspec-mocks' gem 'rspec-support', git: 'https://github.com/rspec/rspec-support' gem 'rspec-expectations', git: 'https://github.com/rspec/rspec-expectations'

@jasnow Thanks for the very prompt reply.
I tried your suggestion but now rspec can't even start.
Here is what I get:

Traceback (most recent call last):
    2: from /usr/local/bundle/bin/rspec:23:in `<main>'
    1: from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem rspec-core (>= 0.a) with executable rspec (Gem::GemNotFoundException)

Did you add all 5 lines to issue_demo's Gemfile file?

I had added them locally.
Now I pushed them also to GitHub repo.

Does "rake" run cleanly now?

Oh thanks, rake works.

"rake" run cleanly now?

It is only a little verbose:

/usr/local/bin/ruby -I/usr/local/bundle/bundler/gems/rspec-core-0b4c98d1c191/lib:/usr/local/bundle/bundler/gems/rspec-support-3a6ec66d3268/lib /usr/local/bundle/bundler/gems/rspec-core-0b4c98d1c191/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
...
rspec ./spec/controllers/accounts_controller_spec.rb:120 # AccountsController PUT #update with invalid params returns a success response (i.e. to display the 'edit' template)

/usr/local/bin/ruby -I/usr/local/bundle/bundler/gems/rspec-core-0b4c98d1c191/lib:/usr/local/bundle/bundler/gems/rspec-support-3a6ec66d3268/lib /usr/local/bundle/bundler/gems/rspec-core-0b4c98d1c191/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed

Great - Signing off.

Thanks a lot for your help.

Glad I could help.

Closing as this is a duplicate of #2095

Was this page helpful?
0 / 5 - 0 ratings