matchi 3.3.2 → 4.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 +148 -98
- data/lib/matchi/be.rb +7 -13
- data/lib/matchi/be_a_kind_of.rb +81 -0
- data/lib/matchi/be_an_instance_of.rb +91 -21
- data/lib/matchi/be_within/of.rb +11 -13
- data/lib/matchi/be_within.rb +4 -1
- data/lib/matchi/change/by.rb +11 -14
- data/lib/matchi/change/by_at_least.rb +12 -14
- data/lib/matchi/change/by_at_most.rb +12 -14
- data/lib/matchi/change/from/to.rb +10 -14
- data/lib/matchi/change/from.rb +3 -1
- data/lib/matchi/change/to.rb +10 -14
- data/lib/matchi/change.rb +8 -7
- data/lib/matchi/eq.rb +7 -13
- data/lib/matchi/match.rb +9 -13
- data/lib/matchi/predicate.rb +8 -19
- data/lib/matchi/raise_exception.rb +30 -17
- data/lib/matchi/satisfy.rb +8 -12
- metadata +4 -6
data/lib/matchi/satisfy.rb
CHANGED
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
module Matchi
|
|
4
4
|
# *Satisfy* matcher.
|
|
5
5
|
class Satisfy
|
|
6
|
-
# @return [Proc] A block of code.
|
|
7
|
-
attr_reader :expected
|
|
8
|
-
|
|
9
6
|
# Initialize the matcher with a block.
|
|
10
7
|
#
|
|
11
8
|
# @example
|
|
@@ -15,6 +12,8 @@ module Matchi
|
|
|
15
12
|
#
|
|
16
13
|
# @param block [Proc] A block of code.
|
|
17
14
|
def initialize(&block)
|
|
15
|
+
raise ::ArgumentError, "a block must be provided" unless block_given?
|
|
16
|
+
|
|
18
17
|
@expected = block
|
|
19
18
|
end
|
|
20
19
|
|
|
@@ -24,24 +23,21 @@ module Matchi
|
|
|
24
23
|
# require "matchi/satisfy"
|
|
25
24
|
#
|
|
26
25
|
# matcher = Matchi::Satisfy.new { |value| value == 42 }
|
|
27
|
-
#
|
|
28
|
-
# matcher.expected # => #<Proc:0x00007fbaafc65540>
|
|
29
|
-
# matcher.matches? { 42 } # => true
|
|
26
|
+
# matcher.match? { 42 } # => true
|
|
30
27
|
#
|
|
31
28
|
# @yieldreturn [#object_id] The actual value to compare to the expected
|
|
32
29
|
# one.
|
|
33
30
|
#
|
|
34
31
|
# @return [Boolean] Comparison between actual and expected values.
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
end
|
|
32
|
+
def match?
|
|
33
|
+
raise ::ArgumentError, "a block must be provided" unless block_given?
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
def inspect
|
|
41
|
-
"#{self.class}(&block)"
|
|
35
|
+
@expected.call(yield)
|
|
42
36
|
end
|
|
43
37
|
|
|
44
38
|
# Returns a string representing the matcher.
|
|
39
|
+
#
|
|
40
|
+
# @return [String] a human-readable description of the matcher
|
|
45
41
|
def to_s
|
|
46
42
|
"satisfy &block"
|
|
47
43
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: matchi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cyril Kato
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
10
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: "Collection of expectation matchers for Rubyists \U0001F939"
|
|
14
13
|
email: contact@cyril.email
|
|
@@ -20,6 +19,7 @@ files:
|
|
|
20
19
|
- README.md
|
|
21
20
|
- lib/matchi.rb
|
|
22
21
|
- lib/matchi/be.rb
|
|
22
|
+
- lib/matchi/be_a_kind_of.rb
|
|
23
23
|
- lib/matchi/be_an_instance_of.rb
|
|
24
24
|
- lib/matchi/be_within.rb
|
|
25
25
|
- lib/matchi/be_within/of.rb
|
|
@@ -40,7 +40,6 @@ licenses:
|
|
|
40
40
|
- MIT
|
|
41
41
|
metadata:
|
|
42
42
|
rubygems_mfa_required: 'true'
|
|
43
|
-
post_install_message:
|
|
44
43
|
rdoc_options: []
|
|
45
44
|
require_paths:
|
|
46
45
|
- lib
|
|
@@ -55,8 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
55
54
|
- !ruby/object:Gem::Version
|
|
56
55
|
version: '0'
|
|
57
56
|
requirements: []
|
|
58
|
-
rubygems_version: 3.
|
|
59
|
-
signing_key:
|
|
57
|
+
rubygems_version: 3.6.2
|
|
60
58
|
specification_version: 4
|
|
61
59
|
summary: "Collection of expectation matchers for Rubyists \U0001F939"
|
|
62
60
|
test_files: []
|