deprecation_toolkit 1.5.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +67 -13
- data/lib/deprecation_toolkit/behaviors/ci_record_helper.rb +5 -4
- data/lib/deprecation_toolkit/behaviors/disabled.rb +4 -2
- data/lib/deprecation_toolkit/behaviors/raise.rb +10 -4
- data/lib/deprecation_toolkit/behaviors/record.rb +3 -2
- data/lib/deprecation_toolkit/collector.rb +14 -6
- data/lib/deprecation_toolkit/configuration.rb +9 -0
- data/lib/deprecation_toolkit/deprecation_subscriber.rb +57 -6
- data/lib/deprecation_toolkit/read_write_helper.rb +3 -7
- data/lib/deprecation_toolkit/rspec_plugin.rb +12 -6
- data/lib/deprecation_toolkit/test_triggerer.rb +3 -1
- data/lib/deprecation_toolkit/version.rb +1 -1
- data/lib/deprecation_toolkit/warning.rb +21 -35
- data/lib/deprecation_toolkit.rb +30 -15
- data/lib/minitest/deprecation_toolkit_plugin.rb +7 -2
- data/lib/tasks/ci_recorder.rake +10 -9
- metadata +8 -90
- data/.gitignore +0 -10
- data/.rspec +0 -4
- data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1017
- data/.rubocop.yml +0 -12
- data/.travis.yml +0 -18
- data/CHANGELOG.md +0 -42
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -69
- data/Rakefile +0 -13
- data/deprecation_toolkit.gemspec +0 -36
- data/gemfiles/activesupport_5.2.gemfile +0 -11
- data/gemfiles/activesupport_6.0.gemfile +0 -11
- data/gemfiles/spec/deprecations/deprecation_toolkit/behaviors/raise.yml +0 -12
- data/gemfiles/test/deprecations +0 -1
- data/shipit.rubygems.yml +0 -1
- data/spec/deprecation_toolkit/behaviors/disabled_spec.rb +0 -23
- data/spec/deprecation_toolkit/behaviors/raise_spec.rb +0 -96
- data/spec/deprecation_toolkit/behaviors/record_spec.rb +0 -71
- data/spec/deprecations/deprecation_toolkit/behaviors/raise.yml +0 -12
- data/spec/rspec/plugin_env_options_spec.rb +0 -13
- data/spec/rspec/plugin_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -19
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
cache: bundler
|
|
3
|
-
language: ruby
|
|
4
|
-
before_install:
|
|
5
|
-
- gem update bundler
|
|
6
|
-
rvm:
|
|
7
|
-
- 2.5
|
|
8
|
-
- 2.6
|
|
9
|
-
- 2.7
|
|
10
|
-
gemfile:
|
|
11
|
-
- gemfiles/activesupport_5.2.gemfile
|
|
12
|
-
- gemfiles/activesupport_6.0.gemfile
|
|
13
|
-
script:
|
|
14
|
-
- bundle exec rubocop --config .rubocop.yml
|
|
15
|
-
- bundle exec rake test
|
|
16
|
-
- bundle exec rspec
|
|
17
|
-
notifications:
|
|
18
|
-
email: false
|
data/CHANGELOG.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Change log
|
|
2
|
-
|
|
3
|
-
## master (unreleased)
|
|
4
|
-
|
|
5
|
-
## 1.4.0 (2019-04-29)
|
|
6
|
-
* [#37](https://github.com/Shopify/deprecation_toolkit/pull/37): Add Rspec support. (@andrewmarkle)
|
|
7
|
-
|
|
8
|
-
## 1.3.0 (2019-02-28)
|
|
9
|
-
* [#38](https://github.com/Shopify/deprecation_toolkit/pull/38): Add a way to mark test as flaky. (@Edouard-chin)
|
|
10
|
-
* [#39](https://github.com/Shopify/deprecation_toolkit/pull/39): Introduced a way to help recording massive amount of deprecations. (@Edouard-chin)
|
|
11
|
-
|
|
12
|
-
## 1.2.1 (2019-01-09)
|
|
13
|
-
|
|
14
|
-
### Bug fixes
|
|
15
|
-
* [#34](https://github.com/Shopify/deprecation_toolkit/pull/34): Fixes SystemStackError with RubyGems v3 and Ruby 2.5+. (@dylanahsmith)
|
|
16
|
-
|
|
17
|
-
## 1.2.0 (2018-11-28)
|
|
18
|
-
|
|
19
|
-
### New features
|
|
20
|
-
|
|
21
|
-
* [#30](https://github.com/Shopify/deprecation_toolkit/pull/30): Introduce a `DeprecationMismatch` error class. (@Edouard-chin)
|
|
22
|
-
### Bug fixes
|
|
23
|
-
* [#29](https://github.com/Shopify/deprecation_toolkit/pull/29): Fix issue where the error class triggered was incorrect in some circumstances. (@Edouard-chin)
|
|
24
|
-
|
|
25
|
-
## 1.1.0 (2018-11-13)
|
|
26
|
-
|
|
27
|
-
### New features
|
|
28
|
-
|
|
29
|
-
* [#28](https://github.com/Shopify/deprecation_toolkit/pull/28): `Configuration.allowed_deprecations` now accepts Procs.
|
|
30
|
-
This is useful if you need to whitelist deprecations based on the caller.
|
|
31
|
-
|
|
32
|
-
## 1.0.3 (2018-10-25)
|
|
33
|
-
|
|
34
|
-
### Bug fixes
|
|
35
|
-
|
|
36
|
-
* [#22](https://github.com/Shopify/deprecation_toolkit/pull/22): Fixes `Kernel.warn` not triggering deprecation. (@rmacklin)
|
|
37
|
-
|
|
38
|
-
## 1.0.2 (2018-10-01)
|
|
39
|
-
|
|
40
|
-
### New features
|
|
41
|
-
|
|
42
|
-
* [#15](https://github.com/Shopify/deprecation_toolkit/pull/15): Add support for ActiveSupport 4.2. (@andrewmarkle)
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
deprecation_toolkit (1.5.1)
|
|
5
|
-
activesupport (>= 4.2)
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: https://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activesupport (6.0.2.2)
|
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
12
|
-
i18n (>= 0.7, < 2)
|
|
13
|
-
minitest (~> 5.1)
|
|
14
|
-
tzinfo (~> 1.1)
|
|
15
|
-
zeitwerk (~> 2.2)
|
|
16
|
-
ast (2.4.0)
|
|
17
|
-
concurrent-ruby (1.1.6)
|
|
18
|
-
diff-lcs (1.3)
|
|
19
|
-
i18n (1.8.2)
|
|
20
|
-
concurrent-ruby (~> 1.0)
|
|
21
|
-
jaro_winkler (1.5.4)
|
|
22
|
-
minitest (5.11.3)
|
|
23
|
-
parallel (1.19.1)
|
|
24
|
-
parser (2.7.1.1)
|
|
25
|
-
ast (~> 2.4.0)
|
|
26
|
-
rainbow (3.0.0)
|
|
27
|
-
rake (12.3.2)
|
|
28
|
-
rexml (3.2.4)
|
|
29
|
-
rspec (3.8.0)
|
|
30
|
-
rspec-core (~> 3.8.0)
|
|
31
|
-
rspec-expectations (~> 3.8.0)
|
|
32
|
-
rspec-mocks (~> 3.8.0)
|
|
33
|
-
rspec-core (3.8.0)
|
|
34
|
-
rspec-support (~> 3.8.0)
|
|
35
|
-
rspec-expectations (3.8.2)
|
|
36
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
-
rspec-support (~> 3.8.0)
|
|
38
|
-
rspec-mocks (3.8.0)
|
|
39
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
-
rspec-support (~> 3.8.0)
|
|
41
|
-
rspec-support (3.8.0)
|
|
42
|
-
rubocop (0.82.0)
|
|
43
|
-
jaro_winkler (~> 1.5.1)
|
|
44
|
-
parallel (~> 1.10)
|
|
45
|
-
parser (>= 2.7.0.1)
|
|
46
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
47
|
-
rexml
|
|
48
|
-
ruby-progressbar (~> 1.7)
|
|
49
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
|
50
|
-
ruby-progressbar (1.10.1)
|
|
51
|
-
thread_safe (0.3.6)
|
|
52
|
-
tzinfo (1.2.7)
|
|
53
|
-
thread_safe (~> 0.1)
|
|
54
|
-
unicode-display_width (1.7.0)
|
|
55
|
-
zeitwerk (2.3.0)
|
|
56
|
-
|
|
57
|
-
PLATFORMS
|
|
58
|
-
ruby
|
|
59
|
-
|
|
60
|
-
DEPENDENCIES
|
|
61
|
-
bundler (>= 1.16)
|
|
62
|
-
deprecation_toolkit!
|
|
63
|
-
minitest (~> 5.0)
|
|
64
|
-
rake
|
|
65
|
-
rspec (~> 3.0)
|
|
66
|
-
rubocop
|
|
67
|
-
|
|
68
|
-
BUNDLED WITH
|
|
69
|
-
1.17.3
|
data/Rakefile
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "bundler/gem_tasks"
|
|
4
|
-
require "rake/testtask"
|
|
5
|
-
|
|
6
|
-
Rake::TestTask.new(:test) do |t|
|
|
7
|
-
t.libs << "test"
|
|
8
|
-
t.libs << "lib"
|
|
9
|
-
t.warning = true
|
|
10
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
task(default: :test)
|
data/deprecation_toolkit.gemspec
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
lib = File.expand_path("lib", __dir__)
|
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
-
require "deprecation_toolkit/version"
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name = "deprecation_toolkit"
|
|
9
|
-
spec.version = DeprecationToolkit::VERSION
|
|
10
|
-
spec.authors = %w(Shopify)
|
|
11
|
-
spec.email = ["rails@shopify.com"]
|
|
12
|
-
|
|
13
|
-
spec.summary = "Deprecation Toolkit around ActiveSupport::Deprecation"
|
|
14
|
-
spec.homepage = "https://github.com/shopify/deprecation_toolkit"
|
|
15
|
-
spec.license = "MIT"
|
|
16
|
-
|
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/shopify/deprecation_toolkit"
|
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/Shopify/deprecation_toolkit/blob/master/CHANGELOG.md"
|
|
20
|
-
|
|
21
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
22
|
-
|
|
23
|
-
spec.required_ruby_version = '>= 2.5'
|
|
24
|
-
|
|
25
|
-
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
|
|
26
|
-
f.match(%r{^(test)/})
|
|
27
|
-
end
|
|
28
|
-
spec.require_paths = %w(lib)
|
|
29
|
-
|
|
30
|
-
spec.add_runtime_dependency('activesupport', '>= 4.2')
|
|
31
|
-
|
|
32
|
-
spec.add_development_dependency("bundler", ">= 1.16")
|
|
33
|
-
spec.add_development_dependency("rake", "~> 10.0")
|
|
34
|
-
spec.add_development_dependency("minitest", "~> 5.0")
|
|
35
|
-
spec.add_development_dependency("rspec", "~> 3.0")
|
|
36
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_raises_a_deprecation_removed_error_when_deprecations_are_removed:
|
|
3
|
-
- 'DEPRECATION WARNING: Foo'
|
|
4
|
-
- 'DEPRECATION WARNING: Bar'
|
|
5
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_raises_a_deprecation_removed_when_mismatched_and_less_than_expected:
|
|
6
|
-
- 'DEPRECATION WARNING: A'
|
|
7
|
-
- 'DEPRECATION WARNING: B'
|
|
8
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_raises_a_deprecation_mismatch_when_same_number_of_deprecations_are_triggered_with_mismatches:
|
|
9
|
-
- 'DEPRECATION WARNING: C'
|
|
10
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_does_not_raise_when_deprecations_are_triggered_but_were_already_recorded:
|
|
11
|
-
- 'DEPRECATION WARNING: Foo'
|
|
12
|
-
- 'DEPRECATION WARNING: Bar'
|
data/gemfiles/test/deprecations
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../../test/deprecations
|
data/shipit.rubygems.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# using the default shipit config
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
|
|
6
|
-
before do
|
|
7
|
-
@previous_configuration = DeprecationToolkit::Configuration.behavior
|
|
8
|
-
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Disabled
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after do
|
|
12
|
-
DeprecationToolkit::Configuration.behavior = @previous_configuration
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it '.trigger noop any deprecations' do |example|
|
|
16
|
-
expect do
|
|
17
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
18
|
-
ActiveSupport::Deprecation.warn("Bar")
|
|
19
|
-
|
|
20
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
21
|
-
end.not_to(raise_error)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
|
|
6
|
-
before do
|
|
7
|
-
@previous_configuration = DeprecationToolkit::Configuration.behavior
|
|
8
|
-
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Raise
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after do
|
|
12
|
-
DeprecationToolkit::Configuration.behavior = @previous_configuration
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it ".trigger raises an DeprecationIntroduced error when deprecations are introduced" do |example|
|
|
16
|
-
expect do
|
|
17
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
18
|
-
ActiveSupport::Deprecation.warn("Bar")
|
|
19
|
-
|
|
20
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
21
|
-
end.to(raise_error(DeprecationToolkit::Behaviors::DeprecationIntroduced))
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it ".trigger raises a DeprecationRemoved error when deprecations are removed" do |example|
|
|
25
|
-
expect do
|
|
26
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
27
|
-
|
|
28
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
29
|
-
end.to(raise_error(DeprecationToolkit::Behaviors::DeprecationRemoved))
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it '.trigger raises a DeprecationRemoved when mismatched and less than expected' do |example|
|
|
33
|
-
expect do
|
|
34
|
-
ActiveSupport::Deprecation.warn("C")
|
|
35
|
-
|
|
36
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
37
|
-
end.to(raise_error(DeprecationToolkit::Behaviors::DeprecationRemoved))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it '.trigger raises a DeprecationMismatch when same number of deprecations are triggered with mismatches' do |example|
|
|
41
|
-
expect do
|
|
42
|
-
ActiveSupport::Deprecation.warn("A")
|
|
43
|
-
|
|
44
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
45
|
-
end.to(raise_error(DeprecationToolkit::Behaviors::DeprecationMismatch))
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it ".trigger does not raise when deprecations are triggered but were already recorded" do |example|
|
|
49
|
-
expect do
|
|
50
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
51
|
-
ActiveSupport::Deprecation.warn("Bar")
|
|
52
|
-
|
|
53
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
54
|
-
end.not_to(raise_error)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it ".trigger does not raise when deprecations are allowed with Regex" do |example|
|
|
58
|
-
@old_allowed_deprecations = DeprecationToolkit::Configuration.allowed_deprecations
|
|
59
|
-
DeprecationToolkit::Configuration.allowed_deprecations = [/John Doe/]
|
|
60
|
-
|
|
61
|
-
begin
|
|
62
|
-
ActiveSupport::Deprecation.warn("John Doe")
|
|
63
|
-
expect do
|
|
64
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
65
|
-
end.not_to(raise_error)
|
|
66
|
-
ensure
|
|
67
|
-
DeprecationToolkit::Configuration.allowed_deprecations = @old_allowed_deprecations
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it ".trigger does not raise when deprecations are allowed with Procs" do |example|
|
|
72
|
-
class_eval <<-RUBY, 'my_file.rb', 1337
|
|
73
|
-
def deprecation_caller
|
|
74
|
-
deprecation_callee
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def deprecation_callee
|
|
78
|
-
ActiveSupport::Deprecation.warn("John Doe")
|
|
79
|
-
end
|
|
80
|
-
RUBY
|
|
81
|
-
|
|
82
|
-
old_allowed_deprecations = DeprecationToolkit::Configuration.allowed_deprecations
|
|
83
|
-
DeprecationToolkit::Configuration.allowed_deprecations = [
|
|
84
|
-
->(_, stack) { stack.first.to_s =~ /my_file\.rb/ },
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
begin
|
|
88
|
-
deprecation_caller
|
|
89
|
-
expect do
|
|
90
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
91
|
-
end.not_to(raise_error)
|
|
92
|
-
ensure
|
|
93
|
-
DeprecationToolkit::Configuration.allowed_deprecations = old_allowed_deprecations
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
require "tmpdir"
|
|
5
|
-
|
|
6
|
-
RSpec.describe(DeprecationToolkit::Behaviors::Record) do
|
|
7
|
-
before do
|
|
8
|
-
@previous_deprecation_path = DeprecationToolkit::Configuration.deprecation_path
|
|
9
|
-
@deprecation_path = Dir.mktmpdir
|
|
10
|
-
@previous_behavior = DeprecationToolkit::Configuration.behavior
|
|
11
|
-
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
|
|
12
|
-
DeprecationToolkit::Configuration.deprecation_path = @deprecation_path
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
after do
|
|
16
|
-
DeprecationToolkit::Configuration.behavior = @previous_behavior
|
|
17
|
-
DeprecationToolkit::Configuration.deprecation_path = @previous_deprecation_path
|
|
18
|
-
FileUtils.rm_rf(@deprecation_path)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it '.trigger should record deprecations' do |example|
|
|
22
|
-
expect_deprecations_recorded("Foo", "Bar", example) do
|
|
23
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
24
|
-
ActiveSupport::Deprecation.warn("Bar")
|
|
25
|
-
|
|
26
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it ".trigger re-record an existing deprecation file" do |example|
|
|
31
|
-
expect_deprecations_recorded("Foo", "Bar", example) do
|
|
32
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
33
|
-
ActiveSupport::Deprecation.warn("Bar")
|
|
34
|
-
|
|
35
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
expect_deprecations_recorded("Foo", example) do
|
|
39
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
40
|
-
|
|
41
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it ".trigger removes the deprecation file when all deprecations were removed" do |example|
|
|
46
|
-
expect_deprecations_recorded("Foo", example) do
|
|
47
|
-
ActiveSupport::Deprecation.warn("Foo")
|
|
48
|
-
|
|
49
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
expect do
|
|
53
|
-
expect_deprecations_recorded("Foo", example) do
|
|
54
|
-
DeprecationToolkit::TestTriggerer.trigger_deprecation_toolkit_behavior(example)
|
|
55
|
-
end
|
|
56
|
-
end.to(raise_error(Errno::ENOENT))
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
private
|
|
60
|
-
|
|
61
|
-
def expect_deprecations_recorded(*deprecation_triggered, example)
|
|
62
|
-
yield
|
|
63
|
-
|
|
64
|
-
recorded = YAML.load_file(
|
|
65
|
-
"#{@deprecation_path}/deprecation_toolkit/behaviors/record.yml"
|
|
66
|
-
).fetch("test_" + example.full_description.underscore.squish.tr(" ", "_"))
|
|
67
|
-
triggered = deprecation_triggered.map { |msg| "DEPRECATION WARNING: #{msg}" }
|
|
68
|
-
|
|
69
|
-
expect(recorded).to(eq(triggered))
|
|
70
|
-
end
|
|
71
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_raises_a_deprecation_removed_error_when_deprecations_are_removed:
|
|
3
|
-
- 'DEPRECATION WARNING: Foo'
|
|
4
|
-
- 'DEPRECATION WARNING: Bar'
|
|
5
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_raises_a_deprecation_removed_when_mismatched_and_less_than_expected:
|
|
6
|
-
- 'DEPRECATION WARNING: A'
|
|
7
|
-
- 'DEPRECATION WARNING: B'
|
|
8
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_raises_a_deprecation_mismatch_when_same_number_of_deprecations_are_triggered_with_mismatches:
|
|
9
|
-
- 'DEPRECATION WARNING: C'
|
|
10
|
-
test_deprecation_toolkit/behaviors/raise_.trigger_does_not_raise_when_deprecations_are_triggered_but_were_already_recorded:
|
|
11
|
-
- 'DEPRECATION WARNING: Foo'
|
|
12
|
-
- 'DEPRECATION WARNING: Bar'
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# This needs to be set before we require `spec_helper` to simulate setting an ENV when running a spec like:
|
|
4
|
-
# `DEPRECATION_BEHAVIOR="record" bundle exec rspec path/to/spec.rb`
|
|
5
|
-
ENV['DEPRECATION_BEHAVIOR'] = "record"
|
|
6
|
-
|
|
7
|
-
require 'spec_helper'
|
|
8
|
-
|
|
9
|
-
RSpec.describe("DeprecationToolkit::RSpecPlugin ENV options") do
|
|
10
|
-
it 'should set the behavior to `Record` when ENV variable is set' do
|
|
11
|
-
expect(DeprecationToolkit::Configuration.behavior).to(eq(DeprecationToolkit::Behaviors::Record))
|
|
12
|
-
end
|
|
13
|
-
end
|
data/spec/rspec/plugin_spec.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
RSpec.describe(DeprecationToolkit::RSpecPlugin) do
|
|
6
|
-
it "should add `notify` behavior to the deprecations behavior list" do
|
|
7
|
-
behavior = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]
|
|
8
|
-
|
|
9
|
-
expect(ActiveSupport::Deprecation.behavior).to(include(behavior))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "doesn't remove previous deprecation behaviors" do
|
|
13
|
-
behavior = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:silence]
|
|
14
|
-
ActiveSupport::Deprecation.behavior = behavior
|
|
15
|
-
|
|
16
|
-
expect(ActiveSupport::Deprecation.behavior).to(include(behavior))
|
|
17
|
-
end
|
|
18
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
|
|
4
|
-
require "deprecation_toolkit"
|
|
5
|
-
require "deprecation_toolkit/rspec_plugin"
|
|
6
|
-
require "active_support/all"
|
|
7
|
-
|
|
8
|
-
DeprecationToolkit::Configuration.test_runner = :rspec
|
|
9
|
-
DeprecationToolkit::Configuration.deprecation_path = "spec/deprecations"
|
|
10
|
-
ActiveSupport::Deprecation.behavior = :silence
|
|
11
|
-
|
|
12
|
-
RSpec.configure do |config|
|
|
13
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
14
|
-
config.disable_monkey_patching!
|
|
15
|
-
|
|
16
|
-
config.expect_with(:rspec) do |c|
|
|
17
|
-
c.syntax = :expect
|
|
18
|
-
end
|
|
19
|
-
end
|