Make click_link support :href option

This commit is contained in:
Andrey Botalov 2013-02-19 23:12:54 +03:00
parent b6c9f70133
commit a3dceaf3c2
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')