0
@@ -113,14 +113,22 @@ describe Webrat::Session do
0
lambda { webrat_session.request_page('some url', :get, {}) }.should raise_error(Webrat::PageLoadError)
0
- it "should follow redirects" do
0
- webrat_session.should_receive(:redirect?).twice.and_return(true, false)
0
+ it "should follow internal redirects" do
0
+ webrat_session.should_receive(:internal_redirect?).twice.and_return(true, false)
0
webrat_session.response.should_receive(:headers).once.and_return({ "Location" => "/newurl" })
0
webrat_session.request_page("/oldurl", :get, {})
0
webrat_session.current_url.should == "/newurl"
0
+ it "should now follow external redirects" do
0
+ webrat_session.should_receive(:internal_redirect?).and_return(false)
0
+ webrat_session.request_page("/oldurl", :get, {})
0
+ webrat_session.current_url.should == "/oldurl"
0
describe "#redirect?" do
0
@@ -138,4 +146,29 @@ describe Webrat::Session do
0
webrat_session.redirect?.should be_false
0
+ describe "#internal_redirect?" do
0
+ webrat_session = Webrat::Session.new
0
+ it "should return true if the last response was a redirect and the host of the current_url matches that of the response location" do
0
+ webrat_session.stub!(:redirect? => true)
0
+ webrat_session.stub!(:current_url => "http://example.com")
0
+ webrat_session.stub!(:response_location => "http://example.com")
0
+ webrat_session.internal_redirect?.should be_true
0
+ it "should return false if the last response was not a redirect" do
0
+ webrat_session.stub!(:redirect? => false)
0
+ webrat_session.internal_redirect?.should be_false
0
+ it "should return false if the last response was a redirect but the host of the current_url doesn't matches that of the response location" do
0
+ webrat_session.stub!(:redirect? => true)
0
+ webrat_session.stub!(:current_url => "http://example.com")
0
+ webrat_session.stub!(:response_location => "http://google.com")
0
+ webrat_session.internal_redirect?.should be_false
0
\ No newline at end of file
Hey, did you ever add a way to get a hold of the redirect location in a platform independent way?