mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Fix issue with not defaulting locator
This commit is contained in:
parent
035e3e33e5
commit
09924678e8
4 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue