rails-controller-testing: Adding rails-controller-testing** gem does not fix NoMethodError message
Adding rails-controller-testing gem to my Rails 5 fork of codeforatlanta’s show-me-the-food5 (https://github.com/jasnow/show-me-the-food5) repo’s Gemfile does not fix the following message:
- NoMethodError:assigns has been extracted to a gem. To continue using it, add
gem 'rails-controller-testing'
to your Gemfile.
Appears to not be the only one: http://stackoverflow.com/questions/30605868/rails-controller-testing-gem
If you run “rake” before upgrading to the most recent version of Rails 5, no tests break.
After adding the gem rails-controller-testing, running “bundle update”, and then running “rake,” you get:
Failures:
1) LocationsController#index assigns @locations
Failure/Error: subject{ assigns(:locations) }
NoMethodError:
assigns has been extracted to a gem. To continue using it,
add `gem 'rails-controller-testing'` to your Gemfile.
# /home/jasnow/.rvm/gems/ruby-2.2.2/bundler/gems/rails-7220ffcffd00/
actionpack/lib/action_dispatch/testing/test_process.rb:8:in `assigns'
# ./spec/controllers/locations_controller_spec.rb:5:in `block
(3 levels) in <top (required)>'
# ./spec/controllers/locations_controller_spec.rb:9:in `block
(3 levels) in <top (required)>'
Finished in 0.29375 seconds (files took 3.41 seconds to load)
1 example, 1 failure
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 44 (5 by maintainers)
Commits related to this issue
- Remove assert_template because of error message https://github.com/rails/rails-controller-testing/issues/5 — committed to cheshire137/competiwatch by cheshire137 6 years ago
- Update README.md to include configurations for RSpec. fixes https://github.com/rails/rails-controller-testing/issues/5 — committed to Good725/controller-rails by Good725 8 years ago
This issue still seems to be active with Rails 5.1.6, RSpec 3.7.2, and rails-controller-testing 1.0.2.
I’ve tried all the solutions here, and nothing has worked. Here’s my spec_helper.rb:
Still I get the following error:
Help!
This worked for me:
+1
On my project it works fine with controller tests, but when I try to use it within a request spec I get:
Versions: rails 5.1.4, rspec-rails 3.7.2, rails-controller-testing 1.0.2
In case anyone else runs into this issue, the README file’s section about usage with RSpec has since been modified, so the note that @tgxworld is alluding to no longer exists. It can be found, however, in this commit: https://github.com/rails/rails-controller-testing/commit/f756b33c138c593eabe37f6085f8bac477b99bfe