Reputation: 2405
I have a RSpec test that keeps failing.
subject { page }
visit user_path(user)
it { should have_link('Settings', href: edit_user_path(user)) }
But when I load the page myself I can see that the link is working well. Any ideas ? No spelling mistake as well.
Possible to see the page that RSpec loaded in the test?
Upvotes: 15
Views: 10537
Reputation: 7344
Your visit user_path(user)
isn't executing in the right context.
Try either:
subject { page }
it do
visit user_path(user)
should have_link('Settings', href: edit_user_path(user))
end
Or:
subject { page }
before { visit user_path(user) }
it { should have_link('Settings', href: edit_user_path(user)) }
If you would like to see the html, you can use a save_and_open_page
statement.
Upvotes: 17