Make click_link support :href option
This commit is contained in:
parent
b6c9f70133
commit
a3dceaf3c2
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue