1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Added support for GET forms

This commit is contained in:
Theo Hultberg and Jonas Nicklas 2009-11-17 23:36:27 +01:00 committed by Jonas Nicklas
parent df5dc1ddbf
commit a8789c612c
4 changed files with 23 additions and 3 deletions

View file

@ -99,12 +99,20 @@ class Capybara::Driver::RackTest
end
def submit(button)
session.submit(node['action'].to_s, params(button))
if post?
session.submit(node['action'].to_s, params(button))
else
session.visit(node['action'].to_s + '?' + params(button))
end
end
def multipart?
self[:enctype] == "multipart/form-data"
end
def post?
self[:method] =~ /post/i
end
end
include ::Rack::Test::Methods

View file

@ -152,6 +152,14 @@ shared_examples_for "session" do
end.should raise_error(Capybara::ElementNotFound)
end
end
it "should serialize and send GET forms" do
@session.visit('/form')
@session.click_button('med')
#puts @session.body
@results = extract_results(@session)
@results['middle_name'].should == 'Darren'
end
it "should follow redirects" do
@session.click_button('Go FAR')

View file

@ -52,6 +52,10 @@ class TestApp < Sinatra::Base
post '/form' do
'<pre id="results">' + params[:form].to_yaml + '</pre>'
end
get '/form/get' do
'<pre id="results">' + params[:form].to_yaml + '</pre>'
end
post '/upload' do
params[:form][:document][:tempfile].read

View file

@ -88,9 +88,9 @@
</p>
</form>
<form action="/blah" method="get"/>
<form action="/form/get" method="get">
<p>
<label for="form_middle_name">Last Name</label>
<label for="form_middle_name">Middle Name</label>
<input type="text" name="form[middle_name]" value="Darren" id="form_middle_name"/>
</p>