Reputation: 1276
I'm working through the hartl rails tutorial
I'm at the end of section 8.3, the application is functioning correctly but I'm getting an rspec error
1) User pages signup with valid information after saving the user
Failure/Error: it { should have_link('Sign out') }
expected link "Sign out" to return something
# ./spec/requests/user_pages_spec.rb:48:in `block (5 levels) in <top (required)>'
the part of user_pages_spec.rb that is involved in this is
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
describe "after saving the user" do
it { should have_link('Sign out') }
end
I'm at a bit of a loss as to how to fix this. There are other posts around similar to this but alas, I can't get their solutions to work in my case. thanks.
Upvotes: 3
Views: 419
Reputation: 754
It looks like you need to Create the account before checking for the link. There is more to the tests than you posted. Here is a snippet of the code I used when going through the tutorial.
describe "after saving the user" do
before { click_button "Create my account" }
it { should have_link('Sign out') }
end
Upvotes: 5