class InduceError

Attempt to induce a specified failure, and report if successful or not.

Attributes

error_class[R]
inducer[R]

Public Class Methods

call(error_class:, inducer:) click to toggle source
# File lib/prolog_minitest_matchers/matchers/asserters/induce_error.rb, line 5
def self.call(error_class:, inducer:)
  InduceError.new(error_class, inducer).call
end
new(error_class, inducer) click to toggle source
# File lib/prolog_minitest_matchers/matchers/asserters/induce_error.rb, line 21
def initialize(error_class, inducer)
  @error_class = error_class
  @inducer = inducer
  self
end

Public Instance Methods

call() click to toggle source
# File lib/prolog_minitest_matchers/matchers/asserters/induce_error.rb, line 9
def call
  expected_error = nil
  begin
    inducer.call
  rescue error_class => error
    expected_error = error
  end
  { expected: expected_error }
end