deprecation_toolkit 2.0.2 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 430ddfb053000146af52b971363780be4bf691de293a25a290a9c3fd96b11d66
4
- data.tar.gz: f336c225f3b20bb345b44147262c9b90a2ef461fe4c1843928c84485fcf6d182
3
+ metadata.gz: 304db5daebe7343f9d4150f079eb498d5c20978ea461c3fe82f2377d42464d2a
4
+ data.tar.gz: bcd740c82a01dc7c3782cdef1705a3ee829fdade6684d75ea2537e5601a8007d
5
5
  SHA512:
6
- metadata.gz: e34959cdf54a5c8db25012249424ccf98ab87aee835c14cdfed3eddb24d46cde2e9711f49d896cb16c2d6f5ef8904d5ded5cb726a00a7d0334dee3e94ca2932d
7
- data.tar.gz: b2cf482a05aa1f093a9d3ede4d47f8365601a83d3a48dd3f3c91f850828357b1d03d7d9f9381beea1aadf28fc1ddaae530fe56859c94e69a175d0d93b1d6b57d
6
+ metadata.gz: 67e7401a039080b8ece8449290ec34fa8595540654dac74cabd45084040f07f526d81a14b4c4fb0f1232bfb62a5f4cdb132080388c236d6b47bf2237c180d9f5
7
+ data.tar.gz: 042f87488783ea236fa740138b659ebf03dd9befa00a5a8681817103620719e1d73cb57324d9e6e6d23ce67b1a8c0feb3d852ff313bd2030305ab774403e147e
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  TargetRubyVersion: 2.6
6
+ SuggestExtensions: false
6
7
  Exclude:
7
8
  - gemfiles/vendor/**/*
8
9
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## main (unreleased)
4
4
 
5
+ ## 2.0.4 (2023-11-20)
6
+
7
+ * [#90](https://github.com/Shopify/deprecation_toolkit/pull/90) & [#93](https://github.com/Shopify/deprecation_toolkit/pull/93): Stop using deprecated behavior from Active Support. (@etiennebarrie)
8
+ * [#91](https://github.com/Shopify/deprecation_toolkit/pull/91): Require necessary Active Support core extension. (@etiennebarrie)
9
+
10
+ ## 2.0.3 (2023-02-10)
11
+
12
+ * [#80](https://github.com/Shopify/deprecation_toolkit/pull/80): Filter out stack trace from Gem::Deprecate deprecation messages (@davidstosik)
13
+
5
14
  ## 2.0.2 (2023-02-08)
6
15
 
7
16
  * [#78](https://github.com/Shopify/deprecation_toolkit/pull/78): Show deprecations without stacktrace. (@shioyama)
data/Gemfile.lock CHANGED
@@ -1,23 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_toolkit (2.0.2)
4
+ deprecation_toolkit (2.0.4)
5
5
  activesupport (>= 5.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4)
10
+ activesupport (7.1.2)
11
+ base64
12
+ bigdecimal
11
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ connection_pool (>= 2.2.5)
15
+ drb
12
16
  i18n (>= 1.6, < 2)
13
17
  minitest (>= 5.1)
18
+ mutex_m
14
19
  tzinfo (~> 2.0)
15
20
  ast (2.4.2)
16
- concurrent-ruby (1.1.10)
21
+ base64 (0.2.0)
22
+ bigdecimal (3.1.4)
23
+ concurrent-ruby (1.2.2)
24
+ connection_pool (2.4.1)
17
25
  diff-lcs (1.5.0)
18
- i18n (1.12.0)
26
+ drb (2.2.0)
27
+ ruby2_keywords
28
+ i18n (1.14.1)
19
29
  concurrent-ruby (~> 1.0)
20
- minitest (5.15.0)
30
+ minitest (5.20.0)
31
+ mutex_m (0.2.0)
21
32
  parallel (1.21.0)
22
33
  parser (3.1.1.0)
23
34
  ast (~> 2.4.1)
@@ -52,7 +63,8 @@ GEM
52
63
  rubocop-shopify (2.5.0)
53
64
  rubocop (~> 1.25)
54
65
  ruby-progressbar (1.11.0)
55
- tzinfo (2.0.5)
66
+ ruby2_keywords (0.0.5)
67
+ tzinfo (2.0.6)
56
68
  concurrent-ruby (~> 1.0)
57
69
  unicode-display_width (2.1.0)
58
70
 
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = ">= 2.7"
24
24
 
25
25
  spec.files = %x(git ls-files -z).split("\x0").reject do |f|
26
- f.match(%r{^(test)/})
26
+ f.match(%r{^(test|spec|\.github|gemfiles)/})
27
27
  end
28
28
  spec.require_paths = ["lib"]
29
29
 
@@ -35,11 +35,9 @@ module DeprecationToolkit
35
35
 
36
36
  def deprecations_without_stacktrace
37
37
  deprecations.map do |deprecation|
38
- if ActiveSupport.gem_version.to_s < "5.0"
39
- deprecation.sub(/\W\s\(called from .*\)$/, "")
40
- else
41
- deprecation.sub(/ \(called from .*\)$/, "")
42
- end
38
+ deprecation
39
+ .sub(*active_support_deprecation_sub_params)
40
+ .sub(*gem_deprecate_sub_params)
43
41
  end
44
42
  end
45
43
 
@@ -63,5 +61,19 @@ module DeprecationToolkit
63
61
  def flaky?
64
62
  size == 1 && deprecations.first["flaky"] == true
65
63
  end
64
+
65
+ private
66
+
67
+ def active_support_deprecation_sub_params
68
+ if ActiveSupport.gem_version.to_s < "5.0"
69
+ [/\W\s\(called from .*\)$/, ""]
70
+ else
71
+ [/ \(called from .*\)$/, ""]
72
+ end
73
+ end
74
+
75
+ def gem_deprecate_sub_params
76
+ [/NOTE: (.*is deprecated.*)\n.* called from.*:\d+\.\n/, "\\1"]
77
+ end
66
78
  end
67
79
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/string/inflections"
4
+ require "active_support/core_ext/string/filters"
4
5
  require "bundler"
5
6
  require "yaml"
6
7
 
@@ -2,16 +2,22 @@
2
2
 
3
3
  module DeprecationToolkit
4
4
  module RSpecPlugin
5
+ extend self
6
+
5
7
  RSpec.configure do |config|
6
8
  config.before(:suite) do
7
- case ENV["DEPRECATION_BEHAVIOR"]
8
- when "r", "record", "record-deprecations"
9
- DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
10
- end
9
+ RSpecPlugin.before_suite
10
+ end
11
+ end
11
12
 
12
- DeprecationToolkit.add_notify_behavior
13
- DeprecationToolkit.attach_subscriber
13
+ def before_suite
14
+ case ENV["DEPRECATION_BEHAVIOR"]
15
+ when "r", "record", "record-deprecations"
16
+ DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
14
17
  end
18
+
19
+ DeprecationToolkit.add_notify_behavior
20
+ DeprecationToolkit.attach_subscriber
15
21
  end
16
22
  end
17
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "2.0.2"
4
+ VERSION = "2.0.4"
5
5
  end
@@ -40,6 +40,13 @@ module DeprecationToolkit
40
40
  def deprecation_triggered?(str)
41
41
  DeprecationToolkit::Configuration.warnings_treated_as_deprecation.any? { |warning| warning =~ str }
42
42
  end
43
+
44
+ def deprecator
45
+ @deprecator ||= ActiveSupport::Deprecation.new("next", "DeprecationToolkit::Warning").tap do |deprecator|
46
+ deprecator.behavior = :notify
47
+ DeprecationSubscriber.attach_to(:deprecation_toolkit_warning)
48
+ end
49
+ end
43
50
  end
44
51
  end
45
52
 
@@ -50,7 +57,7 @@ module DeprecationToolkit
50
57
  return unless str
51
58
 
52
59
  if DeprecationToolkit::Warning.deprecation_triggered?(str)
53
- ActiveSupport::Deprecation.warn(str)
60
+ DeprecationToolkit::Warning.deprecator.warn(str)
54
61
  else
55
62
  super
56
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-07 00:00:00.000000000 Z
11
+ date: 2023-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -31,8 +31,6 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".github/workflows/ci.yml"
35
- - ".github/workflows/cla.yml"
36
34
  - ".gitignore"
37
35
  - ".rspec"
38
36
  - ".rubocop.yml"
@@ -44,13 +42,6 @@ files:
44
42
  - RELEASE.md
45
43
  - Rakefile
46
44
  - deprecation_toolkit.gemspec
47
- - gemfiles/activesupport_5.2.gemfile
48
- - gemfiles/activesupport_6.0.gemfile
49
- - gemfiles/activesupport_6.1.gemfile
50
- - gemfiles/activesupport_7.0.gemfile
51
- - gemfiles/activesupport_edge.gemfile
52
- - gemfiles/spec/deprecations/deprecation_toolkit/behaviors/raise.yml
53
- - gemfiles/test/deprecations
54
45
  - lib/deprecation_toolkit.rb
55
46
  - lib/deprecation_toolkit/behaviors/ci_record_helper.rb
56
47
  - lib/deprecation_toolkit/behaviors/disabled.rb
@@ -69,13 +60,6 @@ files:
69
60
  - lib/minitest/deprecation_toolkit_plugin.rb
70
61
  - lib/tasks/ci_recorder.rake
71
62
  - shipit.rubygems.yml
72
- - spec/deprecation_toolkit/behaviors/disabled_spec.rb
73
- - spec/deprecation_toolkit/behaviors/raise_spec.rb
74
- - spec/deprecation_toolkit/behaviors/record_spec.rb
75
- - spec/deprecations/deprecation_toolkit/behaviors/raise.yml
76
- - spec/rspec/plugin_env_options_spec.rb
77
- - spec/rspec/plugin_spec.rb
78
- - spec/spec_helper.rb
79
63
  homepage: https://github.com/shopify/deprecation_toolkit
80
64
  licenses:
81
65
  - MIT
@@ -99,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
83
  - !ruby/object:Gem::Version
100
84
  version: '0'
101
85
  requirements: []
102
- rubygems_version: 3.3.3
86
+ rubygems_version: 3.4.21
103
87
  signing_key:
104
88
  specification_version: 4
105
89
  summary: Deprecation Toolkit around ActiveSupport::Deprecation
@@ -1,50 +0,0 @@
1
- name: CI
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- functionality:
7
- runs-on: ubuntu-latest
8
- name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
9
- strategy:
10
- matrix:
11
- gemfile: [gemfiles/activesupport_5.2.gemfile, gemfiles/activesupport_6.0.gemfile, gemfiles/activesupport_6.1.gemfile, gemfiles/activesupport_7.0.gemfile, gemfiles/activesupport_edge.gemfile]
12
- ruby: ["2.7", "3.0", "3.1", "3.2"]
13
- exclude:
14
- # Active Support requires Ruby >= 2.7 as of 7.0
15
- - gemfile: "gemfiles/activesupport_7.0.gemfile"
16
- ruby: "2.6"
17
- - gemfile: "gemfiles/activesupport_edge.gemfile"
18
- ruby: "2.6"
19
- env:
20
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
21
- steps:
22
-
23
- - name: Check out code
24
- uses: actions/checkout@v3
25
-
26
- - name: Set up Ruby ${{ matrix.ruby }}
27
- uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: ${{ matrix.ruby }}
30
- bundler-cache: true
31
-
32
- - name: Tests
33
- run: bundle exec rake test
34
-
35
- - name: Specs
36
- run: bundle exec rspec
37
- style:
38
- runs-on: ubuntu-latest
39
- name: Rubocop
40
- steps:
41
- - name: Check out code
42
- uses: actions/checkout@v3
43
-
44
- - uses: ruby/setup-ruby@v1
45
- with:
46
- ruby-version: "3.2"
47
- bundler-cache: true
48
-
49
- - name: RuboCop
50
- run: bundle exec rubocop
@@ -1,26 +0,0 @@
1
- name: Contributor License Agreement (CLA)
2
-
3
- on:
4
- pull_request_target:
5
- types: [opened, synchronize]
6
- issue_comment:
7
- types: [created]
8
-
9
- permissions:
10
- pull-requests: write # to set the label
11
- actions: write # to re-run the workflow when a comment is received
12
-
13
- jobs:
14
- cla:
15
- runs-on: ubuntu-latest
16
- if: |
17
- (github.event.issue.pull_request
18
- && !github.event.issue.pull_request.merged_at
19
- && contains(github.event.comment.body, 'signed')
20
- )
21
- || (github.event.pull_request && !github.event.pull_request.merged)
22
- steps:
23
- - uses: Shopify/shopify-cla-action@v1
24
- with:
25
- github-token: ${{ secrets.GITHUB_TOKEN }}
26
- cla-token: ${{ secrets.CLA_TOKEN }}
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- @activesupport_gem_requirement = "~> 5.2"
4
-
5
- eval_gemfile "../Gemfile"
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- @activesupport_gem_requirement = "~> 6.0"
4
-
5
- eval_gemfile "../Gemfile"
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- @activesupport_gem_requirement = "~> 6.1"
4
-
5
- eval_gemfile "../Gemfile"
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- @activesupport_gem_requirement = "~> 7.0"
4
-
5
- eval_gemfile "../Gemfile"
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- @activesupport_gem_requirement = { github: "rails/rails" }
4
-
5
- eval_gemfile "../Gemfile"
@@ -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 +0,0 @@
1
- ../../test/deprecations
@@ -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
@@ -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