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
Refactor redirect support out of RailsSession & SinatraSession and into 
Session#request_page
joshknowles (author)
Mon Dec 29 18:19:13 -0800 2008
commit  ce364d16638c6d6906b5c00ffdcb0374caed7f5b
tree    9bc450cf3a87ab9e0bcae5a82e1c3b65f3bd71fd
parent  a56973854276e18545da4d89ff99ee73fabe8d9d
...
8
9
10
11
 
12
13
14
...
37
38
39
40
 
41
42
43
44
45
 
46
47
48
 
49
50
51
52
53
54
55
 
56
57
58
 
59
60
61
62
 
63
64
65
...
68
69
70
71
 
72
73
74
75
 
76
77
78
...
80
81
82
83
 
84
85
86
...
103
104
105
106
 
107
108
 
109
110
111
112
 
 
 
113
114
115
 
116
117
118
119
 
120
121
122
123
 
124
125
126
127
 
128
129
130
...
132
133
134
135
136
 
 
137
138
 
139
140
141
...
145
146
147
148
 
149
150
151
152
153
154
155
 
156
157
158
...
161
162
163
164
 
165
166
167
...
176
177
178
179
 
180
181
182
183
 
184
185
186
187
 
188
189
190
191
192
 
193
194
195
196
197
 
198
199
200
...
213
214
215
216
 
217
218
 
219
220
221
222
223
224
 
225
226
...
8
9
10
 
11
12
13
14
...
37
38
39
 
40
41
42
43
44
 
45
46
47
 
48
49
50
51
52
53
54
 
55
56
57
 
58
59
60
61
 
62
63
64
65
...
68
69
70
 
71
72
73
74
 
75
76
77
78
...
80
81
82
 
83
84
85
86
...
103
104
105
 
106
107
 
108
109
110
111
 
112
113
114
115
116
 
117
118
119
120
 
121
122
123
124
 
125
126
127
128
 
129
130
131
132
...
134
135
136
 
 
137
138
139
 
140
141
142
143
...
147
148
149
 
150
151
152
153
154
155
156
 
157
158
159
160
...
163
164
165
 
166
167
168
169
...
178
179
180
 
181
182
183
184
 
185
186
187
188
 
189
190
191
192
193
 
194
195
196
197
198
 
199
200
201
202
...
215
216
217
 
218
219
 
220
221
222
223
224
225
 
226
227
228
0
@@ -8,7 +8,7 @@ module Webrat
0
   # A page load or form submission returned an unsuccessful response code (500-599)
0
   class PageLoadError < WebratError
0
   end
0
-  
0
+
0
   def self.session_class
0
     case Webrat.configuration.mode
0
     when :rails
0
@@ -37,29 +37,29 @@ For example:
0
       STR
0
     end
0
   end
0
-  
0
+
0
   class Session
0
     extend Forwardable
0
     include Logging
0
     include SaveAndOpenPage
0
-    
0
+
0
     attr_reader :current_url
0
     attr_reader :elements
0
-    
0
+
0
     def initialize(context = nil) #:nodoc:
0
       @http_method     = :get
0
       @data            = {}
0
       @default_headers = {}
0
       @custom_headers  = {}
0
       @context         = context
0
-      
0
+
0
       reset
0
     end
0
-    
0
+
0
     def current_dom #:nodoc:
0
       current_scope.dom
0
     end
0
-    
0
+
0
     # For backwards compatibility -- removing in 1.0
0
     def current_page #:nodoc:
0
       page = OpenStruct.new
0
@@ -68,11 +68,11 @@ For example:
0
       page.data = @data
0
       page
0
     end
0
-    
0
+
0
     def doc_root #:nodoc:
0
       nil
0
     end
0
-    
0
+
0
     def header(key, value)
0
       @custom_headers[key] = value
0
     end
0
@@ -80,7 +80,7 @@ For example:
0
     def http_accept(mime_type)
0
       header('Accept', Webrat::MIME.mime_type(mime_type))
0
     end
0
-    
0
+
0
     def basic_auth(user, pass)
0
       encoded_login = ["#{user}:#{pass}"].pack("m*")
0
       header('HTTP_AUTHORIZATION', "Basic #{encoded_login}")
0
@@ -103,28 +103,30 @@ For example:
0
 
0
       save_and_open_page if exception_caught? && Webrat.configuration.open_error_files?
0
       raise PageLoadError.new("Page load was not successful (Code: #{response_code.inspect}):\n#{formatted_error}") unless success_code?
0
-      
0
+
0
       reset
0
-      
0
+
0
       @current_url  = url
0
       @http_method  = http_method
0
       @data         = data
0
-      
0
+
0
+      request_page(response.location, :get, data) if response.redirect?
0
+
0
       return response
0
     end
0
-    
0
+
0
     def success_code? #:nodoc:
0
       (200..499).include?(response_code)
0
     end
0
-    
0
+
0
     def exception_caught? #:nodoc:
0
       response_body =~ /Exception caught/
0
     end
0
-    
0
+
0
     def current_scope #:nodoc:
0
       scopes.last || page_scope
0
     end
0
-    
0
+
0
     # Reloads the last page requested. Note that this will resubmit forms
0
     # and their data.
0
     def reloads
0
@@ -132,10 +134,10 @@ For example:
0
     end
0
 
0
     webrat_deprecate :reload, :reloads
0
-      
0
-    
0
+
0
+
0
     # Works like click_link, but only looks for the link text within a given selector
0
-    # 
0
+    #
0
     # Example:
0
     #   click_link_within "#user_12", "Vote"
0
     def click_link_within(selector, link_text)
0
@@ -145,14 +147,14 @@ For example:
0
     end
0
 
0
     webrat_deprecate :clicks_link_within, :click_link_within
0
-    
0
+
0
     def within(selector)
0
       scopes.push(Scope.from_scope(self, current_scope, selector))
0
       ret = yield(current_scope)
0
       scopes.pop
0
       return ret
0
     end
0
-    
0
+
0
     # Issues a GET request for a page, follows any redirects, and verifies the final page
0
     # load was successful.
0
     #
0
@@ -161,7 +163,7 @@ For example:
0
     def visit(url = nil, http_method = :get, data = {})
0
       request_page(url, http_method, data)
0
     end
0
-    
0
+
0
     webrat_deprecate :visits, :visit
0
 
0
     # Subclasses can override this to show error messages without html
0
@@ -176,25 +178,25 @@ For example:
0
     def page_scope #:nodoc:
0
       @_page_scope ||= Scope.from_page(self, response, response_body)
0
     end
0
-    
0
+
0
     def dom
0
       page_scope.dom
0
     end
0
-    
0
+
0
     def xml_content_type?
0
       false
0
     end
0
-    
0
+
0
     def simulate
0
       return if Webrat.configuration.mode == :selenium
0
       yield
0
     end
0
-    
0
+
0
     def automate
0
       return unless Webrat.configuration.mode == :selenium
0
       yield
0
     end
0
-    
0
+
0
     def_delegators :current_scope, :fill_in,            :fills_in
0
     def_delegators :current_scope, :set_hidden_field
0
     def_delegators :current_scope, :submit_form
0
@@ -213,14 +215,14 @@ For example:
0
     def_delegators :current_scope, :field_by_xpath
0
     def_delegators :current_scope, :field_with_id
0
     def_delegators :current_scope, :select_option
0
-    
0
+
0
   private
0
-    
0
+
0
     def reset
0
       @elements     = {}
0
       @_scopes      = nil
0
       @_page_scope  = nil
0
     end
0
-    
0
+
0
   end
0
 end
...
50
51
52
53
54
55
56
57
58
59
...
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
...
50
51
52
 
53
 
 
54
55
56
...
79
80
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
83
84
0
@@ -50,10 +50,7 @@ module Webrat
0
 
0
     def do_request(http_method, url, data, headers) #:nodoc:
0
       update_protocol(url)
0
-
0
       integration_session.send(http_method, normalize_url(url), data, headers)
0
-      integration_session.follow_redirect_with_headers(headers) while integration_session.internal_redirect?
0
-      integration_session.status
0
     end
0
 
0
     # remove protocol, host and anchor
0
@@ -82,27 +79,6 @@ module Webrat
0
 end
0
 
0
 module ActionController #:nodoc:
0
-  module Integration #:nodoc:
0
-    class Session #:nodoc:
0
-      def internal_redirect?
0
-        redirect? && response.redirect_url_match?(host)
0
-      end
0
-
0
-      def follow_redirect_with_headers(h = {})
0
-        raise "Not a redirect! #{@status} #{@status_message}" unless redirect?
0
-
0
-        h = Hash.new if h.nil?
0
-        h['HTTP_REFERER'] = request.url
0
-
0
-        location = headers["location"]
0
-        location = location.first if location.is_a?(Array)
0
-        
0
-        get(location, {}, h)
0
-        status
0
-      end
0
-    end
0
-  end
0
-
0
   IntegrationTest.class_eval do
0
     include Webrat::Methods
0
     include Webrat::Matchers
...
11
12
13
14
15
16
17
...
11
12
13
 
14
15
16
0
@@ -11,7 +11,6 @@ module Webrat
0
         path, data, headers = *args
0
         params = data.merge({:env => headers || {}})
0
         self.__send__("#{verb}_it", path, params)
0
-        get_it(@response.location, params) while @response.redirect?
0
       end
0
     end
0
   end
...
2
3
4
5
 
6
7
8
9
 
10
11
12
13
 
14
15
 
16
17
 
18
19
20
21
22
 
 
 
 
 
23
24
25
 
 
26
27
28
 
 
29
30
31
 
 
 
 
 
32
33
34
35
...
2
3
4
 
5
6
7
8
 
9
10
11
12
 
13
14
 
15
16
 
17
18
19
20
 
 
21
22
23
24
25
26
 
 
27
28
29
 
 
30
31
32
 
 
33
34
35
36
37
38
39
40
41
0
@@ -2,33 +2,39 @@ module Webrat #:nodoc:
0
   def self.session_class #:nodoc:
0
     TestSession
0
   end
0
-  
0
+
0
   class TestSession < Session #:nodoc:
0
     attr_accessor :response_body
0
     attr_writer :response_code
0
-    
0
+
0
     def doc_root
0
       File.expand_path(File.join(".", "public"))
0
     end
0
-    
0
+
0
     def response
0
-      @response ||= Object.new
0
+      @response ||= TestResponse.new
0
     end
0
-    
0
+
0
     def response_code
0
       @response_code || 200
0
     end
0
-    
0
-    def get(url, data)
0
+
0
+    def get(url, data, headers = nil)
0
+    end
0
+
0
+    def post(url, data, headers = nil)
0
     end
0
-    
0
-    def post(url, data)
0
+
0
+    def put(url, data, headers = nil)
0
     end
0
-    
0
-    def put(url, data)
0
+
0
+    def delete(url, data, headers = nil)
0
     end
0
-    
0
-    def delete(url, data)
0
+  end
0
+  
0
+  class TestResponse #:nodoc:
0
+    def redirect?
0
+      false
0
     end
0
   end
0
 end
0
\ No newline at end of file
...
1
2
3
4
 
5
6
7
8
9
 
10
11
12
 
13
14
15
16
 
17
18
19
20
 
21
22
23
 
24
25
26
27
28
29
30
 
31
32
33
34
35
36
37
 
38
39
40
41
42
43
44
 
45
46
47
...
58
59
60
61
 
62
63
64
...
89
90
91
92
 
93
94
95
96
97
98
99
 
100
101
102
 
103
104
105
...
109
110
111
112
 
113
114
 
 
 
 
 
 
 
 
 
115
116
 
117
...
1
2
3
 
4
5
6
7
8
 
9
10
11
 
12
13
14
15
 
16
17
18
19
 
20
21
22
 
23
24
25
26
27
28
29
 
30
31
32
33
34
35
36
 
37
38
39
40
41
42
43
 
44
45
46
47
...
58
59
60
 
61
62
63
64
...
89
90
91
 
92
93
94
95
96
97
98
 
99
100
101
 
102
103
104
105
...
109
110
111
 
112
113
114
115
116
117
118
119
120
121
122
123
124
 
125
126
0
@@ -1,47 +1,47 @@
0
 require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
0
 
0
 describe Webrat::Session do
0
-  
0
+
0
   it "should not have a doc_root" do
0
     session = Webrat::Session.new
0
     session.doc_root.should be_nil
0
   end
0
-  
0
+
0
   it "should expose the current_dom" do
0
     session = Webrat::Session.new
0
-    
0
+
0
     def session.response
0
       Object.new
0
     end
0
-    
0
+
0
     def session.response_body
0
       "<html></html>"
0
     end
0
-    
0
+
0
     session.should respond_to(:current_dom)
0
   end
0
-  
0
+
0
   it "should open the page in the browser in MacOSX" do
0
     session = Webrat::Session.new
0
     session.stub!(:ruby_platform => 'darwin')
0
     session.should_receive(:`).with("open path")
0
     session.open_in_browser("path")
0
   end
0
-  
0
+
0
   it "should open the page in the browser in cygwin" do
0
     session = Webrat::Session.new
0
     session.stub!(:ruby_platform => 'i386-cygwin')
0
     session.should_receive(:`).with("rundll32 url.dll,FileProtocolHandler path\\to\\file")
0
     session.open_in_browser("path/to/file")
0
   end
0
-  
0
+
0
   it "should open the page in the browser in Win32" do
0
     session = Webrat::Session.new
0
     session.stub!(:ruby_platform => 'win32')
0
     session.should_receive(:`).with("rundll32 url.dll,FileProtocolHandler path\\to\\file")
0
     session.open_in_browser("path/to/file")
0
   end
0
-  
0
+
0
   it "should provide a current_page for backwards compatibility" do
0
     session = Webrat::Session.new
0
     current_page = session.current_page
0
@@ -58,7 +58,7 @@ describe Webrat::Session do
0
 
0
   it "should return a copy of the headers to be sent" do
0
     session = Webrat::Session.new
0
-    session.instance_eval { 
0
+    session.instance_eval {
0
       @default_headers = {'HTTP_X_FORWARDED_FOR' => '192.168.1.1'}
0
       @custom_headers = {'Accept' => 'application/xml'}
0
     }
0
@@ -89,17 +89,17 @@ describe Webrat::Session do
0
     before(:each) do
0
       webrat_session = Webrat::Session.new
0
     end
0
-  
0
+
0
     it "should raise an error if the request is not a success" do
0
       webrat_session.stub!(:get)
0
       webrat_session.stub!(:response_body => "Exception caught")
0
       webrat_session.stub!(:response_code => 500)
0
       webrat_session.stub!(:formatted_error => "application error")
0
       webrat_session.stub!(:save_and_open_page)
0
-  
0
+
0
       lambda { webrat_session.request_page('some url', :get, {}) }.should raise_error(Webrat::PageLoadError)
0
     end
0
-    
0
+
0
     it "should raise an error but not open if the request is not a success and config quashes save_and_open" do
0
       Webrat.configure do |config|
0
         config.open_error_files = false
0
@@ -109,8 +109,17 @@ describe Webrat::Session do
0
       webrat_session.stub!(:response_code => 500)
0
       webrat_session.stub!(:formatted_error => "application error")
0
       webrat_session.should_not_receive(:save_and_open_page)
0
-  
0
+
0
       lambda { webrat_session.request_page('some url', :get, {}) }.should raise_error(Webrat::PageLoadError)
0
     end
0
+
0
+    it "should follow redirects" do
0
+      webrat_session.response.should_receive(:redirect?).twice.and_return(true, false)
0
+      webrat_session.response.should_receive(:location).once.and_return("/newurl")
0
+
0
+      webrat_session.request_page("/oldurl", :get, {})
0
+
0
+      webrat_session.current_url.should == "/newurl"
0
+    end
0
   end
0
-end
0
+end
0
\ No newline at end of file
...
6
7
8
9
10
11
12
13
...
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
6
7
8
 
 
9
10
11
...
78
79
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
82
83
...
85
86
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
89
0
@@ -6,8 +6,6 @@ describe Webrat::RailsSession do
0
   before :each do
0
     Webrat.configuration.mode = :rails
0
     @integration_session = mock("integration_session")
0
-    @integration_session.stub!(:internal_redirect?)
0
-    @integration_session.stub!(:status)
0
   end
0
 
0
   it "should delegate response_body to the session response body" do
0
@@ -80,44 +78,6 @@ describe Webrat::RailsSession do
0
     end
0
   end
0
 
0
-  context "following redirects" do
0
-    it "should use forward headers when following redirects" do
0
-      @integration_session.stub!(:post)
0
-      @integration_session.stub!(:host)
0
-      @integration_session.stub!(:status)
0
-
0
-      @integration_session.should_receive(:internal_redirect?).twice.and_return(true, false)
0
-      @integration_session.should_receive(:follow_redirect_with_headers).with("headers")
0
-
0
-      rails_session = Webrat::RailsSession.new(@integration_session)
0
-      rails_session.post("url", "data", "headers")
0
-    end
0
-
0
-    it "should follow internal redirects" do
0
-      @integration_session.stub!(:get)
0
-      @integration_session.stub!(:host)
0
-      @integration_session.stub!(:status)
0
-
0
-      @integration_session.should_receive(:internal_redirect?).twice.and_return(true, false)
0
-      @integration_session.should_receive(:follow_redirect_with_headers)
0
-
0
-      rails_session = Webrat::RailsSession.new(@integration_session)
0
-      rails_session.get("url", "data", "headers")
0
-    end
0
-
0
-    it "should not follow external redirects" do
0
-      @integration_session.stub!(:get)
0
-      @integration_session.stub!(:host)
0
-      @integration_session.stub!(:status)
0
-
0
-      @integration_session.should_receive(:internal_redirect?).and_return(false)
0
-      @integration_session.should_not_receive(:follow_redirect_with_headers)
0
-
0
-      rails_session = Webrat::RailsSession.new(@integration_session)
0
-      rails_session.get("url", "data", "headers")
0
-    end
0
-  end
0
-
0
   it "should provide a saved_page_dir" do
0
     Webrat::RailsSession.new(mock("integration session")).should respond_to(:saved_page_dir)
0
   end
0
@@ -125,66 +85,4 @@ describe Webrat::RailsSession do
0
   it "should provide a doc_root" do
0
     Webrat::RailsSession.new(mock("integration session")).should respond_to(:doc_root)
0
   end
0
-end
0
-
0
-describe ActionController::Integration::Session do
0
-  before :each do
0
-    Webrat.configuration.mode = :rails
0
-    @integration_session = ActionController::Integration::Session.new
0
-    @integration_session.stub!(:request => mock("request", :url => "http://source.url/"))
0
-    @integration_session.stub!(:response => mock("response"))
0
-  end
0
-
0
-  describe "internal_redirect?" do
0
-    it "should return false if the response is not a redirect" do
0
-      @integration_session.should_receive(:redirect?).and_return(false)
0
-      @integration_session.internal_redirect?.should == false
0
-    end
0
-
0
-    it "should return false if the response was a redirect but the response location does not match the request host" do
0
-      @integration_session.should_receive(:redirect?).and_return(true)
0
-      @integration_session.response.should_receive(:redirect_url_match?).and_return(false)
0
-      @integration_session.internal_redirect?.should == false
0
-    end
0
-
0
-    it "should return true if the response is a redirect and the response location matches the request host" do
0
-      @integration_session.should_receive(:redirect?).and_return(true)
0
-      @integration_session.response.should_receive(:redirect_url_match?).and_return(true)
0
-      @integration_session.internal_redirect?.should == true
0
-    end
0
-  end
0
-
0
-  describe "follow_redirect_with_headers" do
0
-    before do
0
-      Webrat.configuration.mode = :rails
0
-      @integration_session.stub!(:headers).and_return({ 'location' => ["/"]})
0
-      @integration_session.stub!(:redirect?).and_return true
0
-      @integration_session.stub!(:get)
0
-    end
0
-
0
-    it "should raise an exception if response wasn't a redirect" do
0
-      @integration_session.stub!(:redirect?).and_return false
0
-      lambda { @integration_session.follow_redirect_with_headers }.should raise_error
0
-    end
0
-
0
-    it "should set the HTTP referer header" do
0
-      headers = {}
0
-
0
-      @integration_session.follow_redirect_with_headers(headers)
0
-      headers["HTTP_REFERER"].should == "http://source.url/"
0
-    end
0
-
0
-    it "should GET the first location header" do
0
-      @integration_session.stub!("headers").and_return({ 'location' => ['/target'] })
0
-
0
-      @integration_session.should_receive(:get).with("/target", {}, hash_including("headers" => "foo"))
0
-
0
-      @integration_session.follow_redirect_with_headers({"headers" => "foo"})
0
-    end
0
-
0
-    it "should return the status" do
0
-      @integration_session.stub!(:status).and_return "202"
0
-      @integration_session.follow_redirect_with_headers.should == "202"
0
-    end
0
-  end
0
 end
0
\ No newline at end of file
...
4
5
6
7
8
9
10
11
12
13
14
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
...
4
5
6
 
 
 
 
 
7
8
9
...
25
26
27
 
 
 
 
 
 
 
 
 
 
28
29
0
@@ -4,11 +4,6 @@ describe Webrat::SinatraSession do
0
   before :each do
0
     Webrat.configuration.mode = :sinatra
0
     @sinatra_session = Webrat::SinatraSession.new
0
-
0
-    @response = mock(:response)
0
-    @response.stub!(:redirect?)
0
-
0
-    @sinatra_session.instance_variable_set("@response", @response)
0
   end
0
 
0
   it "should delegate get to get_it" do
0
@@ -30,14 +25,4 @@ describe Webrat::SinatraSession do
0
     @sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
0
     @sinatra_session.delete("url", {}, "headers")
0
   end
0
-
0
-  it "should forward headers when following 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(:get_it).with("redirect url", { :env => "headers" })
0
-
0
-    @sinatra_session.get("original url", {}, "headers")
0
-  end
0
 end
0
\ No newline at end of file
...
13
14
15
16
 
17
18
19
20
21
 
22
23
24
25
26
27
28
 
29
30
31
 
 
 
 
 
 
 
 
 
32
33
34
...
45
46
47
48
 
49
...
13
14
15
 
16
17
18
19
20
 
21
22
23
24
25
26
27
 
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
...
54
55
56
 
57
58
0
@@ -13,22 +13,31 @@ describe "visit" do
0
     webrat_session.should_receive(:get).with("/", {})
0
     visit("/")
0
   end
0
-  
0
+
0
   it "should assert valid response" do
0
     webrat_session.response_code = 501
0
     lambda { visit("/") }.should raise_error(Webrat::PageLoadError)
0
   end
0
-  
0
+
0
   [200, 300, 400, 499].each do |status|
0
     it "should consider the #{status} status code as success" do
0
       webrat_session.response_code = status
0
       lambda { visit("/") }.should_not raise_error
0
     end
0
   end
0
-  
0
+
0
   it "should require a visit before manipulating page" do
0
     lambda { fill_in "foo", :with => "blah" }.should raise_error(Webrat::WebratError)
0
   end
0
+
0
+  it "should follow redirects" do
0
+    webrat_session.response.should_receive(:redirect?).twice.and_return(true, false)
0
+    webrat_session.response.should_receive(:location).once.and_return("/newurl")
0
+
0
+    visit("/oldurl")
0
+
0
+    current_url.should == "/newurl"
0
+  end
0
 end
0
 
0
 describe "visit with referer" do
0
@@ -45,5 +54,5 @@ describe "visit with referer" do
0
     webrat_session.should_receive(:get).with("/", {}, {"HTTP_REFERER" => "/old_url"})
0
     visit("/")
0
   end
0
-  
0
+
0
 end

Comments