add test submit button for one form located in a different form

This commit is contained in:
Thomas Walpole 2013-02-11 09:47:40 -08:00
parent 239c212714
commit 83d0e16799
2 changed files with 27 additions and 8 deletions

View File

@ -169,12 +169,12 @@ Capybara::SpecHelper.spec '#click_button' do
end
it "should submit the associated form" do
@results['first_name'].should == 'John'
@results['which_form'].should == 'form2'
end
it "should submit the button that was clicked, but not other buttons" do
@results['outside_button'].should == 'outside_button'
@results['crappy'].should be_nil
@results['unused'].should be_nil
end
end
@ -185,15 +185,21 @@ Capybara::SpecHelper.spec '#click_button' do
end
it "should submit the associated form" do
@results['first_name'].should == 'John'
@results['which_form'].should == 'form1'
end
it "should submit the button that was clicked, but not other buttons" do
@results['outside_submit'].should == 'outside_submit'
@results['crappy'].should be_nil
@results['unused'].should be_nil
end
end
context "with submit button for form1 located within form2" do
it "should submit the form associated with the button" do
@session.click_button('other_form_button')
extract_results(@session)['which_form'].should == "form1"
end
end
context "with alt given on an image button" do
it "should submit the associated form" do

View File

@ -1,6 +1,6 @@
<h1>Form</h1>
<form id="the_form" action="/form" method="post">
<form action="/form" method="post">
<p>
<label for="form_title">Title</label>
@ -256,8 +256,21 @@
<input type="button" disabled value="Disabled button"/>
</p>
</form>
<input type="submit" name="form[outside_submit]" value="outside_submit" form="the_form"/>
<button type="submit" name="form[outside_button]" value="outside_button" form="the_form">Outside!</button>
<form id="form1" action="/form" method="post">
<input type="text" name="form[which_form]" value="form1" id="form_which_form"/>
<input type="submit" name="form[unused]" value="unused"/>
</form>
<form id="form2" action="/form" method="post">
<input type="text" name="form[which_form]" value="form2" id="form_which_form"/>
<input type="submit" name="form[unused]" value="unused"/>
<button type="submit" name="form[other_form_button]" value="other_form_button" form="form1">Form1</button>
</form>
<input type="submit" name="form[outside_submit]" value="outside_submit" form="form1"/>
<button type="submit" name="form[outside_button]" value="outside_button" form="form2">Outside!</button>
<form id="get-form" action="/form/get?foo=bar" method="get">
<p>