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:
parent
df5dc1ddbf
commit
a8789c612c
4 changed files with 23 additions and 3 deletions
|
@ -99,12 +99,20 @@ class Capybara::Driver::RackTest
|
|||
end
|
||||
|
||||
def submit(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
|
||||
|
|
|
@ -153,6 +153,14 @@ shared_examples_for "session" do
|
|||
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')
|
||||
@session.body.should include('You landed')
|
||||
|
|
|
@ -53,6 +53,10 @@ class TestApp < Sinatra::Base
|
|||
'<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
|
||||
end
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in a new issue