matchi 2.2.0 → 2.2.1
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 +1 -1
- data/lib/matchi.rb +2 -0
- data/lib/matchi/matcher/be_an_instance_of.rb +14 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43879fd564f4fe9dfab4116b3e59e452edd5e700dd4cd0f71164965214a17f47
|
4
|
+
data.tar.gz: c4f2eda14d387063449b71e42ea80af8a61888a676b986106c40062735c19342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd575e3e83c363e04d34ea37ed2f66cb5d7a84dfb63c4b18752347ad105bea9074a0c1489a598a9904295d06e5bf051d5126a0d785231ca9df2762f188db7c1d
|
7
|
+
data.tar.gz: b9e90e939b96c10c27796d58577e2c8db4269233e689bb17e1845526da2c5e83668b1608a478ffdec4321d7852750eec9f21b92bd5f4932d6190a85caa11c491
|
data/README.md
CHANGED
@@ -183,7 +183,7 @@ The set of loaded matcher then becomes accessible via a dynamically generated in
|
|
183
183
|
```ruby
|
184
184
|
matcher = MatcherCollection.new
|
185
185
|
matcher.equal(42).matches? { 44 } # => false
|
186
|
-
matcher.be_an_instance_of(String).matches? { "안녕하세요" } # => true
|
186
|
+
matcher.be_an_instance_of(:String).matches? { "안녕하세요" } # => true
|
187
187
|
```
|
188
188
|
|
189
189
|
## Contact
|
data/lib/matchi.rb
CHANGED
@@ -8,13 +8,18 @@ module Matchi
|
|
8
8
|
class BeAnInstanceOf < ::Matchi::Matcher::Base
|
9
9
|
# Initialize the matcher with an object.
|
10
10
|
#
|
11
|
-
# @example A
|
12
|
-
# Matchi::Matcher::BeAnInstanceOf.new(
|
11
|
+
# @example A duck matcher
|
12
|
+
# Matchi::Matcher::BeAnInstanceOf.new(:Duck)
|
13
13
|
#
|
14
14
|
# @param expected [#to_s] The name of a module.
|
15
15
|
def initialize(expected)
|
16
16
|
super()
|
17
|
-
@expected =
|
17
|
+
@expected = String(expected).to_sym
|
18
|
+
end
|
19
|
+
|
20
|
+
# (see Base#inspect)
|
21
|
+
def inspect
|
22
|
+
"#{self.class}(#{expected})"
|
18
23
|
end
|
19
24
|
|
20
25
|
# Boolean comparison between the class of the actual value and the
|
@@ -34,7 +39,12 @@ module Matchi
|
|
34
39
|
#
|
35
40
|
# @return [Boolean] Comparison between actual and expected values.
|
36
41
|
def matches?(*, **)
|
37
|
-
expected.equal?(yield.class)
|
42
|
+
self.class.const_get(expected).equal?(yield.class)
|
43
|
+
end
|
44
|
+
|
45
|
+
# (see Base#to_s)
|
46
|
+
def to_s
|
47
|
+
"#{self.class.to_sym} #{expected}"
|
38
48
|
end
|
39
49
|
end
|
40
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matchi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|