public
Rubygem
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
changed redirect logic.  Now accepts a symbol, which will test for that 
status code instead.

git-svn-id: https://svn.thoughtbot.com/plugins/shoulda/trunk@201 
7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
tsaleh (author)
Fri Aug 31 07:26:29 -0700 2007
commit  725e7f61b11b451dc61e495c4d12934b93be0fe0
tree    247ce26afd3b2c5aa77e3cf2cab9a7fe20cb2d03
parent  a964a514e6fffb5c0a4fecb731d85ccd98944576
...
371
372
373
374
375
376
377
378
 
 
 
379
380
381
...
371
372
373
 
 
 
 
 
374
375
376
377
378
379
0
@@ -371,11 +371,9 @@ module ThoughtBot # :nodoc:
0
         #
0
         # should_redirect_to "/"
0
         def should_redirect_to(url)
0
- if url
0
- should "redirect to \"#{url}\"" do
0
- instantiate_variables_from_assigns do
0
- assert_redirected_to eval(url, self.send(:binding), __FILE__, __LINE__)
0
- end
0
+ should "redirect to \"#{url}\"" do
0
+ instantiate_variables_from_assigns do
0
+ assert_redirected_to eval(url, self.send(:binding), __FILE__, __LINE__)
0
             end
0
           end
0
         end
...
113
114
115
116
 
 
 
 
 
117
118
119
...
141
142
143
144
 
 
 
 
 
145
146
147
...
164
165
166
167
 
 
 
 
 
 
 
168
169
170
171
172
173
174
175
176
...
113
114
115
 
116
117
118
119
120
121
122
123
...
145
146
147
 
148
149
150
151
152
153
154
155
...
172
173
174
 
175
176
177
178
179
180
181
182
183
184
 
 
 
185
186
187
0
@@ -113,7 +113,11 @@ module ThoughtBot # :nodoc:
0
                 end
0
               else
0
                 should_set_the_flash_to res.destroy.flash
0
- should_redirect_to res.destroy.redirect
0
+ if res.destroy.redirect.is_a? Symbol
0
+ should_respond_with res.destroy.redirect
0
+ else
0
+ should_redirect_to res.destroy.redirect
0
+ end
0
 
0
                 should "destroy record" do
0
                   assert_raises(::ActiveRecord::RecordNotFound) { @record.reload }
0
@@ -141,7 +145,11 @@ module ThoughtBot # :nodoc:
0
               else
0
                 should_assign_to res.object
0
                 should_set_the_flash_to res.create.flash
0
- should_redirect_to res.create.redirect
0
+ if res.create.redirect.is_a? Symbol
0
+ should_respond_with res.create.redirect
0
+ else
0
+ should_redirect_to res.create.redirect
0
+ end
0
 
0
                 should "not have errors on @#{res.object}" do
0
                   assert_equal [], assigns(res.object).errors.full_messages, "@#{res.object} has errors:"
0
@@ -164,13 +172,16 @@ module ThoughtBot # :nodoc:
0
                 should_set_the_flash_to res.denied.flash
0
               else
0
                 should_assign_to res.object
0
-
0
+ should_set_the_flash_to(res.update.flash)
0
+ if res.update.redirect.is_a? Symbol
0
+ should_respond_with res.update.redirect
0
+ else
0
+ should_redirect_to res.update.redirect
0
+ end
0
+
0
                 should "not have errors on @#{res.object}" do
0
                   assert_equal [], assigns(res.object).errors.full_messages, "@#{res.object} has errors:"
0
                 end
0
-
0
- should_redirect_to res.update.redirect
0
- should_set_the_flash_to(res.update.flash)
0
               end
0
             end
0
           end

Comments

    No one has commented yet.