I'm in section 7.2.2 (Chapter 7) of Michael Hartl's Rails Tutorial, and when I add an @user variable to app/controllers/users_controller.rb
things get strange. The tests that are supposed to now pass don't - they instead fail for a different reason:
$ rspec spec/requests/user_pages_spec.rb -e "signup page"
Failures:
1) User pages signup page
Failure/Error: before { visit signup_path }
ActionView::Template::Error:
undefined method `users_path' for #<#<Class:0x007fdec372a8e0>:0x007fdec375d010>
# ./app/views/users/new.html.erb:6:in `_app_views_users_new_html_erb___2884421820517152565_70297369620580'
# ./spec/requests/user_pages_spec.rb:8:in `block (3 levels) in <top (required)>'
2) User pages signup page
Failure/Error: before { visit signup_path }
ActionView::Template::Error:
undefined method `users_path' for #<#<Class:0x007fdec372a8e0>:0x007fdec45caee0>
# ./app/views/users/new.html.erb:6:in `_app_views_users_new_html_erb___2884421820517152565_70297369620580'
# ./spec/requests/user_pages_spec.rb:8:in `block (3 levels) in <top (required)>'
Initially, these tests fail b/c @user is nil. Now they're failing due to an undefined method.
The book suggests that they should pass once I've defined @user, so I'm confused. I've pushed ahead a bit thinking perhaps this would work itself out, but it hasn't, so I'd like to figure this out before proceeding.
Here are the tests in question (copied from the book):
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
let(:user) { FactoryGirl.create(:user) }
before { visit signup_path }
it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
end
end