public
Description: Behaviour Driven Development framework for Ruby
Homepage: http://rspec.info
Clone URL: git://github.com/dchelimsky/rspec.git
Click here to lend your support to: rspec and make a donation at www.pledgie.com !
added as_null_object
dchelimsky (author)
Sun Aug 10 05:52:04 -0700 2008
commit  949205a2cefa7b3c6a8c188690f372c2a8320ab3
tree    2d93534114a0978fa2511ccaa923af5c793a8cf1
parent  54e0b01174da205571704c0030e9611aef9db02b
...
28
29
30
 
 
 
 
 
 
 
 
31
32
33
...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -28,6 +28,14 @@ module Spec
0
       def rspec_reset #:nodoc:
0
         __mock_proxy.reset
0
       end
0
+      
0
+      def as_null_object
0
+        __mock_proxy.act_as_null_object
0
+      end
0
+      
0
+      def null_object?
0
+        __mock_proxy.null_object?
0
+      end
0
 
0
     private
0
 
...
20
21
22
 
 
 
 
 
23
24
25
...
20
21
22
23
24
25
26
27
28
29
30
0
@@ -20,6 +20,11 @@ module Spec
0
       def null_object?
0
         @options[:null_object]
0
       end
0
+      
0
+      def act_as_null_object
0
+        @options[:null_object] = true
0
+        @target
0
+      end
0
 
0
       def add_message_expectation(expected_from, sym, opts={}, &block)
0
         __add sym
...
36
37
38
 
 
 
 
 
 
 
 
39
40
...
36
37
38
39
40
41
42
43
44
45
46
47
48
0
@@ -36,5 +36,13 @@ module Spec
0
         @mock.message(:unexpected_arg)
0
       end
0
     end
0
+    
0
+    describe "as_null_object" do
0
+      it "should set the object to null_object" do
0
+        obj = mock('anything').as_null_object
0
+        
0
+        obj.should be_null_object
0
+      end
0
+    end
0
   end
0
 end

Comments