add button_with method
This commit is contained in:
parent
4df61c7906
commit
fb94479166
33
spec/form/button_spec.cr
Normal file
33
spec/form/button_spec.cr
Normal file
@ -0,0 +1,33 @@
|
||||
require "../spec_helper"
|
||||
|
||||
WebMock.stub(:get, "example.com/form/button").to_return(body:
|
||||
<<-BODY
|
||||
<html>
|
||||
<head>
|
||||
<title>page_title</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="post_path" method="post" name="sample_form">
|
||||
<button type="submit" name="fstButton" value="fstButtonValue">
|
||||
<input type="button" class="sndButton" value="sndButtonValue">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
BODY
|
||||
)
|
||||
|
||||
describe "Form Fields CheckBox" do
|
||||
agent = Mechanize.new
|
||||
|
||||
page = agent.get("http://example.com/form/button")
|
||||
form = page.forms[0]
|
||||
|
||||
it "returns buttons" do
|
||||
form.buttons.size.should eq 2
|
||||
end
|
||||
|
||||
it "can be found by button_with method" do
|
||||
button2 = form.button_with({"class" => "sndButton"})
|
||||
button2.value.should eq "sndButtonValue"
|
||||
end
|
||||
end
|
@ -51,6 +51,7 @@ class MechanizeCr::Form
|
||||
elements_with "field"
|
||||
elements_with "radiobutton"
|
||||
elements_with "checkbox", "checkboxes"
|
||||
elements_with "button"
|
||||
|
||||
# Returns all fields of type Textarea
|
||||
def textareas
|
||||
|
Loading…
Reference in New Issue
Block a user