2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_link?' do
|
|
|
|
before do
|
|
|
|
@session.visit('/with_html')
|
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be true if the given link is on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_link('foo')
|
|
|
|
expect(@session).to have_link('awesome title')
|
|
|
|
expect(@session).to have_link('A link', :href => '/with_simple_html')
|
|
|
|
expect(@session).to have_link(:'A link', :href => :'/with_simple_html')
|
2015-04-27 20:33:39 -04:00
|
|
|
expect(@session).to have_link('A link', :href => /\/with_simple_html/)
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be false if the given link is not on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_link('monkey')
|
|
|
|
expect(@session).not_to have_link('A link', :href => '/non-existant-href')
|
2015-04-27 20:33:39 -04:00
|
|
|
expect(@session).not_to have_link('A link', :href => /non-existant/)
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_no_link?' do
|
|
|
|
before do
|
|
|
|
@session.visit('/with_html')
|
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be false if the given link is on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_no_link('foo')
|
|
|
|
expect(@session).not_to have_no_link('awesome title')
|
|
|
|
expect(@session).not_to have_no_link('A link', :href => '/with_simple_html')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be true if the given link is not on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_link('monkey')
|
|
|
|
expect(@session).to have_no_link('A link', :href => '/non-existant-href')
|
2015-04-27 20:33:39 -04:00
|
|
|
expect(@session).to have_no_link('A link', :href => /\/non-existant-href/)
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
|
|
|
end
|