formaction support

This commit is contained in:
Thomas Walpole 2013-12-12 11:47:45 -08:00
parent a4399a57f7
commit 253dbcf7f6
3 changed files with 18 additions and 1 deletions

View File

@ -71,7 +71,8 @@ class Capybara::RackTest::Form < Capybara::RackTest::Node
end
def submit(button)
driver.submit(method, native['action'].to_s, params(button))
action = (button && button['formaction']) || native['action']
driver.submit(method, action.to_s, params(button))
end
def multipart?

View File

@ -346,6 +346,15 @@ Capybara::SpecHelper.spec '#click_button' do
end
end
context "with formaction attribute on button" do
it "should submit to the formaction attribute" do
@session.click_button('Formaction button')
@session.current_path.should == '/form'
@results = extract_results(@session)
@results['which_form'].should == 'formaction form'
end
end
it "should serialize and send valueless buttons that were clicked" do
@session.click_button('No Value!')
@results = extract_results(@session)

View File

@ -429,6 +429,13 @@ New line after and before textarea tag
</p>
</form>
<form action="/other_form" method="post">
<p>
<input type="text" name="form[which_form]" value="formaction form"/>
</p>
<input type="submit" name="form[button]" formaction="/form" value="Formaction button"/>
</form>
<form action="relative" method="post">
<p>
<input type="submit" name="form[relative]" value="Relative Action" />