Class: DeprecationToolkit::Behaviors::DeprecationIntroduced

Inherits:
DeprecationException
  • Object
show all
Defined in:
lib/deprecation_toolkit/behaviors/raise.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_deprecations, recorded_deprecations) ⇒ DeprecationIntroduced

Returns a new instance of DeprecationIntroduced.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/deprecation_toolkit/behaviors/raise.rb', line 24

def initialize(current_deprecations, recorded_deprecations)
  introduced_deprecations = current_deprecations - recorded_deprecations
  record_message =
    if DeprecationToolkit::Configuration.test_runner == :rspec
      "You can record deprecations by adding the `DEPRECATION_BEHAVIOR='record'` ENV when running your specs."
    else
      "You can record deprecations by adding the `--record-deprecations` flag when running your tests."
    end

  message = <<~EOM
    You have introduced new deprecations in the codebase. Fix or record them in order to discard this error.
    #{record_message}

    #{introduced_deprecations.join("\n")}
  EOM

  super(message)
end