Browse files

Issue #134: Add deprecation warning for should_not_receive followed b…

…y and_return.
  • Loading branch information...
1 parent f04d527 commit 15c84d70d8d94439b700cd6f5880212696e1df22 Neha Kumari committed Jun 8, 2012
Showing with 7 additions and 0 deletions.
  1. +2 −0 lib/rspec/mocks/message_expectation.rb
  2. +5 −0 spec/rspec/mocks/mock_ordering_spec.rb
View
2 lib/rspec/mocks/message_expectation.rb
@@ -477,6 +477,8 @@ def initialize(error_generator, expectation_ordering, expected_from, message, &i
def and_return(*)
# no-op
+ # @deprecated Please do not use and_return with negative message expectations.
+ warn "[DEPRECATION] `and_return` with `should_not_receive` is deprecated."
end
# @private
View
5 spec/rspec/mocks/mock_ordering_spec.rb
@@ -98,6 +98,11 @@ module Mocks
@double.b
@double.a
end
+
+ it "warns when should_not_receive is followed by and_return" do
+ @double.should_receive(:warn).with("[DEPRECATION] `and_return` with `should_not_receive` is deprecated.")
+ @double.should_not_receive(:do_something).and_return(1)
+ end
end
end
end

0 comments on commit 15c84d7

Please sign in to comment.