deprecation_toolkit 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +39 -0
  3. data/.rubocop.yml +3 -3
  4. data/CHANGELOG.md +17 -1
  5. data/Gemfile +11 -4
  6. data/Gemfile.lock +48 -44
  7. data/README.md +5 -0
  8. data/RELEASE.md +21 -0
  9. data/deprecation_toolkit.gemspec +7 -10
  10. data/gemfiles/activesupport_5.2.gemfile +2 -8
  11. data/gemfiles/activesupport_6.0.gemfile +5 -0
  12. data/gemfiles/activesupport_6.1.gemfile +5 -0
  13. data/gemfiles/activesupport_7.0.gemfile +5 -0
  14. data/gemfiles/activesupport_edge.gemfile +5 -0
  15. data/gemfiles/test/deprecations +1 -1
  16. data/lib/deprecation_toolkit/behaviors/ci_record_helper.rb +2 -2
  17. data/lib/deprecation_toolkit/collector.rb +1 -1
  18. data/lib/deprecation_toolkit/deprecation_subscriber.rb +1 -1
  19. data/lib/deprecation_toolkit/rspec_plugin.rb +1 -1
  20. data/lib/deprecation_toolkit/version.rb +1 -1
  21. data/lib/deprecation_toolkit/warning.rb +43 -32
  22. data/lib/deprecation_toolkit.rb +4 -5
  23. data/lib/minitest/deprecation_toolkit_plugin.rb +9 -2
  24. data/lib/tasks/ci_recorder.rake +10 -9
  25. data/spec/deprecation_toolkit/behaviors/disabled_spec.rb +2 -2
  26. data/spec/deprecation_toolkit/behaviors/raise_spec.rb +4 -4
  27. data/spec/deprecation_toolkit/behaviors/record_spec.rb +1 -1
  28. data/spec/rspec/plugin_env_options_spec.rb +3 -3
  29. data/spec/rspec/plugin_spec.rb +1 -1
  30. metadata +14 -69
  31. data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1178
  32. data/.travis.yml +0 -20
  33. data/gemfiles/activesupport_4.2.gemfile +0 -11
  34. data/gemfiles/activesupport_5.0.gemfile +0 -11
  35. data/gemfiles/activesupport_5.1.gemfile +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d2f08916abc502412bc2c68826947592e55e90a5eee9cce948e57145a9e3db4
4
- data.tar.gz: d96b9c8941b6f769f2218e6695e7b1d99fcde3b4cb40fac5bace9d6af81706ab
3
+ metadata.gz: 50f90bbfa1a09a7e1f2cbd9dad67e90d50a3d43e71e57d713f4ed37824bf288f
4
+ data.tar.gz: a8e704fd3454e2f0b7753cc6ed677ebfc7f07298362cd06166f53d5d8a01b67b
5
5
  SHA512:
6
- metadata.gz: 1ba98635a5fcf3b30868ebeb4d7b52256c8444b2ef2681860308be56d506a6849e1c27d98cd2c9b2322490ec25f2416a09eb989be19a0c3bb819511cf491cf84
7
- data.tar.gz: 2bda4d027138410c2752fb9217bd2a01bebf3c5f0420d4a0a571f7172ee8965483eebc76257b3d8df50e1f4f09d9c71fc69c1586a26491942970102f8419ec87
6
+ metadata.gz: aa06c177df6e63bf8a2ba11d734b837481bc1d5ada8d1fbbf8187e5d6424797aa605b70be127c48642ff3a0e66188fff8cbded056167ef045811a74e8a73eb41
7
+ data.tar.gz: 52a7bccd13c97db713aa708e226e817cd0fac52550ded6ef0890ca1b8d6da4a18291787f552f1c11358c5a52d25a8d54a2dfbb1c1efc05bcc99cc559ed8ee7c4
@@ -0,0 +1,39 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
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.6", "2.7", "3.0", "3.1"]
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: RuboCop
33
+ run: bundle exec rubocop
34
+
35
+ - name: Tests
36
+ run: bundle exec rake test
37
+
38
+ - name: Specs
39
+ run: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1,8 +1,8 @@
1
- inherit_from:
2
- - https://shopify.github.io/ruby-style-guide/rubocop.yml
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.3
5
+ TargetRubyVersion: 2.6
6
6
  Exclude:
7
7
  - gemfiles/vendor/**/*
8
8
 
data/CHANGELOG.md CHANGED
@@ -1,11 +1,27 @@
1
1
  # Change log
2
2
 
3
- ## master (unreleased)
3
+ ## main (unreleased)
4
+
5
+ ## 2.0.0 (2022-03-16)
6
+
7
+ * [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Drop support for Ruby < 2.6 & Active Support < 5.2. (@sambostock)
8
+ * [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Ensure compatibility with Rails 7. (@sambostock)
9
+
10
+ ## 1.5.1 (2020-04-28)
11
+
12
+ * [#46](https://github.com/Shopify/deprecation_toolkit/pull/46): Handle another two part Ruby 2.7 keyword argument deprecation warning. (@casperisfine)
13
+
14
+ ## 1.5.0 (2020-04-14)
15
+
16
+ * [#42](https://github.com/Shopify/deprecation_toolkit/pull/42): Fix Minitest plugin kicking in when it shouldn't. (@Edouard-chin)
17
+ * [#45](https://github.com/Shopify/deprecation_toolkit/pull/45): Handle two part Ruby 2.7 keyword argument deprecation warning. (@casperisfine)
4
18
 
5
19
  ## 1.4.0 (2019-04-29)
20
+
6
21
  * [#37](https://github.com/Shopify/deprecation_toolkit/pull/37): Add Rspec support. (@andrewmarkle)
7
22
 
8
23
  ## 1.3.0 (2019-02-28)
24
+
9
25
  * [#38](https://github.com/Shopify/deprecation_toolkit/pull/38): Add a way to mark test as flaky. (@Edouard-chin)
10
26
  * [#39](https://github.com/Shopify/deprecation_toolkit/pull/39): Introduced a way to help recording massive amount of deprecations. (@Edouard-chin)
11
27
 
data/Gemfile CHANGED
@@ -1,10 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- group :deployment do
8
- gem 'rake'
9
- gem 'rubocop'
7
+ gem "bundler"
8
+ gem "minitest"
9
+ gem "rake"
10
+ gem "rspec"
11
+ gem "rubocop-shopify"
12
+
13
+ if defined?(@activesupport_gem_requirement) && @activesupport_gem_requirement
14
+ # causes Dependabot to ignore the next line
15
+ activesupport = "activesupport"
16
+ gem activesupport, @activesupport_gem_requirement
10
17
  end
data/Gemfile.lock CHANGED
@@ -1,67 +1,71 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_toolkit (1.4.0)
5
- activesupport (>= 4.2)
4
+ deprecation_toolkit (2.0.0)
5
+ activesupport (>= 5.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.2.3)
10
+ activesupport (7.0.2.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (>= 0.7, < 2)
13
- minitest (~> 5.1)
14
- tzinfo (~> 1.1)
15
- ast (2.4.0)
16
- concurrent-ruby (1.1.5)
17
- diff-lcs (1.3)
18
- i18n (1.6.0)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ ast (2.4.2)
16
+ concurrent-ruby (1.1.9)
17
+ diff-lcs (1.5.0)
18
+ i18n (1.10.0)
19
19
  concurrent-ruby (~> 1.0)
20
- jaro_winkler (1.5.2)
21
- minitest (5.11.3)
22
- parallel (1.17.0)
23
- parser (2.6.3.0)
24
- ast (~> 2.4.0)
25
- psych (3.1.0)
26
- rainbow (3.0.0)
27
- rake (12.3.2)
28
- rspec (3.8.0)
29
- rspec-core (~> 3.8.0)
30
- rspec-expectations (~> 3.8.0)
31
- rspec-mocks (~> 3.8.0)
32
- rspec-core (3.8.0)
33
- rspec-support (~> 3.8.0)
34
- rspec-expectations (3.8.2)
20
+ minitest (5.15.0)
21
+ parallel (1.21.0)
22
+ parser (3.1.1.0)
23
+ ast (~> 2.4.1)
24
+ rainbow (3.1.1)
25
+ rake (13.0.6)
26
+ regexp_parser (2.2.1)
27
+ rexml (3.2.5)
28
+ rspec (3.11.0)
29
+ rspec-core (~> 3.11.0)
30
+ rspec-expectations (~> 3.11.0)
31
+ rspec-mocks (~> 3.11.0)
32
+ rspec-core (3.11.0)
33
+ rspec-support (~> 3.11.0)
34
+ rspec-expectations (3.11.0)
35
35
  diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.8.0)
37
- rspec-mocks (3.8.0)
36
+ rspec-support (~> 3.11.0)
37
+ rspec-mocks (3.11.0)
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.8.0)
40
- rspec-support (3.8.0)
41
- rubocop (0.67.2)
42
- jaro_winkler (~> 1.5.1)
39
+ rspec-support (~> 3.11.0)
40
+ rspec-support (3.11.0)
41
+ rubocop (1.25.1)
43
42
  parallel (~> 1.10)
44
- parser (>= 2.5, != 2.5.1.1)
45
- psych (>= 3.1.0)
43
+ parser (>= 3.1.0.0)
46
44
  rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 1.8, < 3.0)
46
+ rexml
47
+ rubocop-ast (>= 1.15.1, < 2.0)
47
48
  ruby-progressbar (~> 1.7)
48
- unicode-display_width (>= 1.4.0, < 1.6)
49
- ruby-progressbar (1.10.0)
50
- thread_safe (0.3.6)
51
- tzinfo (1.2.5)
52
- thread_safe (~> 0.1)
53
- unicode-display_width (1.5.0)
49
+ unicode-display_width (>= 1.4.0, < 3.0)
50
+ rubocop-ast (1.16.0)
51
+ parser (>= 3.1.1.0)
52
+ rubocop-shopify (2.5.0)
53
+ rubocop (~> 1.25)
54
+ ruby-progressbar (1.11.0)
55
+ tzinfo (2.0.4)
56
+ concurrent-ruby (~> 1.0)
57
+ unicode-display_width (2.1.0)
54
58
 
55
59
  PLATFORMS
56
60
  ruby
57
61
 
58
62
  DEPENDENCIES
59
- bundler (>= 1.16)
63
+ bundler
60
64
  deprecation_toolkit!
61
- minitest (~> 5.0)
65
+ minitest
62
66
  rake
63
- rspec (~> 3.0)
64
- rubocop
67
+ rspec
68
+ rubocop-shopify
65
69
 
66
70
  BUNDLED WITH
67
- 1.17.3
71
+ 2.2.22
data/README.md CHANGED
@@ -114,6 +114,11 @@ a message in the console.
114
114
  Deprecation Toolkit allows you to configure which warnings should be treated as deprecations in order for you
115
115
  to keep track of them as if they were regular deprecations.
116
116
 
117
+ This setting accepts an array of regular expressions. To match on all warnings, you can provide a empty regex:
118
+
119
+ ```ruby
120
+ DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [//]
121
+ ```
117
122
 
118
123
  ## RSpec
119
124
 
data/RELEASE.md ADDED
@@ -0,0 +1,21 @@
1
+ # Contribution to Deprecation Toolkit
2
+
3
+ ## Releasing a new version
4
+
5
+ 1. Audit PRs and commits merged since the last release, ensuring **all user fancing changes are documented** in `CHANGELOG.md`.
6
+ 2. Based on the changes, determine whether to increment the major, minor, or patch version, adhering to [Semantic Versioning][semver].
7
+ 3. Update the gem version string accordingly in `lib/deprecation_toolkit/version.rb`.
8
+ 4. Run `bundle install` to update the `Gemfile.lock`.
9
+ 5. Insert a new heading in `CHANGELOG.md` containing the version identifier and expected release date (e.g. `## 1.2.3 (1999-12-31)`).
10
+ 6. Commit changes on a new branch and open a PR.
11
+ 7. **Draft** a [new release][github-new-release] on GitHub, but **do not publish it yet**.
12
+ 8. Once you have received approval on your PR, merge it into `main`.
13
+ 9. Deploy using the [ShipIt][shipit] UI, and **verify** the new version is available on [RubyGems][rubygems].
14
+ 10. Publish the drafted release, tagging the deployed commit (should be `HEAD` of the `main` branch) with a tag of the form `vMAJOR.MINOR.PATCH`.
15
+
16
+ If something goes wrong during the deploy process, address it and tag whatever commit was successfully deployed as that version.
17
+
18
+ [semver]: https://semver.org
19
+ [github-new-release]: https://github.com/Shopify/deprecation_toolkit/releases/new
20
+ [shipit]: https://shipit.shopify.io/shopify/deprecation_toolkit/rubygems
21
+ [rubygems]: https://rubygems.org/gems/deprecation_toolkit/versions
@@ -7,7 +7,7 @@ require "deprecation_toolkit/version"
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = "deprecation_toolkit"
9
9
  spec.version = DeprecationToolkit::VERSION
10
- spec.authors = %w(Shopify)
10
+ spec.authors = ["Shopify"]
11
11
  spec.email = ["rails@shopify.com"]
12
12
 
13
13
  spec.summary = "Deprecation Toolkit around ActiveSupport::Deprecation"
@@ -16,19 +16,16 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
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"
19
+ spec.metadata["changelog_uri"] = "https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md"
20
20
 
21
- spec.required_ruby_version = '>= 2.3'
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+
23
+ spec.required_ruby_version = ">= 2.6"
22
24
 
23
25
  spec.files = %x(git ls-files -z).split("\x0").reject do |f|
24
26
  f.match(%r{^(test)/})
25
27
  end
26
- spec.require_paths = %w(lib)
27
-
28
- spec.add_runtime_dependency('activesupport', '>= 4.2')
28
+ spec.require_paths = ["lib"]
29
29
 
30
- spec.add_development_dependency("bundler", ">= 1.16")
31
- spec.add_development_dependency("rake", "~> 10.0")
32
- spec.add_development_dependency("minitest", "~> 5.0")
33
- spec.add_development_dependency("rspec", "~> 3.0")
30
+ spec.add_runtime_dependency("activesupport", ">= 5.2")
34
31
  end
@@ -1,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
- source "https://rubygems.org"
3
2
 
4
- gem "activesupport", "~> 5.2"
3
+ @activesupport_gem_requirement = "~> 5.2"
5
4
 
6
- group :deployment do
7
- gem "rake"
8
- gem "rubocop"
9
- end
10
-
11
- gemspec path: "../"
5
+ eval_gemfile "../Gemfile"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ @activesupport_gem_requirement = "~> 6.0"
4
+
5
+ eval_gemfile "../Gemfile"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ @activesupport_gem_requirement = "~> 6.1"
4
+
5
+ eval_gemfile "../Gemfile"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ @activesupport_gem_requirement = "~> 7.0"
4
+
5
+ eval_gemfile "../Gemfile"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ @activesupport_gem_requirement = { github: "rails/rails" }
4
+
5
+ eval_gemfile "../Gemfile"
@@ -1 +1 @@
1
- gemfiles/test/../../test/deprecations
1
+ ../../test/deprecations
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
3
+ require "json"
4
4
 
5
5
  module DeprecationToolkit
6
6
  module Behaviors
7
7
  class CIRecordHelper
8
8
  extend ReadWriteHelper
9
9
 
10
- HEADER = '[DeprecationToolkit]'
10
+ HEADER = "[DeprecationToolkit]"
11
11
 
12
12
  def self.trigger(test, current_deprecations, _recorded_deprecations)
13
13
  filename = recorded_deprecations_path(test)
@@ -61,7 +61,7 @@ module DeprecationToolkit
61
61
  end
62
62
 
63
63
  def flaky?
64
- size == 1 && deprecations.first['flaky'] == true
64
+ size == 1 && deprecations.first["flaky"] == true
65
65
  end
66
66
  end
67
67
  end
@@ -20,7 +20,7 @@ module DeprecationToolkit
20
20
  allowed_deprecations, procs = Configuration.allowed_deprecations.partition { |el| el.is_a?(Regexp) }
21
21
 
22
22
  allowed_deprecations.any? { |regex| regex =~ payload[:message] } ||
23
- procs.any? { |proc| proc.call(payload[:message], payload[:callstack]) }
23
+ procs.any? { |proc| proc.call(payload[:message], payload[:callstack]) }
24
24
  end
25
25
  end
26
26
  end
@@ -4,7 +4,7 @@ module DeprecationToolkit
4
4
  module RSpecPlugin
5
5
  RSpec.configure do |config|
6
6
  config.before(:suite) do
7
- case ENV['DEPRECATION_BEHAVIOR']
7
+ case ENV["DEPRECATION_BEHAVIOR"]
8
8
  when "r", "record", "record-deprecations"
9
9
  DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "1.4.0"
4
+ VERSION = "2.0.0"
5
5
  end
@@ -4,46 +4,57 @@ module DeprecationToolkit
4
4
  module Warning
5
5
  extend self
6
6
 
7
- def deprecation_triggered?(str)
8
- DeprecationToolkit::Configuration.warnings_treated_as_deprecation.any? { |warning| warning =~ str }
7
+ @buffer = nil
8
+
9
+ # Ruby 2.7 has two warnings for improper use of keyword arguments that are sent in two parts
10
+ # Example:
11
+ #
12
+ # /path/to/caller.rb:1: warning: Using the last argument as keyword parameters is deprecated; \
13
+ # maybe ** should be added to the call
14
+ # /path/to/calleee.rb:1: warning: The called method `method_name' is defined here
15
+ #
16
+ # /path/to/caller.rb:1: warning: Passing the keyword argument as the last hash parameter is deprecated
17
+ # /path/to/calleee.rb:1: warning: The called method `method_name' is defined here
18
+ def two_part_warning?(str)
19
+ str.end_with?(
20
+ "maybe ** should be added to the call\n",
21
+ "Passing the keyword argument as the last hash parameter is deprecated\n",
22
+ )
9
23
  end
10
- end
11
- end
12
24
 
13
- # Warning is a new feature in ruby 2.5, so support older versions
14
- # Note that the `Warning` module exists in Ruby 2.4 but has a bug https://bugs.ruby-lang.org/issues/12944
15
- if RUBY_VERSION < '2.5.0' && RUBY_ENGINE == 'ruby'
16
- module Kernel
17
- class << self
18
- alias_method :__original_warn, :warn
19
-
20
- def warn(*messages)
21
- message = messages.join("\n")
22
- message += "\n" unless message.end_with?("\n")
23
-
24
- if DeprecationToolkit::Warning.deprecation_triggered?(message)
25
- ActiveSupport::Deprecation.warn(message)
26
- else
27
- __original_warn(messages)
28
- end
25
+ def handle_multipart(str)
26
+ if @buffer
27
+ str = @buffer + str
28
+ @buffer = nil
29
+ return str
30
+ end
31
+
32
+ if two_part_warning?(str)
33
+ @buffer = str
34
+ return
29
35
  end
36
+
37
+ str
30
38
  end
31
39
 
32
- def warn(*messages)
33
- Kernel.warn(messages)
40
+ def deprecation_triggered?(str)
41
+ DeprecationToolkit::Configuration.warnings_treated_as_deprecation.any? { |warning| warning =~ str }
34
42
  end
35
43
  end
36
- else
37
- module DeprecationToolkit
38
- module WarningPatch
39
- def warn(str)
40
- if DeprecationToolkit::Warning.deprecation_triggered?(str)
41
- ActiveSupport::Deprecation.warn(str)
42
- else
43
- super
44
- end
44
+ end
45
+
46
+ module DeprecationToolkit
47
+ module WarningPatch
48
+ def warn(str)
49
+ str = DeprecationToolkit::Warning.handle_multipart(str)
50
+ return unless str
51
+
52
+ if DeprecationToolkit::Warning.deprecation_triggered?(str)
53
+ ActiveSupport::Deprecation.warn(str)
54
+ else
55
+ super
45
56
  end
46
57
  end
47
58
  end
48
- Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
49
59
  end
60
+ Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- load('tasks/ci_recorder.rake')
3
+ require "active_support"
4
+
5
+ load("tasks/ci_recorder.rake")
4
6
 
5
7
  module DeprecationToolkit
6
8
  autoload :DeprecationSubscriber, "deprecation_toolkit/deprecation_subscriber"
@@ -34,8 +36,5 @@ module DeprecationToolkit
34
36
  end
35
37
  end
36
38
 
37
- unless defined?(RSpec)
38
- require "deprecation_toolkit/minitest_hook"
39
- end
40
-
39
+ require "deprecation_toolkit/minitest_hook" unless defined? RSpec
41
40
  require "deprecation_toolkit/warning"
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'deprecation_toolkit'
4
-
5
3
  module Minitest
6
4
  extend self
7
5
 
@@ -12,6 +10,9 @@ module Minitest
12
10
  end
13
11
 
14
12
  def plugin_deprecation_toolkit_init(options)
13
+ return unless using_bundler?
14
+
15
+ require "deprecation_toolkit"
15
16
  if options[:record_deprecations]
16
17
  DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
17
18
  end
@@ -19,4 +20,10 @@ module Minitest
19
20
  DeprecationToolkit.add_notify_behavior
20
21
  DeprecationToolkit.attach_subscriber
21
22
  end
23
+
24
+ private
25
+
26
+ def using_bundler?
27
+ ENV["BUNDLE_GEMFILE"]
28
+ end
22
29
  end
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tempfile'
4
- require 'json'
5
- require 'active_support/core_ext/hash'
6
- require 'rake'
7
- require_relative '../deprecation_toolkit/read_write_helper'
3
+ require "tempfile"
4
+ require "json"
5
+ require "active_support/core_ext/hash"
6
+ require "rake"
7
+ require_relative "../deprecation_toolkit/read_write_helper"
8
8
 
9
9
  class CIRecorder
10
10
  include Rake::DSL
11
11
  include DeprecationToolkit::ReadWriteHelper
12
12
 
13
13
  def initialize
14
- namespace :deprecation_toolkit do
15
- desc 'Parse a file generated with the CIOutputHelper and generate deprecations out of it'
16
- task :record_from_ci_output do
17
- raw_file = ENV.fetch('FILEPATH')
14
+ namespace(:deprecation_toolkit) do
15
+ desc("Parse a file generated with the CIOutputHelper and generate deprecations out of it")
16
+ task(:record_from_ci_output) do
17
+ raw_file = ENV.fetch("FILEPATH")
18
18
 
19
19
  deprecations = extract_deprecations_output(raw_file) do |file|
20
20
  parse_file(file)
@@ -32,6 +32,7 @@ class CIRecorder
32
32
  shell_command = "cat #{file} | sed -n -e 's/^.* \\[DeprecationToolkit\\] \\(.*\\)/\\1/p' > #{tmp_file.path}"
33
33
 
34
34
  raise "Couldn't extract deprecations from output" unless system(shell_command)
35
+
35
36
  yield(tmp_file)
36
37
  ensure
37
38
  tmp_file.delete
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
6
6
  before do
@@ -12,7 +12,7 @@ RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
12
12
  DeprecationToolkit::Configuration.behavior = @previous_configuration
13
13
  end
14
14
 
15
- it '.trigger noop any deprecations' do |example|
15
+ it ".trigger noop any deprecations" do |example|
16
16
  expect do
17
17
  ActiveSupport::Deprecation.warn("Foo")
18
18
  ActiveSupport::Deprecation.warn("Bar")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
6
6
  before do
@@ -29,7 +29,7 @@ RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
29
29
  end.to(raise_error(DeprecationToolkit::Behaviors::DeprecationRemoved))
30
30
  end
31
31
 
32
- it '.trigger raises a DeprecationRemoved when mismatched and less than expected' do |example|
32
+ it ".trigger raises a DeprecationRemoved when mismatched and less than expected" do |example|
33
33
  expect do
34
34
  ActiveSupport::Deprecation.warn("C")
35
35
 
@@ -37,7 +37,7 @@ RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
37
37
  end.to(raise_error(DeprecationToolkit::Behaviors::DeprecationRemoved))
38
38
  end
39
39
 
40
- it '.trigger raises a DeprecationMismatch when same number of deprecations are triggered with mismatches' do |example|
40
+ it ".trigger raises a DeprecationMismatch when same number of deprecations are triggered with mismatches" do |example|
41
41
  expect do
42
42
  ActiveSupport::Deprecation.warn("A")
43
43
 
@@ -69,7 +69,7 @@ RSpec.describe(DeprecationToolkit::Behaviors::Raise) do
69
69
  end
70
70
 
71
71
  it ".trigger does not raise when deprecations are allowed with Procs" do |example|
72
- class_eval <<-RUBY, 'my_file.rb', 1337
72
+ class_eval <<-RUBY, "my_file.rb", 1337
73
73
  def deprecation_caller
74
74
  deprecation_callee
75
75
  end
@@ -18,7 +18,7 @@ RSpec.describe(DeprecationToolkit::Behaviors::Record) do
18
18
  FileUtils.rm_rf(@deprecation_path)
19
19
  end
20
20
 
21
- it '.trigger should record deprecations' do |example|
21
+ it ".trigger should record deprecations" do |example|
22
22
  expect_deprecations_recorded("Foo", "Bar", example) do
23
23
  ActiveSupport::Deprecation.warn("Foo")
24
24
  ActiveSupport::Deprecation.warn("Bar")