Class: InduceError

Inherits:
Object
  • Object
show all
Defined in:
lib/prolog_minitest_matchers/matchers/asserters/induce_error.rb

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(error_class:, inducer:) ⇒ Object



5
6
7
# 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

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
# 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