Permalink
Browse files

Merge pull request #151 from c42engineering/issue_134

Issue #134: Add deprecation warning for should_not_receive followed by and_return
  • Loading branch information...
2 parents 05741e9 + 15c84d7 commit 5b36ea4819285cbb980c69cb77a3e31e4c34a941 @dchelimsky dchelimsky committed Aug 20, 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 5b36ea4

Please sign in to comment.