Merge pull request #1377 from nidalaa/formmethod_support

Formmethod attribute support
This commit is contained in:
Thomas Walpole 2014-08-27 09:16:26 -07:00
commit da85ae7226
3 changed files with 12 additions and 1 deletions

View File

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

View File

@ -355,6 +355,15 @@ Capybara::SpecHelper.spec '#click_button' do
end
end
context "with formmethod attribute on button" do
it "should submit to the formethod attribute" do
@session.click_button('Formmethod button')
expect(@session.current_path).to eq '/form/get'
@results = extract_results(@session)
expect(@results['which_form']).to eq '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

@ -434,6 +434,7 @@ New line after and before textarea tag
<input type="text" name="form[which_form]" value="formaction form"/>
</p>
<input type="submit" name="form[button]" formaction="/form" value="Formaction button"/>
<input type="submit" name="form[button]" formaction="/form/get" formmethod="get" value="Formmethod button"/>
</form>
<form action="relative" method="post">