1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Merge pull request #963 from abotalov/support_for_href_by_click_link

Support for :href by click_link
This commit is contained in:
Jonas Nicklas 2013-02-19 12:47:51 -08:00
commit 2131876269
2 changed files with 15 additions and 2 deletions

View file

@ -20,9 +20,11 @@ module Capybara
# alt text inside the link.
#
# @param [String] locator Text, id or text of link
# @param options
# @option options [String] :href The value the href attribute must be
#
def click_link(locator)
find(:link, locator).click
def click_link(locator, options={})
find(:link, locator, options).click
end
##

View file

@ -66,6 +66,17 @@ Capybara::SpecHelper.spec '#click_link' do
end
end
context "with :href option given" do
it "should find links with valid href" do
@session.click_link('labore', :href => '/with_simple_html')
@session.should have_content('Bar')
end
it "should raise error if link wasn't found" do
expect { @session.click_link('labore', :href => 'invalid_href') }.to raise_error(Capybara::ElementNotFound)
end
end
it "should follow relative links" do
@session.visit('/')
@session.click_link('Relative')