Reputation: 131
I'm writing tests for a project and this is the first time I'm writing tests on Rails and I'm having a little trouble. Here's the situation, after I click on Submit, on the page returned I should have a link called "View" with a certain url. So what I'm doing is this:
it 'should be able to review' do
#submit review
click_on 'Submit'
#expect result
expect(page).to have_link('View', href: "/response/view?a_id=#{@a.id}")
end
And I'm sure that the link exists on the page because I tested this manually, and if I delete the line expect(page)
the test will pass. Is there something wrong with what I wrote? Also, I tried expect(page).to have_link('View')
and it does not work either. Thanks!
Upvotes: 0
Views: 636
Reputation: 5116
I would say you have to debug the test, with the Capybara instruction save_and_open_page
so you can actually confirm what the page is rendering and what is happening.
For this you have to install the launchy
gem
Here is a useful link: https://github.com/copiousfreetime/launchy#capybara-testing to set it up and see how it works
Upvotes: 1