diff --git a/lib/capybara/node/actions.rb b/lib/capybara/node/actions.rb index 992add38..96770e36 100644 --- a/lib/capybara/node/actions.rb +++ b/lib/capybara/node/actions.rb @@ -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 ## diff --git a/lib/capybara/spec/session/check_spec.rb b/lib/capybara/spec/session/check_spec.rb index 678f3f97..18b2cc6c 100644 --- a/lib/capybara/spec/session/check_spec.rb +++ b/lib/capybara/spec/session/check_spec.rb @@ -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