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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a3c186895362318fd2c0497d3fb4b124b291a582d37ff16d02cb454f9dd52ca
4
- data.tar.gz: 2fff123c60074a43feb8b81428d1dd61cb0d9e736e223531499113e794c2a2d0
3
+ metadata.gz: 43879fd564f4fe9dfab4116b3e59e452edd5e700dd4cd0f71164965214a17f47
4
+ data.tar.gz: c4f2eda14d387063449b71e42ea80af8a61888a676b986106c40062735c19342
5
5
  SHA512:
6
- metadata.gz: 95e61bb5d94221542d1b3c95e67d5616f90ffbb08a501edc997ed29bf57795a5ab398f2cb6f7edc59a32c9ed3482738246028e3ae35394c84788268fefc4b049
7
- data.tar.gz: bec13c5814a7e007bbff9ae3f47ed3a3b162bc4fe26e5bf941a668fbb9310b7ef9de021dd85fa4fa89d4ef68f1c35bbf7572de0f6bcd799a951c115b6ed6f345
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
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Namespace for the Matchi library.
4
+ #
5
+ # @api public
4
6
  module Matchi
5
7
  end
6
8
 
@@ -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 string matcher
12
- # Matchi::Matcher::BeAnInstanceOf.new(String)
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 = self.class.const_get String(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.0
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-18 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler