can use NamedTuple as *_with method's argument
This commit is contained in:
parent
979c5b4c3a
commit
9dd4273f2c
@ -26,8 +26,13 @@ describe "Form Fields CheckBox" do
|
||||
form.buttons.size.should eq 2
|
||||
end
|
||||
|
||||
it "can be found by button_with method" do
|
||||
it "can be found by button_with method, argument type: Hash" do
|
||||
button2 = form.button_with({"class" => "sndButton"})
|
||||
button2.value.should eq "sndButtonValue"
|
||||
end
|
||||
|
||||
it "can be found by button_with method, argument type: NamedTuple" do
|
||||
button2 = form.button_with({class: "sndButton"})
|
||||
button2.value.should eq "sndButtonValue"
|
||||
end
|
||||
end
|
||||
|
@ -52,10 +52,17 @@ describe "Form Fields CheckBox" do
|
||||
checkbox.name.should eq "remember_me"
|
||||
end
|
||||
|
||||
it "can be found by checkboxes_with method" do
|
||||
it "can be found by checkboxes_with method, argument type: Hash" do
|
||||
checkboxes = form.checkboxes_with({"class" => "some_checkbox"})
|
||||
checkboxes.size.should eq 2
|
||||
checkboxes[0].name.should eq "remember_me"
|
||||
checkboxes[1].name.should eq "forget_me"
|
||||
end
|
||||
|
||||
it "can be found by checkboxes_with method, argument type: NamedTuple" do
|
||||
checkboxes = form.checkboxes_with({class: "some_checkbox"})
|
||||
checkboxes.size.should eq 2
|
||||
checkboxes[0].name.should eq "remember_me"
|
||||
checkboxes[1].name.should eq "forget_me"
|
||||
end
|
||||
end
|
||||
|
@ -47,9 +47,17 @@ describe "Form Fields" do
|
||||
email_field.name.should eq "email"
|
||||
end
|
||||
|
||||
it "can be found by fields_with method" do
|
||||
it "can be found by fields_with method, argument type: Hash" do
|
||||
name_fields = form.fields_with("name")
|
||||
name_fields.size.should eq 2
|
||||
name_fields[0].name.should eq "name"
|
||||
end
|
||||
|
||||
it "can be found by fields_with method, argument type: NamedTuple" do
|
||||
name_field = form.field_with("name")
|
||||
name_field.name.should eq "name"
|
||||
|
||||
email_field = form.field_with({id: "emailID"})
|
||||
email_field.name.should eq "email"
|
||||
end
|
||||
end
|
||||
|
@ -71,4 +71,14 @@ describe "Form Fields RadioButton" do
|
||||
radiobuttons[1].value.should eq "phone"
|
||||
radiobuttons[2].value.should eq "mail"
|
||||
end
|
||||
|
||||
it "can be found by radiobutton_with method, argument type: Hash" do
|
||||
radiobutton = form.radiobutton_with({"id": "contactChoice1"})
|
||||
radiobutton.value.should eq "email"
|
||||
end
|
||||
|
||||
it "can be found by radiobutton_with method, argument type: NamedTuple" do
|
||||
radiobutton = form.radiobutton_with({id: "contactChoice1"})
|
||||
radiobutton.value.should eq "email"
|
||||
end
|
||||
end
|
||||
|
@ -32,10 +32,17 @@ describe "Mechanize Page test" do
|
||||
page.forms.first.name.should eq "sample_form"
|
||||
end
|
||||
|
||||
it "can detect form by using form_with method" do
|
||||
it "can detect form by using form_with method, argument type: Hash" do
|
||||
agent = Mechanize.new
|
||||
page = agent.get("http://example.com/form")
|
||||
form = page.form_with({"name" => "sample_form" })
|
||||
form.name.should eq "sample_form"
|
||||
end
|
||||
|
||||
it "can detect form by using form_with method, argument type: NamedTuple" do
|
||||
agent = Mechanize.new
|
||||
page = agent.get("http://example.com/form")
|
||||
form = page.form_with({name: "sample_form" })
|
||||
form.name.should eq "sample_form"
|
||||
end
|
||||
end
|
||||
|
@ -6,6 +6,9 @@ module MechanzeCr::ElementMatcher
|
||||
end
|
||||
|
||||
def {{plural.id}}_with(criteria, &block)
|
||||
if criteria.is_a?(NamedTuple)
|
||||
criteria = criteria.to_h
|
||||
end
|
||||
if criteria.is_a?(String)
|
||||
criteria = {"name" => criteria}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user