Permalink
Browse files

Don't assume presence of rspec-core's `warn_deprecation` method.

rspec-mocks should be usable outside of rspec-core.
  • Loading branch information...
1 parent 16d30dc commit 363406a4b947bf646b725ec9b68fed4627093ca2 @myronmarston myronmarston committed Dec 26, 2012
Showing with 10 additions and 2 deletions.
  1. +8 −0 lib/rspec/mocks.rb
  2. +1 −1 lib/rspec/mocks/message_expectation.rb
  3. +1 −1 spec/rspec/mocks/mock_spec.rb
View
@@ -27,6 +27,14 @@ def configuration
@configuration ||= Configuration.new
end
+ # @api private
+ # Used internally by RSpec to display custom deprecation warnings. This
+ # is also defined in rspec-core, but we can't assume it's loaded since
+ # rspec-expectations should be usable w/o rspec-core.
+ def warn_deprecation(message)
+ warn(message)
+ end
+
private
def add_extensions
@@ -488,7 +488,7 @@ def initialize(error_generator, expectation_ordering, expected_from, method_doub
def and_return(*)
# no-op
# @deprecated and_return is not supported with negative message expectations.
- RSpec.warn_deprecation <<-MSG
+ RSpec::Mocks.warn_deprecation <<-MSG
DEPRECATION: `and_return` with `should_not_receive` is deprecated. Called from #{caller(0)[1]}
MSG
@@ -43,7 +43,7 @@ module Mocks
end
it "warns when should_not_receive is followed by and_return" do
- RSpec.should_receive(:warn_deprecation).
+ RSpec::Mocks.should_receive(:warn_deprecation).
with(/`and_return` with `should_not_receive` is deprecated/)
@double.should_not_receive(:do_something).and_return(1)

0 comments on commit 363406a

Please sign in to comment.