Module: Minitest::Assertions

Defined in:
lib/minitest/rematch_plugin.rb

Overview

Reopen the minitest module

Instance Method Summary collapse

Instance Method Details

#assert_rematch(actual, *args) ⇒ Object

Main assertion



38
39
40
41
42
43
44
45
46
47
# File 'lib/minitest/rematch_plugin.rb', line 38

def assert_rematch(actual, *args)
  label = Rematch.extract_label(args)
  assertion, message = args
  assertion, message = message, assertion unless assertion.nil? || assertion.is_a?(Symbol)
  if actual.nil? # use specific assert_nil after deprecation of assert_equal nil
    assert_nil @rematch.rematch(actual, label:), message
  else # assert that the stored value is the same actual value
    send assertion || :assert_equal, @rematch.rematch(actual, label:), actual, message
  end
end

#store_assert_rematch(actual, *args) ⇒ Object

Temporarily used to store the actual value, useful for reconciliation of expected changed values

Raises:

  • (Minitest::Assertion)


50
51
52
53
54
55
# File 'lib/minitest/rematch_plugin.rb', line 50

def store_assert_rematch(actual, *args)
  label = Rematch.extract_label(args)
  @rematch.rematch(actual, overwrite: true, label:)
  # Always fail after storing, forcing the restore of the original assertion/expectation
  raise Minitest::Assertion, '[rematch] the value has been stored: remove the "store_" prefix to pass the test'
end