simo
simo

Reputation: 24560

Capybara and Rails, Why has_link? always returns false?

I am trying to test with has_link? in my spec test, here is my test:

page.has_link?('next_page', {}).should == true

but, the test always fail, although the link with id 'next_page' dose exist! the strange thing is that have_content always works fine, here is how I implement it:

page.should have_content("some text")

Can you help me please ? what I am missing here ?

EDIT

Here is the resulted link in the page:

<a id="next_page" href="javascript: void(0)" onclick="javascript: void(0)" style="color: #888888">Next</a>

Upvotes: 1

Views: 3968

Answers (3)

Vishnu Atrai
Vishnu Atrai

Reputation: 2368

You can try below sample -

it "should have logout link" do
  expect(page).to have_link('Logout') 
end 

Upvotes: 1

dpassage
dpassage

Reputation: 5453

I do this with:

rendered.should have_link("Teams", :href => teams_path)

Upvotes: 0

Alpha Beta Charlie
Alpha Beta Charlie

Reputation: 841

I think you should do :

page.has_link? "next_page"

or

page.has_link? "next_page", url_path

Upvotes: 7

Related Questions