Follow redirects for links

This commit is contained in:
Jonas Nicklas 2009-11-12 18:58:27 +01:00
parent eef4e74a9f
commit a2ee724e2d
4 changed files with 19 additions and 1 deletions

View File

@ -119,6 +119,7 @@ class Webcat::Driver::RackTest
def visit(path)
get(path)
follow_redirect! while response.redirect?
cache_body
end

View File

@ -49,6 +49,11 @@ shared_examples_for "session" do
end.should raise_error(Webcat::ElementNotFound)
end
end
it "should follow redirects" do
@session.click_link('Redirect')
@session.body.should include('You landed')
end
end
describe '#click_button' do

View File

@ -29,6 +29,18 @@ class TestApp < Sinatra::Base
erb :form
end
get '/redirect' do
redirect '/redirect_again'
end
get '/redirect_again' do
redirect '/landed'
end
get '/landed' do
"You landed"
end
post '/form' do
params[:form].to_yaml
end

View File

@ -10,7 +10,7 @@
<p>
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
dolore eu fugiat <a href="/redirect">Redirect</a> pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>