public
Description: Webrat - Ruby Acceptance Testing for Web applications
Homepage: http://gitrdoc.com/brynary/webrat/tree/master/
Clone URL: git://github.com/brynary/webrat.git
Sinatra integration tests for following redirects
joshknowles (author)
Sun Jan 04 19:34:47 -0800 2009
commit  34ea3e64b896424b5aa1195610d5e61e5be466cf
tree    452de5ce8470208a9147859c6f3d9f1d535f8568
parent  c3120833b0a4fab942e1430088e513783304b2a0
...
22
23
24
25
26
27
28
...
22
23
24
 
25
26
27
0
@@ -22,7 +22,6 @@ module Webrat
0
         path, data, headers = *args
0
         params = data.merge(:env => headers || {})
0
         self.__send__("#{verb}_it", path, params)
0
-        request_page(response.location, :get, {}) while response.redirect?
0
       end
0
     end
0
   end
...
10
11
12
 
 
 
 
13
14
15
...
10
11
12
13
14
15
16
17
18
19
0
@@ -10,6 +10,10 @@ end
0
 get "/go" do
0
   erb :go
0
 end
0
+
0
+get "/redirect" do
0
+  redirect "/"
0
+end
0
  
0
 post "/go" do
0
   @user = params[:name]
...
16
17
18
 
 
 
 
 
19
...
16
17
18
19
20
21
22
23
24
0
@@ -16,4 +16,9 @@ class WebratTest < Test::Unit::TestCase
0
     
0
     assert response_body.include?("Hello, World")
0
   end
0
+  
0
+  def test_follows_redirects
0
+    visit "/redirect"
0
+    assert response_body.include?("visit")
0
+  end
0
 end
...
4
5
6
7
8
9
10
11
...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
4
5
6
 
 
7
8
9
...
25
26
27
 
 
 
 
 
 
 
 
 
 
28
29
0
@@ -4,8 +4,6 @@ describe Webrat::SinatraSession, "API" do
0
   before :each do
0
     Webrat.configuration.mode = :sinatra
0
     @sinatra_session = Webrat::SinatraSession.new
0
-    @response = mock("response", :redirect? => false)
0
-    @sinatra_session.stub!(:response => @response)
0
   end
0
 
0
   it "should delegate get to get_it" do
0
@@ -27,14 +25,4 @@ describe Webrat::SinatraSession, "API" do
0
     @sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
0
     @sinatra_session.delete("url", {}, "headers")
0
   end
0
-
0
-  it "should use Session#request_page to handle redirects" do
0
-    @response.should_receive(:redirect?).twice.and_return(true, false)
0
-    @response.should_receive(:location).and_return("redirect url")
0
-
0
-    @sinatra_session.should_receive(:get_it).with("original url", { :env => "headers" })
0
-    @sinatra_session.should_receive(:request_page).with("redirect url", :get, {})
0
-
0
-    @sinatra_session.get("original url", {}, "headers")
0
-  end
0
 end
0
\ No newline at end of file

Comments