Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

output deprecation warning on #any_number_of_times #237

Merged
merged 1 commit into from

3 participants

@michihuber

closes #131
should be merged/not merged together with #231

@JonRowe
Owner

:+1: Looks good to me :)

@samphippen samphippen merged commit 99c61e0 into rspec:master

1 check passed

Details default The Travis build passed
@samphippen samphippen referenced this pull request from a commit
@samphippen samphippen Add a changelog entry for #231 and #237
Signed-off-by: Sam Phippen <samphippen@googlemail.com>
2efca50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  lib/rspec/mocks/message_expectation.rb
@@ -334,6 +334,9 @@ def times(&block)
# Allows an expected message to be received any number of times.
def any_number_of_times(&block)
+ RSpec::Mocks.warn_deprecation <<-MSG
+DEPRECATION: `#any_number_of_times` is deprecated, use `#stub` instead. Called from #{caller(0)[1]}
+MSG
@implementation = block if block
@expected_received_count = :any
self
View
6 spec/rspec/mocks/any_number_of_times_spec.rb
@@ -3,6 +3,12 @@
describe "AnyNumberOfTimes" do
before(:each) do
@mock = RSpec::Mocks::Mock.new("test mock")
+ RSpec::Mocks.stub(:warn_deprecation)
+ end
+
+ it "outputs a deprecation warning" do
+ RSpec::Mocks.should_receive(:warn_deprecation).with(/DEPRECATION: `#any_number_of_times` is deprecated/)
+ @mock.should_receive(:random_call).any_number_of_times
end
it "passes if any number of times method is called many times" do
Something went wrong with that request. Please try again.