1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/lib/capybara/spec/session/uncheck_spec.rb
CJ Kihlbom and Jonas Nicklas 942c65dadf Add options to uncheck
2013-02-24 16:48:33 +01:00

40 lines
1.2 KiB
Ruby

Capybara::SpecHelper.spec "#uncheck" do
before do
@session.visit('/form')
end
it "should uncheck a checkbox by id" do
@session.uncheck("form_pets_hamster")
@session.click_button('awesome')
extract_results(@session)['pets'].should include('dog')
extract_results(@session)['pets'].should_not include('hamster')
end
it "should uncheck a checkbox by label" do
@session.uncheck("Hamster")
@session.click_button('awesome')
extract_results(@session)['pets'].should include('dog')
extract_results(@session)['pets'].should_not include('hamster')
end
it "casts to string" do
@session.uncheck(:"form_pets_hamster")
@session.click_button('awesome')
extract_results(@session)['pets'].should include('dog')
extract_results(@session)['pets'].should_not include('hamster')
end
context "with :exact option" do
it "should accept partial matches when false" do
@session.uncheck('Ham', :exact => false)
@session.click_button('awesome')
extract_results(@session)['pets'].should_not include('hamster')
end
it "should not accept partial matches when true" do
expect do
@session.uncheck('Ham', :exact => true)
end.to raise_error(Capybara::ElementNotFound)
end
end
end