Class: DeprecationToolkit::Behaviors::DeprecationMismatch

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

Instance Method Summary collapse

Constructor Details

#initialize(current_deprecations, recorded_deprecations) ⇒ DeprecationMismatch

Returns a new instance of DeprecationMismatch.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/deprecation_toolkit/behaviors/raise.rb', line 66

def initialize(current_deprecations, recorded_deprecations)
  record_message =
    if DeprecationToolkit::Configuration.test_runner == :rspec
      "You can re-record deprecations by adding the `DEPRECATION_BEHAVIOR='record'` ENV when running your specs."
    else
      "You can re-record deprecations by adding the `--record-deprecations` flag when running your tests."
    end
  message = <<~EOM
    The recorded deprecations for this test doesn't match the one that got triggered.
    Fix or record the new deprecations to discard this error.

    #{record_message}

    ===== Expected
    #{recorded_deprecations.deprecations_without_stacktrace.join("\n")}
    ===== Actual
    #{current_deprecations.deprecations_without_stacktrace.join("\n")}
  EOM

  super(message)
end