Fix issue with not defaulting locator

This commit is contained in:
Thomas Walpole 2018-04-27 09:39:34 -07:00
parent 035e3e33e5
commit 09924678e8
4 changed files with 20 additions and 1 deletions

View File

@ -129,7 +129,7 @@ module Capybara
# @macro waiting_behavior
#
# @return [Capybara::Node::Element] The element checked or the label clicked
def check(locator, **options)
def check(locator = nil, **options)
_check_with_label(:checkbox, true, locator, **options)
end

View File

@ -62,6 +62,12 @@ Capybara::SpecHelper.spec "#check" do
expect(extract_results(@session)['pets']).to include('dog', 'cat', 'hamster')
end
it "should work without a locator string" do
@session.check(id: "form_pets_cat")
@session.click_button('awesome')
expect(extract_results(@session)['pets']).to include('dog', 'cat', 'hamster')
end
it "casts to string" do
@session.check(:form_pets_cat)
@session.click_button('awesome')

View File

@ -17,6 +17,12 @@ Capybara::SpecHelper.spec "#choose" do
expect(extract_results(@session)['gender']).to eq('both')
end
it "should work without a locator string" do
@session.choose(id: "gender_male")
@session.click_button('awesome')
expect(extract_results(@session)['gender']).to eq('male')
end
it "casts to string" do
@session.choose("Both")
@session.click_button(:awesome)

View File

@ -19,6 +19,13 @@ Capybara::SpecHelper.spec "#uncheck" do
expect(extract_results(@session)['pets']).not_to include('hamster')
end
it "should work without a locator string" do
@session.uncheck(id: "form_pets_hamster")
@session.click_button('awesome')
expect(extract_results(@session)['pets']).to include('dog')
expect(extract_results(@session)['pets']).not_to include('hamster')
end
it "casts to string" do
@session.uncheck(:form_pets_hamster)
@session.click_button('awesome')