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:
commit
2131876269
2 changed files with 15 additions and 2 deletions
|
@ -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 a new issue