public
Description: Custom controller spec macros, with an included 'custom_scaffold' generator.
Clone URL: git://github.com/technoweenie/rspec_on_rails_on_crack.git
Changed default behavior for it_assigns if no instance variable exists, 
just checks if not_nil
iownbey (author)
Wed Mar 26 19:13:22 -0700 2008
commit  06bca8bc54d632d2cc7ea260ec956378a4af4594
tree    4922f86acf79509d82e764a2b2ff4e84a25f7eda
parent  bd40587a93c36e084f969923d1da89e9d6089447
...
155
156
157
 
 
 
 
158
159
160
...
285
286
287
288
 
 
 
 
 
289
290
291
...
155
156
157
158
159
160
161
162
163
164
...
289
290
291
 
292
293
294
295
296
297
298
299
0
@@ -155,6 +155,10 @@ module RspecOnRailsOnCrack
0
     #
0
     # it_assigns :foo # => assigns[:foo].should == @foo
0
     #
0
+ # If there is no instance variable @foo, it will just check to see if its not nil:
0
+ #
0
+ # if_assigns :foo # => assigns[:foo].should_not be_nil (if @foo is not defined in spec)
0
+ #
0
     # Check multiple instance variables
0
     #
0
     # it_assigns :foo, :bar
0
@@ -285,7 +289,11 @@ module RspecOnRailsOnCrack
0
           when :undefined
0
             controller.send(:instance_variables).should_not include("@#{name}")
0
           when Symbol
0
- assigns[name].should == instance_variable_get("@#{value}")
0
+ if (instance_variable = instance_variable_get("@#{value}")).nil?
0
+ assigns[name].should_not be_nil
0
+ else
0
+ assigns[name].should == instance_variable
0
+ end
0
           end
0
       end
0
     end

Comments

    No one has commented yet.