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.
- checksums.yaml +4 -4
- data/README.md +69 -74
- data/lib/matchi.rb +4 -2
- data/lib/matchi/be.rb +44 -0
- data/lib/matchi/be_an_instance_of.rb +44 -0
- data/lib/matchi/change.rb +109 -0
- data/lib/matchi/change/by.rb +58 -0
- data/lib/matchi/change/by_at_least.rb +58 -0
- data/lib/matchi/change/by_at_most.rb +58 -0
- data/lib/matchi/change/from.rb +44 -0
- data/lib/matchi/change/from/to.rb +64 -0
- data/lib/matchi/change/to.rb +57 -0
- data/lib/matchi/eq.rb +44 -0
- data/lib/matchi/match.rb +44 -0
- data/lib/matchi/raise_exception.rb +48 -0
- data/lib/matchi/satisfy.rb +44 -0
- metadata +17 -15
- data/lib/matchi/helper.rb +0 -40
- data/lib/matchi/matcher.rb +0 -11
- data/lib/matchi/matcher/base.rb +0 -63
- data/lib/matchi/matcher/be_an_instance_of.rb +0 -51
- data/lib/matchi/matcher/be_false.rb +0 -24
- data/lib/matchi/matcher/be_nil.rb +0 -24
- data/lib/matchi/matcher/be_true.rb +0 -24
- data/lib/matchi/matcher/eql.rb +0 -35
- data/lib/matchi/matcher/equal.rb +0 -35
- data/lib/matchi/matcher/match.rb +0 -35
- data/lib/matchi/matcher/raise_exception.rb +0 -39
|
@@ -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
|