matchi 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module Matchi
6
- module Matcher
7
- # *Expecting errors* matcher.
8
- class RaiseException < ::Matchi::Matcher::Base
9
- # Initialize the matcher with a descendant of class Exception.
10
- #
11
- # @example Divided by 0 matcher.
12
- # Matchi::Matcher::RaiseException.new(ZeroDivisionError)
13
- #
14
- # @param expected [Exception] The class of the expected exception.
15
- def initialize(expected)
16
- super()
17
- @expected = expected
18
- end
19
-
20
- # Boolean comparison between the actual value and the expected value.
21
- #
22
- # @example Is it raising NameError?
23
- # matcher = Matchi::Matcher::RaiseException.new(NameError)
24
- # matcher.matches? { Boom } # => true
25
- #
26
- # @yieldreturn [#object_id] The actual value to compare to the expected
27
- # one.
28
- #
29
- # @return [Boolean] Comparison between actual and expected values.
30
- def matches?(*, **)
31
- yield
32
- rescue expected => _e
33
- true
34
- else
35
- false
36
- end
37
- end
38
- end
39
- end