Permalink
Browse files

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

…y and_return.
  • Loading branch information...
Neha Kumari
Neha Kumari committed Jun 8, 2012
1 parent 9d8e81d commit a1bc823fe4e1dc6ae0abdb4e5a9d08f17a563d0e
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
@@ -494,6 +494,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
@@ -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 a1bc823

Please sign in to comment.