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 handling as Merb response doesn't support the redirect? 
method.  All integration specs now passing again.
joshknowles (author)
Mon Dec 29 19:45:55 -0800 2008
commit  e77495bc04cacfb1e7684bd938a7c6d32545130f
tree    acba813b4992b9ef522700013ac13c3c991b54c1
parent  b222d3fde3983b4fe7f8dfa0f0c3959494e3a149
...
110
111
112
113
 
114
115
116
...
118
119
120
 
 
 
 
121
122
123
...
110
111
112
 
113
114
115
116
...
118
119
120
121
122
123
124
125
126
127
0
@@ -110,7 +110,7 @@ For example:
0
       @http_method  = http_method
0
       @data         = data
0
 
0
-      request_page(response.location, :get, data) if response.redirect?
0
+      request_page(response.location, :get, data) if redirect?
0
 
0
       return response
0
     end
0
@@ -118,6 +118,10 @@ For example:
0
     def success_code? #:nodoc:
0
       (200..499).include?(response_code)
0
     end
0
+    
0
+    def redirect? #:nodoc:
0
+      response_code / 100 == 3
0
+    end
0
 
0
     def exception_caught? #:nodoc:
0
       response_body =~ /Exception caught/
...
12
13
14
15
 
16
17
18
...
31
32
33
34
35
36
37
38
39
40
41
...
12
13
14
 
15
16
17
18
...
31
32
33
 
 
 
 
 
 
34
35
0
@@ -12,7 +12,7 @@ module Webrat #:nodoc:
0
     end
0
 
0
     def response
0
-      @response ||= TestResponse.new
0
+      @response ||= Object.new
0
     end
0
 
0
     def response_code
0
@@ -31,10 +31,4 @@ module Webrat #:nodoc:
0
     def delete(url, data, headers = nil)
0
     end
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
...
114
115
116
117
 
118
119
120
...
122
123
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
126
...
114
115
116
 
117
118
119
120
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
0
@@ -114,7 +114,7 @@ describe Webrat::Session do
0
     end
0
 
0
     it "should follow redirects" do
0
-      webrat_session.response.should_receive(:redirect?).twice.and_return(true, false)
0
+      webrat_session.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
@@ -122,4 +122,20 @@ describe Webrat::Session do
0
       webrat_session.current_url.should == "/newurl"
0
     end
0
   end
0
+
0
+  describe "#redirect?" do
0
+    before(:each) do
0
+      webrat_session = Webrat::Session.new
0
+    end
0
+
0
+    it "should return true if the last response was a redirect" do
0
+      webrat_session.stub!(:response_code => 301)
0
+      webrat_session.redirect?.should be_true
0
+    end
0
+
0
+    it "should return false if the last response wasn't a redirect" do
0
+      webrat_session.stub!(:response_code => 200)
0
+      webrat_session.redirect?.should be_false
0
+    end
0
+  end
0
 end
0
\ No newline at end of file
...
24
25
26
27
 
28
29
30
...
34
35
36
 
37
38
39
40
41
 
42
43
44
...
47
48
49
50
 
51
52
53
54
55
 
56
57
58
...
64
65
66
67
 
68
69
70
...
78
79
80
81
 
82
83
84
...
24
25
26
 
27
28
29
30
...
34
35
36
37
38
39
40
41
 
42
43
44
45
...
48
49
50
 
51
52
53
54
55
 
56
57
58
59
...
65
66
67
 
68
69
70
71
...
79
80
81
 
82
83
84
85
0
@@ -24,7 +24,7 @@ describe "click_area" do
0
     webrat_session.response_code = 501
0
     lambda { click_area "Berlin" }.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
       with_html <<-HTML
0
@@ -34,11 +34,12 @@ describe "click_area" do
0
         </map>
0
         </html>
0
       HTML
0
+      webrat_session.stub!(:redirect? => false)
0
       webrat_session.response_code = status
0
       lambda { click_area "Berlin" }.should_not raise_error
0
     end
0
   end
0
-  
0
+
0
   it "should fail if the area doesn't exist" do
0
     with_html <<-HTML
0
       <html>
0
@@ -47,12 +48,12 @@ describe "click_area" do
0
       </map>
0
       </html>
0
     HTML
0
-    
0
+
0
     lambda {
0
       click_area "Missing area"
0
     }.should raise_error(Webrat::NotFoundError)
0
   end
0
-  
0
+
0
   it "should not be case sensitive" do
0
     with_html <<-HTML
0
       <html>
0
@@ -64,7 +65,7 @@ describe "click_area" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_area "berlin"
0
   end
0
-  
0
+
0
 
0
   it "should follow relative links" do
0
     webrat_session.stub!(:current_url => "/page")
0
@@ -78,7 +79,7 @@ describe "click_area" do
0
     webrat_session.should_receive(:get).with("/page/sub", {})
0
     click_area "Berlin"
0
   end
0
-  
0
+
0
   it "should follow fully qualified local links" do
0
     with_html <<-HTML
0
       <html>
...
7
8
9
10
 
11
12
13
 
14
15
16
...
23
24
25
26
 
27
28
29
...
35
36
37
38
 
39
40
41
...
47
48
49
50
 
51
52
53
...
59
60
61
62
 
63
64
65
...
69
70
71
 
72
73
74
75
76
 
77
78
79
...
88
89
90
91
 
92
93
94
...
100
101
102
103
 
104
105
106
...
115
116
117
118
 
119
120
121
...
127
128
129
130
 
131
132
133
...
139
140
141
142
 
143
144
145
...
152
153
154
155
 
156
157
158
...
177
178
179
180
181
 
 
182
183
184
...
191
192
193
194
 
195
196
197
...
204
205
206
207
 
208
209
210
...
221
222
223
224
 
225
226
227
...
234
235
236
237
 
238
239
240
...
250
251
252
253
 
254
255
256
...
264
265
266
267
 
268
269
270
...
302
303
304
305
 
306
307
308
...
315
316
317
318
 
319
320
321
...
328
329
330
331
 
332
333
334
...
342
343
344
345
 
346
347
348
349
350
351
352
 
353
354
355
...
381
382
383
384
 
385
386
387
...
397
398
399
400
 
401
402
403
...
449
450
451
452
 
453
454
455
...
461
462
463
464
 
465
466
467
...
7
8
9
 
10
11
12
 
13
14
15
16
...
23
24
25
 
26
27
28
29
...
35
36
37
 
38
39
40
41
...
47
48
49
 
50
51
52
53
...
59
60
61
 
62
63
64
65
...
69
70
71
72
73
74
75
76
 
77
78
79
80
...
89
90
91
 
92
93
94
95
...
101
102
103
 
104
105
106
107
...
116
117
118
 
119
120
121
122
...
128
129
130
 
131
132
133
134
...
140
141
142
 
143
144
145
146
...
153
154
155
 
156
157
158
159
...
178
179
180
 
 
181
182
183
184
185
...
192
193
194
 
195
196
197
198
...
205
206
207
 
208
209
210
211
...
222
223
224
 
225
226
227
228
...
235
236
237
 
238
239
240
241
...
251
252
253
 
254
255
256
257
...
265
266
267
 
268
269
270
271
...
303
304
305
 
306
307
308
309
...
316
317
318
 
319
320
321
322
...
329
330
331
 
332
333
334
335
...
343
344
345
 
346
347
348
349
350
351
352
 
353
354
355
356
...
382
383
384
 
385
386
387
388
...
398
399
400
 
401
402
403
404
...
450
451
452
 
453
454
455
456
...
462
463
464
 
465
466
467
468
0
@@ -7,10 +7,10 @@ describe "click_button" do
0
       <form method="get" action="/login"></form>
0
       </html>
0
     HTML
0
-    
0
+
0
     lambda { click_button }.should raise_error(Webrat::NotFoundError)
0
   end
0
-  
0
+
0
   it "should fail if input is not a submit button" do
0
     with_html <<-HTML
0
       <html>
0
@@ -23,7 +23,7 @@ describe "click_button" do
0
     lambda { click_button }.should raise_error(Webrat::NotFoundError)
0
   end
0
 
0
-  
0
+
0
   it "should fail if button is disabled" do
0
     with_html <<-HTML
0
       <html>
0
@@ -35,7 +35,7 @@ describe "click_button" do
0
 
0
     lambda { click_button }.should raise_error(Webrat::DisabledFieldError)
0
   end
0
-  
0
+
0
   it "should default to get method" do
0
     with_html <<-HTML
0
       <html>
0
@@ -47,7 +47,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get)
0
     click_button
0
   end
0
-  
0
+
0
   it "should assert valid response" do
0
     with_html <<-HTML
0
       <html>
0
@@ -59,7 +59,7 @@ describe "click_button" do
0
     webrat_session.response_code = 501
0
     lambda { click_button }.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
       with_html <<-HTML
0
@@ -69,11 +69,12 @@ describe "click_button" do
0
         </form>
0
         </html>
0
       HTML
0
+      webrat_session.stub!(:redirect? => false)
0
       webrat_session.response_code = status
0
       lambda { click_button }.should_not raise_error
0
     end
0
   end
0
-  
0
+
0
   it "should submit the first form by default" do
0
     with_html <<-HTML
0
       <html>
0
@@ -88,7 +89,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/form1", {})
0
     click_button
0
   end
0
-  
0
+
0
   it "should not explode on file fields" do
0
     with_html <<-HTML
0
       <html>
0
@@ -100,7 +101,7 @@ describe "click_button" do
0
     HTML
0
     click_button
0
   end
0
-  
0
+
0
   it "should submit the form with the specified button" do
0
     with_html <<-HTML
0
       <html>
0
@@ -115,7 +116,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/form2", {})
0
     click_button "Form2"
0
   end
0
-  
0
+
0
   it "should use action from form" do
0
     with_html <<-HTML
0
       <html>
0
@@ -127,7 +128,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", {})
0
     click_button
0
   end
0
-  
0
+
0
   it "should use method from form" do
0
     with_html <<-HTML
0
       <html>
0
@@ -139,7 +140,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:post)
0
     click_button
0
   end
0
-  
0
+
0
   it "should send button as param if it has a name" do
0
     with_html <<-HTML
0
       <html>
0
@@ -152,7 +153,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:post).with("/login", "login" => "Login")
0
     click_button("Login")
0
   end
0
-  
0
+
0
   it "should not send button as param if it has no name" do
0
     with_html <<-HTML
0
       <html>
0
@@ -177,8 +178,8 @@ describe "click_button" do
0
     HTML
0
     webrat_session.should_receive(:get).with("/login", "user" => {"password" => "mypass"})
0
     click_button
0
-  end  
0
-  
0
+  end
0
+
0
   it "should send default hidden field values" do
0
     with_html <<-HTML
0
       <html>
0
@@ -191,7 +192,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
0
     click_button
0
   end
0
-  
0
+
0
   it "should send default text field values" do
0
     with_html <<-HTML
0
       <html>
0
@@ -204,7 +205,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
0
     click_button
0
   end
0
-  
0
+
0
   it "should not send disabled field values" do
0
     with_html <<-HTML
0
       <html>
0
@@ -221,7 +222,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", {})
0
     click_button
0
   end
0
-  
0
+
0
   it "should send default checked fields" do
0
     with_html <<-HTML
0
       <html>
0
@@ -234,7 +235,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
0
     click_button
0
   end
0
-  
0
+
0
   it "should send default radio options" do
0
     with_html <<-HTML
0
       <html>
0
@@ -250,7 +251,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "F"})
0
     click_button
0
   end
0
-  
0
+
0
   it "should send correct data for rails style unchecked fields" do
0
     with_html <<-HTML
0
       <html>
0
@@ -264,7 +265,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
0
     click_button
0
   end
0
-  
0
+
0
   it "should send correct data for rails style checked fields" do
0
     with_html <<-HTML
0
       <html>
0
@@ -302,7 +303,7 @@ describe "click_button" do
0
       "response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]})
0
     click_button
0
   end
0
-  
0
+
0
   it "should not send default unchecked fields" do
0
     with_html <<-HTML
0
       <html>
0
@@ -315,7 +316,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", {})
0
     click_button
0
   end
0
-  
0
+
0
   it "should send default textarea values" do
0
     with_html <<-HTML
0
       <html>
0
@@ -328,7 +329,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"})
0
     click_button
0
   end
0
-  
0
+
0
   it "should properly handle HTML entities in textarea default values" do
0
     spec = lambda do
0
       with_html <<-HTML
0
@@ -342,14 +343,14 @@ describe "click_button" do
0
       webrat_session.should_receive(:post).with("/posts", "post" => {"body" => "Peanut butter & jelly"})
0
       click_button
0
     end
0
-    
0
+
0
     if Webrat.on_java?
0
       spec.call
0
     else
0
       pending("needs bug fix", &spec)
0
     end
0
   end
0
-  
0
+
0
   it "should send default selected option value from select" do
0
     with_html <<-HTML
0
       <html>
0
@@ -381,7 +382,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", "month" => "February")
0
     click_button
0
   end
0
-  
0
+
0
   it "should send first select option value when no option selected" do
0
     with_html <<-HTML
0
       <html>
0
@@ -397,7 +398,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get).with("/login", "month" => "1")
0
     click_button
0
   end
0
-  
0
+
0
   it "should handle nested properties" do
0
     with_html <<-HTML
0
       <html>
0
@@ -449,7 +450,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get)
0
     click_button
0
   end
0
-  
0
+
0
   it "should find buttons by their IDs" do
0
     with_html <<-HTML
0
       <html>
0
@@ -461,7 +462,7 @@ describe "click_button" do
0
     webrat_session.should_receive(:get)
0
     click_button "my_button"
0
   end
0
-  
0
+
0
   it "should find image buttons by their alt text" do
0
     with_html <<-HTML
0
       <html>
...
10
11
12
13
 
14
15
16
...
30
31
32
33
 
34
35
36
...
40
41
42
43
 
44
45
46
...
50
51
52
53
54
 
 
55
56
57
...
61
62
63
64
 
65
66
67
...
71
72
73
74
 
75
76
77
...
81
82
83
84
85
 
 
86
87
88
...
91
92
93
94
95
 
 
96
97
98
...
101
102
103
104
 
105
106
107
...
122
123
124
125
 
126
127
128
...
143
144
145
146
 
147
148
149
...
159
160
161
162
 
163
164
165
...
175
176
177
178
 
179
180
181
...
196
197
198
199
 
200
201
202
...
213
214
215
216
 
217
218
219
220
221
 
222
223
224
...
228
229
230
231
 
232
233
234
...
236
237
238
 
239
240
241
242
243
 
244
245
246
247
248
249
250
 
251
252
253
254
255
 
256
257
258
...
262
263
264
265
 
266
267
268
...
272
273
274
275
 
276
277
278
...
282
283
284
285
 
286
287
288
...
293
294
295
296
 
297
298
299
...
301
302
303
304
 
305
306
307
308
 
309
310
311
312
313
314
315
 
316
317
318
319
 
320
321
322
...
325
326
327
328
 
329
330
331
332
333
 
334
335
336
...
340
341
342
343
 
344
345
346
...
366
367
368
369
 
370
371
372
...
377
378
379
380
 
381
382
383
...
398
399
400
401
 
402
403
404
405
406
407
408
 
409
410
411
412
413
414
415
 
416
417
418
419
420
421
422
 
423
424
425
...
428
429
430
431
 
432
433
434
435
436
437
438
439
 
 
440
441
442
...
464
465
466
467
 
468
...
10
11
12
 
13
14
15
16
...
30
31
32
 
33
34
35
36
...
40
41
42
 
43
44
45
46
...
50
51
52
 
 
53
54
55
56
57
...
61
62
63
 
64
65
66
67
...
71
72
73
 
74
75
76
77
...
81
82
83
 
 
84
85
86
87
88
...
91
92
93
 
 
94
95
96
97
98
...
101
102
103
 
104
105
106
107
...
122
123
124
 
125
126
127
128
...
143
144
145
 
146
147
148
149
...
159
160
161
 
162
163
164
165
...
175
176
177
 
178
179
180
181
...
196
197
198
 
199
200
201
202
...
213
214
215
 
216
217
218
219
220
 
221
222
223
224
...
228
229
230
 
231
232
233
234
...
236
237
238
239
240
241
242
243
 
244
245
246
247
248
249
250
 
251
252
253
254
255
 
256
257
258
259
...
263
264
265
 
266
267
268
269
...
273
274
275
 
276
277
278
279
...
283
284
285
 
286
287
288
289
...
294
295
296
 
297
298
299
300
...
302
303
304
 
305
306
307
308
 
309
310
311
312
313
314
315
 
316
317
318
319
 
320
321
322
323
...
326
327
328
 
329
330
331
332
333
 
334
335
336
337
...
341
342
343
 
344
345
346
347
...
367
368
369
 
370
371
372
373
...
378
379
380
 
381
382
383
384
...
399
400
401
 
402
403
404
405
406
407
408
 
409
410
411
412
413
414
415
 
416
417
418
419
420
421
422
 
423
424
425
426
...
429
430
431
 
432
433
434
435
436
437
438
 
 
439
440
441
442
443
...
465
466
467
 
468
469
0
@@ -10,7 +10,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link "Save & go back"
0
   end
0
-  
0
+
0
   it "should use get by default" do
0
     with_html <<-HTML
0
       <html>
0
@@ -30,7 +30,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link "Link text", :method => :get
0
   end
0
-  
0
+
0
   it "should click link on substring" do
0
     with_html <<-HTML
0
       <html>
0
@@ -40,7 +40,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link "ink tex", :method => :get
0
   end
0
-  
0
+
0
   it "should click delete links" do
0
     with_html <<-HTML
0
       <html>
0
@@ -50,8 +50,8 @@ describe "click_link" do
0
     webrat_session.should_receive(:delete).with("/page", {})
0
     click_link "Link text", :method => :delete
0
   end
0
-  
0
-  
0
+
0
+
0
   it "should click post links" do
0
     with_html <<-HTML
0
       <html>
0
@@ -61,7 +61,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:post).with("/page", {})
0
     click_link "Link text", :method => :post
0
   end
0
-  
0
+
0
   it "should click put links" do
0
     with_html <<-HTML
0
       <html>
0
@@ -71,7 +71,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:put).with("/page", {})
0
     click_link "Link text", :method => :put
0
   end
0
-  
0
+
0
   it "should click links by regexp" do
0
     with_html <<-HTML
0
       <html>
0
@@ -81,8 +81,8 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link /link [a-z]/i
0
   end
0
-  
0
-  it "should click links by id" do 
0
+
0
+  it "should click links by id" do
0
     with_html <<-HTML
0
       <html>
0
       <a id="link_text_link" href="/page">Link text</a>
0
@@ -91,8 +91,8 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link "link_text_link"
0
   end
0
-  
0
-  it "should click links by id regexp" do 
0
+
0
+  it "should click links by id regexp" do
0
     with_html <<-HTML
0
       <html>
0
       <a id="link_text_link" href="/page">Link text</a>
0
@@ -101,7 +101,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link /_text_/
0
   end
0
-  
0
+
0
   it "should click rails javascript links with authenticity tokens" do
0
     with_html <<-HTML
0
       <html>
0
@@ -122,7 +122,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62")
0
     click_link "Posts"
0
   end
0
-  
0
+
0
   it "should click rails javascript delete links" do
0
     with_html <<-HTML
0
       <html>
0
@@ -143,7 +143,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:delete).with("/posts/1", {})
0
     click_link "Delete"
0
   end
0
-  
0
+
0
   it "should click rails javascript post links" do
0
     with_html <<-HTML
0
       <html>
0
@@ -159,7 +159,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:post).with("/posts", {})
0
     click_link "Posts"
0
   end
0
-  
0
+
0
   it "should click rails javascript post links without javascript" do
0
     with_html <<-HTML
0
       <html>
0
@@ -175,7 +175,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/posts", {})
0
     click_link "Posts", :javascript => false
0
   end
0
-  
0
+
0
   it "should click rails javascript put links" do
0
     with_html <<-HTML
0
       <html>
0
@@ -196,7 +196,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:put).with("/posts", {})
0
     click_link "Put"
0
   end
0
-  
0
+
0
   it "should fail if the javascript link doesn't have a value for the _method input" do
0
     with_html <<-HTML
0
       <html>
0
@@ -213,12 +213,12 @@ describe "click_link" do
0
         return false;">Link</a>
0
       </html>
0
     HTML
0
-    
0
+
0
     lambda {
0
       click_link "Link"
0
     }.should raise_error(Webrat::WebratError)
0
   end
0
-  
0
+
0
   it "should assert valid response" do
0
     with_html <<-HTML
0
       <html>
0
@@ -228,7 +228,7 @@ describe "click_link" do
0
     webrat_session.response_code = 501
0
     lambda { click_link "Link text" }.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
       with_html <<-HTML
0
@@ -236,23 +236,24 @@ describe "click_link" do
0
         <a href="/page">Link text</a>
0
         </html>
0
       HTML
0
+      webrat_session.stub!(:redirect? => false)
0
       webrat_session.response_code = status
0
       lambda { click_link "Link text" }.should_not raise_error
0
     end
0
   end
0
-  
0
+
0
   it "should fail is the link doesn't exist" do
0
     with_html <<-HTML
0
       <html>
0
       <a href="/page">Link text</a>
0
       </html>
0
     HTML
0
-    
0
+
0
     lambda {
0
       click_link "Missing link"
0
     }.should raise_error(Webrat::NotFoundError)
0
   end
0
-  
0
+
0
   it "should not be case sensitive" do
0
     with_html <<-HTML
0
       <html>
0
@@ -262,7 +263,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link "LINK TEXT"
0
   end
0
-  
0
+
0
   it "should match link substrings" do
0
     with_html <<-HTML
0
       <html>
0
@@ -272,7 +273,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link "Link text"
0
   end
0
-  
0
+
0
   it "should work with elements in the link" do
0
     with_html <<-HTML
0
       <html>
0
@@ -282,7 +283,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page", {})
0
     click_link "Link text"
0
   end
0
-  
0
+
0
   it "should match the first matching link" do
0
     with_html <<-HTML
0
       <html>
0
@@ -293,7 +294,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page1", {})
0
     click_link "Link text"
0
   end
0
-  
0
+
0
   it "should choose the shortest link text match" do
0
     with_html <<-HTML
0
       <html>
0
@@ -301,22 +302,22 @@ describe "click_link" do
0
         <a href="/page2">Link</a>
0
       </html>
0
     HTML
0
-    
0
+
0
     webrat_session.should_receive(:get).with("/page2", {})
0
     click_link "Link"
0
   end
0
-  
0
+
0
   it "should treat non-breaking spaces as spaces" do
0
     with_html <<-HTML
0
       <html>
0
         <a href="/page1">This&nbsp;is&nbsp;a&nbsp;link</a>
0
       </html>
0
     HTML
0
-    
0
+
0
     webrat_session.should_receive(:get).with("/page1", {})
0
     click_link "This is a link"
0
   end
0
-  
0
+
0
   it "should not match on non-text contents" do
0
     pending "needs fix" do
0
       with_html <<-HTML
0
@@ -325,12 +326,12 @@ describe "click_link" do
0
         <a href="/page2">Location</a>
0
         </html>
0
       HTML
0
-    
0
+
0
       webrat_session.should_receive(:get).with("/page2", {})
0
       click_link "Location"
0
     end
0
   end
0
-  
0
+
0
   it "should click link within a selector" do
0
     with_html <<-HTML
0
     <html>
0
@@ -340,7 +341,7 @@ describe "click_link" do
0
       </div>
0
     </html>
0
     HTML
0
-    
0
+
0
     webrat_session.should_receive(:get).with("/page2", {})
0
     click_link_within "#container", "Link"
0
   end
0
@@ -366,7 +367,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page/sub", {})
0
     click_link "Jump to sub page"
0
   end
0
-  
0
+
0
   it "should follow fully qualified local links" do
0
     webrat_session.stub!(:current_url => "/page")
0
     with_html <<-HTML
0
@@ -377,7 +378,7 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("http://subdomain.example.com/page/sub", {})
0
     click_link "Jump to sub page"
0
   end
0
-  
0
+
0
   it "should follow fully qualified local links to example.com" do
0
     with_html <<-HTML
0
       <html>
0
@@ -398,28 +399,28 @@ describe "click_link" do
0
     webrat_session.should_receive(:get).with("/page?foo=bar", {})
0
     click_link "Jump to foo bar"
0
   end
0
-  
0
+
0
   it "should matches_text? on regexp" do
0
     pending "need to update these"
0
     link = Webrat::Link.new(webrat_session, nil)
0
     link.should_receive(:text).and_return(@link_text_with_nbsp)
0
     link.matches_text?(/link/i).should == 0
0
   end
0
-  
0
+
0
   it "should matches_text? on link_text" do
0
     pending "need to update these"
0
     link = Webrat::Link.new(webrat_session, nil)
0
     link.should_receive(:text).and_return(@link_text_with_nbsp)
0
     link.matches_text?("Link Text").should == 0
0
   end
0
-  
0
+
0
   it "should matches_text? on substring" do
0
     pending "need to update these"
0
     link = Webrat::Link.new(webrat_session, nil)
0
     link.should_receive(:text).and_return(@link_text_with_nbsp)
0
     link.matches_text?("nk Te").should_not be_nil
0
   end
0
-  
0
+
0
   it "should not matches_text? on link_text case insensitive" do
0
     pending "need to update these"
0
     link = Webrat::Link.new(webrat_session, nil)
0
@@ -428,15 +429,15 @@ describe "click_link" do
0
     link.should_receive(:title).and_return(nil)
0
     link.matches_text?("link_text").should == false
0
   end
0
-  
0
+
0
   it "should match text not include &nbsp;" do
0
     pending "need to update these"
0
     link = Webrat::Link.new(webrat_session, nil)
0
     link.should_receive(:text).and_return('LinkText')
0
     link.matches_text?("LinkText").should == 0
0
   end
0
-  
0
-  it "should not matches_text? on wrong text" do 
0
+
0
+  it "should not matches_text? on wrong text" do
0
     pending "need to update these"
0
     link = Webrat::Link.new(webrat_session, nil)
0
     nbsp = [0xA0].pack("U")
0
@@ -464,5 +465,5 @@ describe "click_link" do
0
     link.should_receive(:inner_html).and_return('<img src="logo.png" />')
0
     link.matches_text?('logo.png').should == 10
0
   end
0
-  
0
+
0
 end
...
21
22
23
 
24
25
26
...
31
32
33
34
 
35
36
37
...
21
22
23
24
25
26
27
...
32
33
34
 
35
36
37
38
0
@@ -21,6 +21,7 @@ describe "visit" do
0
 
0
   [200, 300, 400, 499].each do |status|
0
     it "should consider the #{status} status code as success" do
0
+      webrat_session.stub!(:redirect? => false)
0
       webrat_session.response_code = status
0
       lambda { visit("/") }.should_not raise_error
0
     end
0
@@ -31,7 +32,7 @@ describe "visit" do
0
   end
0
 
0
   it "should follow redirects" do
0
-    webrat_session.response.should_receive(:redirect?).twice.and_return(true, false)
0
+    webrat_session.should_receive(:redirect?).twice.and_return(true, false)
0
     webrat_session.response.should_receive(:location).once.and_return("/newurl")
0
 
0
     visit("/oldurl")

Comments