public
Fork of dchelimsky/rspec-tmbundle
Description: Textmate bundle for RSpec.
Clone URL: git://github.com/timcharper/rspec-tmbundle.git
Better messages for mocks receiving correct message with wrong args when 
using :null_object => true. Further fixes 
http://rspec.lighthouseapp.com/projects/5645/tickets/352.
dchelimsky (author)
Mon Mar 31 06:22:29 -0700 2008
commit  cd2176712f8575d1e69f29a9a315f707074f7cd5
tree    1eefb8aa818a0d1efc00a9d613437d241acd92ca
parent  e81efef7089d5f1d65c49cc80395e394703e2e75
...
63
64
65
66
 
67
68
69
70
71
72
73
74
75
 
76
 
77
78
 
 
79
80
81
...
63
64
65
 
66
67
 
 
 
 
 
 
 
 
68
69
70
71
 
72
73
74
75
76
0
@@ -63,19 +63,14 @@ module Spec
0
       def message_received(sym, *args, &block)
0
         if expectation = find_matching_expectation(sym, *args)
0
           expectation.invoke(args, block)
0
- elsif stub = find_matching_method_stub(sym, *args)
0
+ elsif (stub = find_matching_method_stub(sym, *args))
0
           if expectation = find_almost_matching_expectation(sym, *args)
0
- if expectation.expected_messages_received?
0
- stub.invoke([], block)
0
- else
0
- expectation.advise(args, block)
0
- stub.invoke([], block)
0
- end
0
- else
0
- stub.invoke([], block)
0
+ expectation.advise(args, block) unless expectation.expected_messages_received?
0
           end
0
+ stub.invoke([], block)
0
         elsif expectation = find_almost_matching_expectation(sym, *args)
0
- raise_unexpected_message_args_error(expectation, *args) unless has_negative_expectation?(sym) unless null_object?
0
+ expectation.advise(args, block) if null_object? unless expectation.expected_messages_received?
0
+ raise_unexpected_message_args_error(expectation, *args) unless (has_negative_expectation?(sym) or null_object?)
0
         else
0
           @target.send :method_missing, sym, *args, &block
0
         end
...
92
93
94
 
 
 
 
 
 
 
 
 
95
96
97
...
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
0
@@ -92,6 +92,15 @@ module Spec
0
         }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
0
       end
0
            
0
+ it "should raise exception if args don't match when method called even when using null_object" do
0
+ @mock = mock("test mock", :null_object => true)
0
+ @mock.should_receive(:something).with("a","b","c")
0
+ lambda {
0
+ @mock.something("a","d","c")
0
+ @mock.rspec_verify
0
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
0
+ end
0
+
0
       it "should fail if unexpected method called" do
0
         lambda {
0
           @mock.something("a","b","c")

Comments

    No one has commented yet.