Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit c442f14

Browse files
committed
Merge pull request #989 from rspec/remove_extra_deprecation_code_master
Remove old deprecation API.
2 parents b315f1a + 9396aa1 commit c442f14

File tree

2 files changed

+11
-33
lines changed

2 files changed

+11
-33
lines changed

lib/rspec/core/deprecation.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ module Deprecation
44
# @private
55
#
66
# Used internally to print deprecation warnings
7-
def deprecate(deprecated, replacement_or_hash={}, ignore_version=nil)
8-
# Temporarily support old and new APIs while we transition the other
9-
# rspec libs to use a hash for the 2nd arg and no version arg
10-
data = Hash === replacement_or_hash ? replacement_or_hash : { :replacement => replacement_or_hash }
7+
def deprecate(deprecated, data = {})
118
call_site = caller.find { |line| line !~ %r{/lib/rspec/(core|mocks|expectations|matchers|rails)/} }
129

1310
RSpec.configuration.reporter.deprecation(

spec/rspec/core/deprecation_spec.rb

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,19 @@
22

33
describe RSpec::Core::Deprecation do
44
describe "#deprecate" do
5-
context "old API with individual args" do
6-
it "includes the method to deprecate" do
7-
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :deprecated => "deprecated_method")
8-
RSpec.deprecate("deprecated_method")
9-
end
10-
11-
it "includes the replacement when provided" do
12-
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :deprecated => "deprecated_method", :replacement => "replacement")
13-
RSpec.deprecate("deprecated_method", "replacement")
14-
end
15-
16-
it "adds the call site" do
17-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
18-
RSpec.deprecate("deprecated_method")
19-
end
20-
21-
it "doesn't override the existing callsite" do
22-
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :call_site => "/path")
23-
RSpec.deprecate("deprecated_method", :call_site => "/path")
24-
end
5+
it "passes the hash to the reporter" do
6+
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :deprecated => "deprecated_method", :replacement => "replacement")
7+
RSpec.deprecate("deprecated_method", :replacement => "replacement")
258
end
269

27-
context "new API with a hash after the first arg" do
28-
it "passes the hash to the reporter" do
29-
expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :deprecated => "deprecated_method", :replacement => "replacement")
30-
RSpec.deprecate("deprecated_method", :replacement => "replacement")
31-
end
10+
it "adds the call site" do
11+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
12+
RSpec.deprecate("deprecated_method")
13+
end
3214

33-
it "adds the call site" do
34-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
35-
RSpec.deprecate("deprecated_method")
36-
end
15+
it "doesn't override a passed call site" do
16+
expect_deprecation_with_call_site("some_file.rb", 17)
17+
RSpec.deprecate("deprecated_method", :call_site => "/some_file.rb:17")
3718
end
3819
end
3920

0 commit comments

Comments
 (0)