Add options to `check`

This commit is contained in:
CJ Kihlbom and Jonas Nicklas 2013-02-24 16:48:25 +01:00
parent def1e395aa
commit d62a31f39d
2 changed files with 16 additions and 2 deletions

View File

@ -75,8 +75,8 @@ module Capybara
#
# @param [String] locator Which check box to check
#
def check(locator)
find(:checkbox, locator).set(true)
def check(locator, options={})
find(:checkbox, locator, options).set(true)
end
##

View File

@ -82,4 +82,18 @@ Capybara::SpecHelper.spec "#check" do
end.to raise_error(Capybara::ElementNotFound)
end
end
context "with :exact option" do
it "should accept partial matches when false" do
@session.check('Ham', :exact => false)
@session.click_button('awesome')
extract_results(@session)['pets'].should include('hamster')
end
it "should not accept partial matches when true" do
expect do
@session.check('Ham', :exact => true)
end.to raise_error(Capybara::ElementNotFound)
end
end
end