Sinatra integration tests for following redirects
This commit is contained in:
parent
c3120833b0
commit
34ea3e64b8
@ -22,7 +22,6 @@ module Webrat
|
|||||||
path, data, headers = *args
|
path, data, headers = *args
|
||||||
params = data.merge(:env => headers || {})
|
params = data.merge(:env => headers || {})
|
||||||
self.__send__("#{verb}_it", path, params)
|
self.__send__("#{verb}_it", path, params)
|
||||||
request_page(response.location, :get, {}) while response.redirect?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,6 +10,10 @@ end
|
|||||||
get "/go" do
|
get "/go" do
|
||||||
erb :go
|
erb :go
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/redirect" do
|
||||||
|
redirect "/"
|
||||||
|
end
|
||||||
|
|
||||||
post "/go" do
|
post "/go" do
|
||||||
@user = params[:name]
|
@user = params[:name]
|
||||||
|
@ -16,4 +16,9 @@ class WebratTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert response_body.include?("Hello, World")
|
assert response_body.include?("Hello, World")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_follows_redirects
|
||||||
|
visit "/redirect"
|
||||||
|
assert response_body.include?("visit")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,8 +4,6 @@ describe Webrat::SinatraSession, "API" do
|
|||||||
before :each do
|
before :each do
|
||||||
Webrat.configuration.mode = :sinatra
|
Webrat.configuration.mode = :sinatra
|
||||||
@sinatra_session = Webrat::SinatraSession.new
|
@sinatra_session = Webrat::SinatraSession.new
|
||||||
@response = mock("response", :redirect? => false)
|
|
||||||
@sinatra_session.stub!(:response => @response)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should delegate get to get_it" do
|
it "should delegate get to get_it" do
|
||||||
@ -27,14 +25,4 @@ describe Webrat::SinatraSession, "API" do
|
|||||||
@sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
|
@sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
|
||||||
@sinatra_session.delete("url", {}, "headers")
|
@sinatra_session.delete("url", {}, "headers")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use Session#request_page to handle redirects" do
|
|
||||||
@response.should_receive(:redirect?).twice.and_return(true, false)
|
|
||||||
@response.should_receive(:location).and_return("redirect url")
|
|
||||||
|
|
||||||
@sinatra_session.should_receive(:get_it).with("original url", { :env => "headers" })
|
|
||||||
@sinatra_session.should_receive(:request_page).with("redirect url", :get, {})
|
|
||||||
|
|
||||||
@sinatra_session.get("original url", {}, "headers")
|
|
||||||
end
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user