matchi 1.0.8 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -59
- data/lib/matchi.rb +1 -1
- data/lib/matchi/helper.rb +28 -0
- data/lib/matchi/matcher.rb +11 -0
- data/lib/matchi/matcher/base.rb +52 -0
- data/lib/matchi/matcher/be_false.rb +24 -0
- data/lib/matchi/matcher/be_nil.rb +24 -0
- data/lib/matchi/matcher/be_true.rb +24 -0
- data/lib/matchi/matcher/eql.rb +34 -0
- data/lib/matchi/matcher/equal.rb +34 -0
- data/lib/matchi/matcher/match.rb +34 -0
- data/lib/matchi/matcher/raise_exception.rb +38 -0
- metadata +16 -49
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -7
- data/.travis.yml +0 -28
- data/.yardopts +0 -1
- data/CODE_OF_CONDUCT.md +0 -13
- data/Gemfile +0 -5
- data/Rakefile +0 -22
- data/VERSION.semver +0 -1
- data/bin/console +0 -8
- data/bin/setup +0 -6
- data/checksum/matchi-0.0.1.gem.sha512 +0 -1
- data/checksum/matchi-0.0.2.gem.sha512 +0 -1
- data/checksum/matchi-0.0.3.gem.sha512 +0 -1
- data/checksum/matchi-0.0.4.gem.sha512 +0 -1
- data/checksum/matchi-0.0.5.gem.sha512 +0 -1
- data/checksum/matchi-0.0.6.gem.sha512 +0 -1
- data/checksum/matchi-0.0.7.gem.sha512 +0 -1
- data/checksum/matchi-0.0.8.gem.sha512 +0 -1
- data/checksum/matchi-0.0.9.gem.sha512 +0 -1
- data/checksum/matchi-0.1.0.gem.sha512 +0 -1
- data/checksum/matchi-0.1.1.gem.sha512 +0 -1
- data/checksum/matchi-0.1.2.gem.sha512 +0 -1
- data/checksum/matchi-1.0.0.gem.sha512 +0 -1
- data/checksum/matchi-1.0.1.gem.sha512 +0 -1
- data/checksum/matchi-1.0.2.gem.sha512 +0 -1
- data/checksum/matchi-1.0.3.gem.sha512 +0 -1
- data/checksum/matchi-1.0.4.gem.sha512 +0 -1
- data/checksum/matchi-1.0.5.gem.sha512 +0 -1
- data/checksum/matchi-1.0.6.gem.sha512 +0 -1
- data/checksum/matchi-1.0.7.gem.sha512 +0 -1
- data/lib/matchi/matchers.rb +0 -11
- data/lib/matchi/matchers/be_false.rb +0 -30
- data/lib/matchi/matchers/be_nil.rb +0 -30
- data/lib/matchi/matchers/be_true.rb +0 -30
- data/lib/matchi/matchers/eql.rb +0 -40
- data/lib/matchi/matchers/equal.rb +0 -40
- data/lib/matchi/matchers/match.rb +0 -40
- data/lib/matchi/matchers/raise_exception.rb +0 -44
- data/lib/matchi/matchers_base.rb +0 -62
- data/matchi.gemspec +0 -24
- data/pkg_checksum +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 511594a89eee8989ff8fda9fb3a2b372a794681788a5835a757f4f754a187626
|
4
|
+
data.tar.gz: 974f20880b56d14b292f4c48873c5464c557236356aa46272b58b27a61aea4b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87062a4f55243e204ea9f1eb39c3213d3772e8c5cee2684031c267881b0482b12ef705eeb133b8b3e62bcd328e670c7b55271a8ef31dcb8c72942d7934360d11
|
7
|
+
data.tar.gz: d8dc438ed8523e3ae7b6273ee91e3f91485054195dafc2d466884e6a7a608c03be39e6fc7e7e944dd26223b91fedc8fbabe7695506eb22e167d65ed45b7d5f2a
|
data/README.md
CHANGED
@@ -42,49 +42,49 @@ Or install it yourself as:
|
|
42
42
|
**Equivalence** matcher:
|
43
43
|
|
44
44
|
```ruby
|
45
|
-
eql = Matchi::
|
45
|
+
eql = Matchi::Matcher::Eql.new('foo')
|
46
46
|
eql.matches? { 'foo' } # => true
|
47
47
|
```
|
48
48
|
|
49
49
|
**Identity** matcher:
|
50
50
|
|
51
51
|
```ruby
|
52
|
-
equal = Matchi::
|
52
|
+
equal = Matchi::Matcher::Equal.new(:foo)
|
53
53
|
equal.matches? { :foo } # => true
|
54
54
|
```
|
55
55
|
|
56
56
|
**Regular expressions** matcher:
|
57
57
|
|
58
58
|
```ruby
|
59
|
-
match = Matchi::
|
59
|
+
match = Matchi::Matcher::Match.new(/^foo$/)
|
60
60
|
match.matches? { 'foo' } # => true
|
61
61
|
```
|
62
62
|
|
63
63
|
**Expecting errors** matcher:
|
64
64
|
|
65
65
|
```ruby
|
66
|
-
raise_exception = Matchi::
|
66
|
+
raise_exception = Matchi::Matcher::RaiseException.new(NameError)
|
67
67
|
raise_exception.matches? { Boom } # => true
|
68
68
|
```
|
69
69
|
|
70
70
|
**Truth** matcher:
|
71
71
|
|
72
72
|
```ruby
|
73
|
-
be_true = Matchi::
|
73
|
+
be_true = Matchi::Matcher::BeTrue.new
|
74
74
|
be_true.matches? { true } # => true
|
75
75
|
```
|
76
76
|
|
77
77
|
**Untruth** matcher:
|
78
78
|
|
79
79
|
```ruby
|
80
|
-
be_false = Matchi::
|
80
|
+
be_false = Matchi::Matcher::BeFalse.new
|
81
81
|
be_false.matches? { false } # => true
|
82
82
|
```
|
83
83
|
|
84
84
|
**Nil** matcher:
|
85
85
|
|
86
86
|
```ruby
|
87
|
-
be_nil = Matchi::
|
87
|
+
be_nil = Matchi::Matcher::BeNil.new
|
88
88
|
be_nil.matches? { nil } # => true
|
89
89
|
```
|
90
90
|
|
@@ -96,26 +96,16 @@ A **Be the answer** matcher:
|
|
96
96
|
|
97
97
|
```ruby
|
98
98
|
module Matchi
|
99
|
-
module
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
42.equal? yield
|
104
|
-
end
|
105
|
-
|
106
|
-
def to_s
|
107
|
-
'be_the_answer'
|
108
|
-
end
|
109
|
-
|
110
|
-
def to_h
|
111
|
-
{ BeTheAnswer: [] }
|
112
|
-
end
|
99
|
+
module Matcher
|
100
|
+
class BeTheAnswer < ::Matchi::Matcher::Base
|
101
|
+
def matches?
|
102
|
+
42.equal? yield
|
113
103
|
end
|
114
104
|
end
|
115
105
|
end
|
116
106
|
end
|
117
107
|
|
118
|
-
be_the_answer = Matchi::
|
108
|
+
be_the_answer = Matchi::Matcher::BeTheAnswer.new
|
119
109
|
be_the_answer.matches? { 42 } # => true
|
120
110
|
```
|
121
111
|
|
@@ -125,26 +115,16 @@ A **Be prime** matcher:
|
|
125
115
|
require 'prime'
|
126
116
|
|
127
117
|
module Matchi
|
128
|
-
module
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
Prime.prime? yield
|
133
|
-
end
|
134
|
-
|
135
|
-
def to_s
|
136
|
-
'be_prime'
|
137
|
-
end
|
138
|
-
|
139
|
-
def to_h
|
140
|
-
{ BePrime: [] }
|
141
|
-
end
|
118
|
+
module Matcher
|
119
|
+
class BePrime < ::Matchi::Matcher::Base
|
120
|
+
def matches?
|
121
|
+
Prime.prime? yield
|
142
122
|
end
|
143
123
|
end
|
144
124
|
end
|
145
125
|
end
|
146
126
|
|
147
|
-
be_prime = Matchi::
|
127
|
+
be_prime = Matchi::Matcher::BePrime.new
|
148
128
|
be_prime.matches? { 42 } # => false
|
149
129
|
```
|
150
130
|
|
@@ -152,30 +132,20 @@ A **Start with** matcher:
|
|
152
132
|
|
153
133
|
```ruby
|
154
134
|
module Matchi
|
155
|
-
module
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
!Regexp.new("^#{@expected}").match(yield).nil?
|
164
|
-
end
|
165
|
-
|
166
|
-
def to_s
|
167
|
-
'start_with'
|
168
|
-
end
|
169
|
-
|
170
|
-
def to_h
|
171
|
-
{ StartWith: [@expected] }
|
172
|
-
end
|
135
|
+
module Matcher
|
136
|
+
class StartWith < ::Matchi::Matcher::Base
|
137
|
+
def initialize(expected)
|
138
|
+
@expected = expected
|
139
|
+
end
|
140
|
+
|
141
|
+
def matches?
|
142
|
+
!Regexp.new("^#{expected}").match(yield).nil?
|
173
143
|
end
|
174
144
|
end
|
175
145
|
end
|
176
146
|
end
|
177
147
|
|
178
|
-
start_with = Matchi::
|
148
|
+
start_with = Matchi::Matcher::StartWith.new('foo')
|
179
149
|
start_with.matches? { 'foobar' } # => true
|
180
150
|
```
|
181
151
|
|
@@ -216,6 +186,9 @@ See `LICENSE.md` file.
|
|
216
186
|
|
217
187
|
***
|
218
188
|
|
219
|
-
|
220
|
-
|
221
|
-
|
189
|
+
<p>
|
190
|
+
This project is sponsored by:<br />
|
191
|
+
<a href="https://sashite.com/"><img
|
192
|
+
src="https://github.com/fixrb/matchi/raw/master/img/sashite.png"
|
193
|
+
alt="Sashite" /></a>
|
194
|
+
</p>
|
data/lib/matchi.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'matcher'
|
4
|
+
|
5
|
+
module Matchi
|
6
|
+
# Collection of helper methods.
|
7
|
+
module Helper
|
8
|
+
::Matchi::Matcher.constants.each do |matcher_const|
|
9
|
+
next if matcher_const.equal?(:Base)
|
10
|
+
|
11
|
+
matcher_klass = ::Matchi::Matcher.const_get(matcher_const)
|
12
|
+
|
13
|
+
# Define a method for the given matcher.
|
14
|
+
#
|
15
|
+
# @example Given the `Matchi::Matchers::Equal::Matcher` matcher, its
|
16
|
+
# method would be:
|
17
|
+
#
|
18
|
+
# def equal(expected)
|
19
|
+
# Matchi::Matchers::Equal::Matcher.new(expected)
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# @return [#matches?] The matcher.
|
23
|
+
define_method(matcher_klass.to_sym) do |*args|
|
24
|
+
matcher_klass.new(*args)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Matchi
|
4
|
+
module Matcher
|
5
|
+
# Abstract matcher class.
|
6
|
+
class Base
|
7
|
+
# @return [Symbol] A symbol identifying the matcher.
|
8
|
+
def self.to_sym
|
9
|
+
name.gsub(/\AMatchi::Matcher::/, '')
|
10
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
11
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
12
|
+
.downcase
|
13
|
+
.to_sym
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [#object_id] Any value to give to the matcher.
|
17
|
+
attr_reader :expected
|
18
|
+
|
19
|
+
# Initialize the matcher with the nil expected value by default.
|
20
|
+
#
|
21
|
+
# @param expected [#object_id] Any object. It is `nil` unless present.
|
22
|
+
def initialize(expected = nil)
|
23
|
+
@expected = expected
|
24
|
+
end
|
25
|
+
|
26
|
+
# A string containing a human-readable representation of the matcher.
|
27
|
+
#
|
28
|
+
# @return [String] The human-readable representation of the matcher.
|
29
|
+
def inspect
|
30
|
+
"#{self.class}(#{expected&.inspect})"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Abstract matcher class.
|
34
|
+
#
|
35
|
+
# @raise [NotImplementedError] Override me inside a matcher.
|
36
|
+
def matches?
|
37
|
+
raise ::NotImplementedError, 'matcher MUST respond to this method.'
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns a string representing the matcher.
|
41
|
+
#
|
42
|
+
# @example The readable definition of a FooBar matcher.
|
43
|
+
# matcher = Matchi::Matcher::FooBar.new(42)
|
44
|
+
# matcher.to_s # => "foo_bar 42"
|
45
|
+
#
|
46
|
+
# @return [String] A string representing the matcher.
|
47
|
+
def to_s
|
48
|
+
[self.class.to_sym, expected&.inspect].compact.join(' ')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module Matchi
|
6
|
+
module Matcher
|
7
|
+
# **Untruth** matcher.
|
8
|
+
class BeFalse < ::Matchi::Matcher::Base
|
9
|
+
# Boolean comparison between the actual value and the expected value.
|
10
|
+
#
|
11
|
+
# @example Is it false?
|
12
|
+
# be_false = Matchi::Matcher::BeFalse.new
|
13
|
+
# be_false.matches? { false } # => true
|
14
|
+
#
|
15
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
16
|
+
# one.
|
17
|
+
#
|
18
|
+
# @return [Boolean] Comparison between actual and expected values.
|
19
|
+
def matches?(*, **)
|
20
|
+
false.equal?(yield)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module Matchi
|
6
|
+
module Matcher
|
7
|
+
# **Nil** matcher.
|
8
|
+
class BeNil < ::Matchi::Matcher::Base
|
9
|
+
# Boolean comparison between the actual value and the expected value.
|
10
|
+
#
|
11
|
+
# @example Is it nil?
|
12
|
+
# be_nil = Matchi::Matcher::BeNil.new
|
13
|
+
# be_nil.matches? { nil } # => true
|
14
|
+
#
|
15
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
16
|
+
# one.
|
17
|
+
#
|
18
|
+
# @return [Boolean] Comparison between actual and expected values.
|
19
|
+
def matches?(*, **)
|
20
|
+
nil.equal?(yield)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module Matchi
|
6
|
+
module Matcher
|
7
|
+
# **Truth** matcher.
|
8
|
+
class BeTrue < ::Matchi::Matcher::Base
|
9
|
+
# Boolean comparison between the actual value and the expected value.
|
10
|
+
#
|
11
|
+
# @example Is it true?
|
12
|
+
# be_true = Matchi::Matcher::BeTrue.new
|
13
|
+
# be_true.matches? { true } # => true
|
14
|
+
#
|
15
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
16
|
+
# one.
|
17
|
+
#
|
18
|
+
# @return [Boolean] Comparison between actual and expected values.
|
19
|
+
def matches?(*, **)
|
20
|
+
true.equal?(yield)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module Matchi
|
6
|
+
module Matcher
|
7
|
+
# **Equivalence** matcher.
|
8
|
+
class Eql < ::Matchi::Matcher::Base
|
9
|
+
# Initialize the matcher with an object.
|
10
|
+
#
|
11
|
+
# @example The string 'foo' matcher.
|
12
|
+
# Matchi::Matcher::Eql.new('foo')
|
13
|
+
#
|
14
|
+
# @param expected [#eql?] An expected equivalent object.
|
15
|
+
def initialize(expected)
|
16
|
+
@expected = expected
|
17
|
+
end
|
18
|
+
|
19
|
+
# Boolean comparison between the actual value and the expected value.
|
20
|
+
#
|
21
|
+
# @example Is it equivalent to 'foo'?
|
22
|
+
# eql = Matchi::Matcher::Eql.new('foo')
|
23
|
+
# eql.matches? { 'foo' } # => true
|
24
|
+
#
|
25
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
26
|
+
# one.
|
27
|
+
#
|
28
|
+
# @return [Boolean] Comparison between actual and expected values.
|
29
|
+
def matches?(*, **)
|
30
|
+
expected.eql?(yield)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module Matchi
|
6
|
+
module Matcher
|
7
|
+
# **Identity** matcher.
|
8
|
+
class Equal < ::Matchi::Matcher::Base
|
9
|
+
# Initialize the matcher with an object.
|
10
|
+
#
|
11
|
+
# @example The number 42 matcher.
|
12
|
+
# Matchi::Matcher::Equal.new(42)
|
13
|
+
#
|
14
|
+
# @param expected [#equal?] An expected object.
|
15
|
+
def initialize(expected)
|
16
|
+
@expected = expected
|
17
|
+
end
|
18
|
+
|
19
|
+
# Boolean comparison between the actual value and the expected value.
|
20
|
+
#
|
21
|
+
# @example Is it equal to :foo?
|
22
|
+
# equal = Matchi::Matcher::Equal.new(:foo)
|
23
|
+
# equal.matches? { :foo } # => true
|
24
|
+
#
|
25
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
26
|
+
# one.
|
27
|
+
#
|
28
|
+
# @return [Boolean] Comparison between actual and expected values.
|
29
|
+
def matches?(*, **)
|
30
|
+
expected.equal?(yield)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module Matchi
|
6
|
+
module Matcher
|
7
|
+
# **Regular expressions** matcher.
|
8
|
+
class Match < ::Matchi::Matcher::Base
|
9
|
+
# Initialize the matcher with an instance of Regexp.
|
10
|
+
#
|
11
|
+
# @example Username matcher.
|
12
|
+
# Matchi::Matcher::Match.new(/^[a-z0-9_-]{3,16}$/)
|
13
|
+
#
|
14
|
+
# @param expected [#match] A regular expression.
|
15
|
+
def initialize(expected)
|
16
|
+
@expected = expected
|
17
|
+
end
|
18
|
+
|
19
|
+
# Boolean comparison between the actual value and the expected value.
|
20
|
+
#
|
21
|
+
# @example Is it matching /^foo$/ regex?
|
22
|
+
# match = Matchi::Matcher::Match.new(/^foo$/)
|
23
|
+
# match.matches? { 'foo' } # => true
|
24
|
+
#
|
25
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
26
|
+
# one.
|
27
|
+
#
|
28
|
+
# @return [Boolean] Comparison between actual and expected values.
|
29
|
+
def matches?(*, **)
|
30
|
+
expected.match(yield).nil?.equal?(false)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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
|
+
@expected = expected
|
17
|
+
end
|
18
|
+
|
19
|
+
# Boolean comparison between the actual value and the expected value.
|
20
|
+
#
|
21
|
+
# @example Is it raising NameError?
|
22
|
+
# matcher = Matchi::Matcher::RaiseException.new(NameError)
|
23
|
+
# matcher.matches? { Boom } # => true
|
24
|
+
#
|
25
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
26
|
+
# one.
|
27
|
+
#
|
28
|
+
# @return [Boolean] Comparison between actual and expected values.
|
29
|
+
def matches?(*, **)
|
30
|
+
yield
|
31
|
+
rescue expected => _e
|
32
|
+
true
|
33
|
+
else
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,57 +95,24 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.9'
|
97
97
|
description: Collection of expectation matchers for Ruby.
|
98
|
-
email:
|
99
|
-
- contact@cyril.email
|
98
|
+
email: contact@cyril.email
|
100
99
|
executables: []
|
101
100
|
extensions: []
|
102
101
|
extra_rdoc_files: []
|
103
102
|
files:
|
104
|
-
- ".gitignore"
|
105
|
-
- ".rubocop.yml"
|
106
|
-
- ".rubocop_todo.yml"
|
107
|
-
- ".travis.yml"
|
108
|
-
- ".yardopts"
|
109
|
-
- CODE_OF_CONDUCT.md
|
110
|
-
- Gemfile
|
111
103
|
- LICENSE.md
|
112
104
|
- README.md
|
113
|
-
- Rakefile
|
114
|
-
- VERSION.semver
|
115
|
-
- bin/console
|
116
|
-
- bin/setup
|
117
|
-
- checksum/matchi-0.0.1.gem.sha512
|
118
|
-
- checksum/matchi-0.0.2.gem.sha512
|
119
|
-
- checksum/matchi-0.0.3.gem.sha512
|
120
|
-
- checksum/matchi-0.0.4.gem.sha512
|
121
|
-
- checksum/matchi-0.0.5.gem.sha512
|
122
|
-
- checksum/matchi-0.0.6.gem.sha512
|
123
|
-
- checksum/matchi-0.0.7.gem.sha512
|
124
|
-
- checksum/matchi-0.0.8.gem.sha512
|
125
|
-
- checksum/matchi-0.0.9.gem.sha512
|
126
|
-
- checksum/matchi-0.1.0.gem.sha512
|
127
|
-
- checksum/matchi-0.1.1.gem.sha512
|
128
|
-
- checksum/matchi-0.1.2.gem.sha512
|
129
|
-
- checksum/matchi-1.0.0.gem.sha512
|
130
|
-
- checksum/matchi-1.0.1.gem.sha512
|
131
|
-
- checksum/matchi-1.0.2.gem.sha512
|
132
|
-
- checksum/matchi-1.0.3.gem.sha512
|
133
|
-
- checksum/matchi-1.0.4.gem.sha512
|
134
|
-
- checksum/matchi-1.0.5.gem.sha512
|
135
|
-
- checksum/matchi-1.0.6.gem.sha512
|
136
|
-
- checksum/matchi-1.0.7.gem.sha512
|
137
105
|
- lib/matchi.rb
|
138
|
-
- lib/matchi/
|
139
|
-
- lib/matchi/
|
140
|
-
- lib/matchi/
|
141
|
-
- lib/matchi/
|
142
|
-
- lib/matchi/
|
143
|
-
- lib/matchi/
|
144
|
-
- lib/matchi/
|
145
|
-
- lib/matchi/
|
146
|
-
- lib/matchi/
|
147
|
-
- matchi.
|
148
|
-
- pkg_checksum
|
106
|
+
- lib/matchi/helper.rb
|
107
|
+
- lib/matchi/matcher.rb
|
108
|
+
- lib/matchi/matcher/base.rb
|
109
|
+
- lib/matchi/matcher/be_false.rb
|
110
|
+
- lib/matchi/matcher/be_nil.rb
|
111
|
+
- lib/matchi/matcher/be_true.rb
|
112
|
+
- lib/matchi/matcher/eql.rb
|
113
|
+
- lib/matchi/matcher/equal.rb
|
114
|
+
- lib/matchi/matcher/match.rb
|
115
|
+
- lib/matchi/matcher/raise_exception.rb
|
149
116
|
homepage: https://github.com/fixrb/matchi
|
150
117
|
licenses:
|
151
118
|
- MIT
|
@@ -165,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
132
|
- !ruby/object:Gem::Version
|
166
133
|
version: '0'
|
167
134
|
requirements: []
|
168
|
-
rubygems_version: 3.
|
135
|
+
rubygems_version: 3.1.2
|
169
136
|
signing_key:
|
170
137
|
specification_version: 4
|
171
138
|
summary: Collection of matchers.
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
|
3
|
-
# using RuboCop version 0.76.0.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
data/.travis.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
cache: bundler
|
4
|
-
before_install:
|
5
|
-
- gem install bundler
|
6
|
-
script:
|
7
|
-
- bundle exec rubocop
|
8
|
-
- bundle exec rake test
|
9
|
-
rvm:
|
10
|
-
- 2.3.3
|
11
|
-
- 2.4.0
|
12
|
-
- 2.5.0
|
13
|
-
- 2.6.1
|
14
|
-
- ruby-head
|
15
|
-
- jruby-head
|
16
|
-
- rbx-3
|
17
|
-
matrix:
|
18
|
-
allow_failures:
|
19
|
-
- rvm: ruby-head
|
20
|
-
- rvm: jruby-head
|
21
|
-
- rvm: rbx-3
|
22
|
-
notifications:
|
23
|
-
webhooks:
|
24
|
-
urls:
|
25
|
-
- https://webhooks.gitter.im/e/a44b19cc5cf6db25fa87
|
26
|
-
on_success: change
|
27
|
-
on_failure: always
|
28
|
-
on_start: never
|
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
- README.md
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
-
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
-
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
-
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
-
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
-
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require 'rubocop/rake_task'
|
6
|
-
|
7
|
-
RuboCop::RakeTask.new
|
8
|
-
|
9
|
-
Rake::TestTask.new do |t|
|
10
|
-
t.verbose = true
|
11
|
-
t.warning = true
|
12
|
-
end
|
13
|
-
|
14
|
-
namespace :test do
|
15
|
-
task :coverage do
|
16
|
-
ENV['COVERAGE'] = 'true'
|
17
|
-
Rake::Task['test'].invoke
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
task(:doc_stats) { ruby '-S yard stats' }
|
22
|
-
task default: %i[test doc_stats rubocop]
|
data/VERSION.semver
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.8
|
data/bin/console
DELETED
data/bin/setup
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
548d9f669ded4e622182791a5390aaceae0bf2e557b0864f05a842b0be2c65e10e1fb8499f49a3b9efd0e8eaeb691351b1c670d6316ce49965a99683b1071389
|
@@ -1 +0,0 @@
|
|
1
|
-
d82ab27fc779090bbb6848bd0d621a28934bb2d3404aa2086a81fe7ffb6722af2a5071af8ce2d1e8aeac77d634c1ee0c0cbe1d989b4b0b8a66f490794ceec97e
|
@@ -1 +0,0 @@
|
|
1
|
-
474a7ee1ad41ce13fb56f8935fc774492095397addca63b1c830cdd55c394b301764773dee68e055341ced3971a6a6f79c15cd3c5af6290179027677ebbe1d14
|
@@ -1 +0,0 @@
|
|
1
|
-
7d9b374d6260c62f94f1cfd5b4612eb8c2201060ecf0c85f4221bf5503ee434071abe73514654b7cd28c71e2305f6fe680fc0d5b3202fc56b96b881d6cb08168
|
@@ -1 +0,0 @@
|
|
1
|
-
354f4bfa07bf00f569e09b39b6333ba04ac76cd4ac612e3fadd945c94b710c5ddb670fe7f5ef164c526da85e8a4c38a5b1f1521e86f85ddb6d3bc81399ef0800
|
@@ -1 +0,0 @@
|
|
1
|
-
38d4b6160b00b7151e6b344942674ab724c60b5543eecbaf339ba7b9182be86063df987240af317ae0ef0e6123e29603180095ea2c6e676e264e662386fe03db
|
@@ -1 +0,0 @@
|
|
1
|
-
b2c0cc27a4ea712acf7699e32849f380e8c04609ffbf7e0c21e975fe99d130c221b13d2991c432e797ef0eccd41fd3aaa3d4ca5622f53bb0109aea844f21d74a
|
@@ -1 +0,0 @@
|
|
1
|
-
92577ec2d3b918b7532f18fc451e60d723c454bc14f2aab79ecf03d59318b4bb97ef94db765bd8c7e482bd8feb2a36f8faf95f425b725bba2647853b4a2ef766
|
@@ -1 +0,0 @@
|
|
1
|
-
e09fc68126ef7683b72d98b0ac7aa198b451442ecace0b1c2d0843ca53873abee397ba1aa1e42ced97f03f6c1be18221f856b50a089a87878edc70a4ad90bd61
|
@@ -1 +0,0 @@
|
|
1
|
-
2a4b619499601224f409b41ce482b8e2e1852acd0bba8c9adc2f1333c2a2fdffea4c2573d7dca35d6193ded2018c6f0c0204ed18b58fac8b47abf81d4d214ceb
|
@@ -1 +0,0 @@
|
|
1
|
-
2b7586059766b9686f7f0a2185c211ffedd685386897ce027f7b201a5d4a3242ded950a25a15993bacab7cc44635ce58d9b15c1e91806d74837a95b2060d58aa
|
@@ -1 +0,0 @@
|
|
1
|
-
ddc127123b3b59b5edaa5532d60521c7bec45d1889d84ac282d461928066ef0646ae3cfe312adba700d21da17f33be17efca258533e512f2f63a9eae7085831c
|
@@ -1 +0,0 @@
|
|
1
|
-
92c9c997b1ad0d959e00a309fc44f567e0ae72eb8f59242e185a3faf03aeab871858237c967844b67f62d98c85facfeeb3b470edaf15037d50ff9899923030d6
|
@@ -1 +0,0 @@
|
|
1
|
-
feaba0bb11dec2e0a60cfa712462f9e05c0be105b7eebafe13bc8c1f32072dccfd1b2dae5f6e8cc32213284164d9815112184225e6443825c3ac6382ae8687cc
|
@@ -1 +0,0 @@
|
|
1
|
-
c72967975a9d42287d1d80da893867d5d1aaeb34377f6dcc65cfbdef272d28ec1e7f4caec9df8f198b01b429e8da022585221814e7b494e6fdccb7a39a9fc970
|
@@ -1 +0,0 @@
|
|
1
|
-
3965452f3b41ed817a4263fdd9cd18fc35bf049f5d6624a8ef310c851fda25ff3e1dd8aaad9be3557ac0bfa424dd3be50370e882712d00cf3f307cda2b9d29d5
|
@@ -1 +0,0 @@
|
|
1
|
-
fcd3a51ded233ec0edb84e2c71ea1363bb56f46828ccedf4ad3d26c88a65654561733905d64c235ca259eb2de0b39c9470ba1c9807eed3dbc8a3f3e4c59d183e
|
@@ -1 +0,0 @@
|
|
1
|
-
9fd2c70563171bd7625207d805f4398035588fc4023f3b06da390c980fd4b7602ba7855760be679e6242338db1b7f7754c20b73c8b3392bb65e969576e4bbef5
|
@@ -1 +0,0 @@
|
|
1
|
-
fc17f33e6ea2f3b93ded8cb855873825d39355360a205b38f3db588a724719e874971a62ed4de5a29b151a2edc0e9719b4bd0d3a2015e2bea9615b4dabb29cf1
|
@@ -1 +0,0 @@
|
|
1
|
-
f16e29583a3311ffad06a27bed7fe670ee694ad45217271708b58f479bf7b677acf42b13c8ff94d397b5f6e74aced22d3bbac2679dc66cb357b28cae11d80be4
|
data/lib/matchi/matchers.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join('..', 'matchers_base') unless
|
4
|
-
defined?(::Matchi::MatchersBase)
|
5
|
-
|
6
|
-
module Matchi
|
7
|
-
module Matchers
|
8
|
-
# **Untruth** matcher.
|
9
|
-
module BeFalse
|
10
|
-
# The matcher.
|
11
|
-
class Matcher
|
12
|
-
include MatchersBase
|
13
|
-
|
14
|
-
# Boolean comparison between the actual value and the expected value.
|
15
|
-
#
|
16
|
-
# @example Is it false?
|
17
|
-
# be_false = Matchi::Matchers::BeFalse::Matcher.new
|
18
|
-
# be_false.matches? { false } # => true
|
19
|
-
#
|
20
|
-
# @yieldreturn [#object_id] The actual value to compare to the expected
|
21
|
-
# one.
|
22
|
-
#
|
23
|
-
# @return [Boolean] Comparison between actual and expected values.
|
24
|
-
def matches?(*, **)
|
25
|
-
false.equal?(yield)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join('..', 'matchers_base') unless
|
4
|
-
defined?(::Matchi::MatchersBase)
|
5
|
-
|
6
|
-
module Matchi
|
7
|
-
module Matchers
|
8
|
-
# **Nil** matcher.
|
9
|
-
module BeNil
|
10
|
-
# The matcher.
|
11
|
-
class Matcher
|
12
|
-
include MatchersBase
|
13
|
-
|
14
|
-
# Boolean comparison between the actual value and the expected value.
|
15
|
-
#
|
16
|
-
# @example Is it nil?
|
17
|
-
# be_nil = Matchi::Matchers::BeNil::Matcher.new
|
18
|
-
# be_nil.matches? { nil } # => true
|
19
|
-
#
|
20
|
-
# @yieldreturn [#object_id] The actual value to compare to the expected
|
21
|
-
# one.
|
22
|
-
#
|
23
|
-
# @return [Boolean] Comparison between actual and expected values.
|
24
|
-
def matches?(*, **)
|
25
|
-
nil.equal?(yield)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join('..', 'matchers_base') unless
|
4
|
-
defined?(::Matchi::MatchersBase)
|
5
|
-
|
6
|
-
module Matchi
|
7
|
-
module Matchers
|
8
|
-
# **Truth** matcher.
|
9
|
-
module BeTrue
|
10
|
-
# The matcher.
|
11
|
-
class Matcher
|
12
|
-
include MatchersBase
|
13
|
-
|
14
|
-
# Boolean comparison between the actual value and the expected value.
|
15
|
-
#
|
16
|
-
# @example Is it true?
|
17
|
-
# be_true = Matchi::Matchers::BeTrue::Matcher.new
|
18
|
-
# be_true.matches? { true } # => true
|
19
|
-
#
|
20
|
-
# @yieldreturn [#object_id] The actual value to compare to the expected
|
21
|
-
# one.
|
22
|
-
#
|
23
|
-
# @return [Boolean] Comparison between actual and expected values.
|
24
|
-
def matches?(*, **)
|
25
|
-
true.equal?(yield)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/matchi/matchers/eql.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join('..', 'matchers_base') unless
|
4
|
-
defined?(::Matchi::MatchersBase)
|
5
|
-
|
6
|
-
module Matchi
|
7
|
-
module Matchers
|
8
|
-
# **Equivalence** matcher.
|
9
|
-
module Eql
|
10
|
-
# The matcher.
|
11
|
-
class Matcher
|
12
|
-
include MatchersBase
|
13
|
-
|
14
|
-
# Initialize the matcher with an object.
|
15
|
-
#
|
16
|
-
# @example The string 'foo' matcher.
|
17
|
-
# Matchi::Matchers::Eql::Matcher.new('foo')
|
18
|
-
#
|
19
|
-
# @param expected [#eql?] An expected equivalent object.
|
20
|
-
def initialize(expected)
|
21
|
-
@expected = expected
|
22
|
-
end
|
23
|
-
|
24
|
-
# Boolean comparison between the actual value and the expected value.
|
25
|
-
#
|
26
|
-
# @example Is it equivalent to 'foo'?
|
27
|
-
# eql = Matchi::Matchers::Eql::Matcher.new('foo')
|
28
|
-
# eql.matches? { 'foo' } # => true
|
29
|
-
#
|
30
|
-
# @yieldreturn [#object_id] The actual value to compare to the expected
|
31
|
-
# one.
|
32
|
-
#
|
33
|
-
# @return [Boolean] Comparison between actual and expected values.
|
34
|
-
def matches?(*, **)
|
35
|
-
@expected.eql?(yield)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join('..', 'matchers_base') unless
|
4
|
-
defined?(::Matchi::MatchersBase)
|
5
|
-
|
6
|
-
module Matchi
|
7
|
-
module Matchers
|
8
|
-
# **Identity** matcher.
|
9
|
-
module Equal
|
10
|
-
# The matcher.
|
11
|
-
class Matcher
|
12
|
-
include MatchersBase
|
13
|
-
|
14
|
-
# Initialize the matcher with an object.
|
15
|
-
#
|
16
|
-
# @example The number 42 matcher.
|
17
|
-
# Matchi::Matchers::Equal::Matcher.new(42)
|
18
|
-
#
|
19
|
-
# @param expected [#equal?] An expected object.
|
20
|
-
def initialize(expected)
|
21
|
-
@expected = expected
|
22
|
-
end
|
23
|
-
|
24
|
-
# Boolean comparison between the actual value and the expected value.
|
25
|
-
#
|
26
|
-
# @example Is it equal to :foo?
|
27
|
-
# equal = Matchi::Matchers::Equal::Matcher.new(:foo)
|
28
|
-
# equal.matches? { :foo } # => true
|
29
|
-
#
|
30
|
-
# @yieldreturn [#object_id] The actual value to compare to the expected
|
31
|
-
# one.
|
32
|
-
#
|
33
|
-
# @return [Boolean] Comparison between actual and expected values.
|
34
|
-
def matches?(*, **)
|
35
|
-
@expected.equal?(yield)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join('..', 'matchers_base') unless
|
4
|
-
defined?(::Matchi::MatchersBase)
|
5
|
-
|
6
|
-
module Matchi
|
7
|
-
module Matchers
|
8
|
-
# **Regular expressions** matcher.
|
9
|
-
module Match
|
10
|
-
# The matcher.
|
11
|
-
class Matcher
|
12
|
-
include MatchersBase
|
13
|
-
|
14
|
-
# Initialize the matcher with an instance of Regexp.
|
15
|
-
#
|
16
|
-
# @example Username matcher.
|
17
|
-
# Matchi::Matchers::Match::Matcher.new(/^[a-z0-9_-]{3,16}$/)
|
18
|
-
#
|
19
|
-
# @param expected [#match] A regular expression.
|
20
|
-
def initialize(expected)
|
21
|
-
@expected = expected
|
22
|
-
end
|
23
|
-
|
24
|
-
# Boolean comparison between the actual value and the expected value.
|
25
|
-
#
|
26
|
-
# @example Is it matching /^foo$/ regex?
|
27
|
-
# match = Matchi::Matchers::Match::Matcher.new(/^foo$/)
|
28
|
-
# match.matches? { 'foo' } # => true
|
29
|
-
#
|
30
|
-
# @yieldreturn [#object_id] The actual value to compare to the expected
|
31
|
-
# one.
|
32
|
-
#
|
33
|
-
# @return [Boolean] Comparison between actual and expected values.
|
34
|
-
def matches?(*, **)
|
35
|
-
@expected.match(yield).nil?.equal?(false)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative File.join('..', 'matchers_base') unless
|
4
|
-
defined?(::Matchi::MatchersBase)
|
5
|
-
|
6
|
-
module Matchi
|
7
|
-
module Matchers
|
8
|
-
# **Expecting errors** matcher.
|
9
|
-
module RaiseException
|
10
|
-
# The matcher.
|
11
|
-
class Matcher
|
12
|
-
include MatchersBase
|
13
|
-
|
14
|
-
# Initialize the matcher with a descendant of class Exception.
|
15
|
-
#
|
16
|
-
# @example Divided by 0 matcher.
|
17
|
-
# Matchi::Matchers::RaiseException::Matcher.new(ZeroDivisionError)
|
18
|
-
#
|
19
|
-
# @param expected [.exception] The class of the expected exception.
|
20
|
-
def initialize(expected)
|
21
|
-
@expected = expected
|
22
|
-
end
|
23
|
-
|
24
|
-
# Boolean comparison between the actual value and the expected value.
|
25
|
-
#
|
26
|
-
# @example Is it raising NameError?
|
27
|
-
# matcher = Matchi::Matchers::RaiseException::Matcher.new(NameError)
|
28
|
-
# matcher.matches? { Boom } # => true
|
29
|
-
#
|
30
|
-
# @yieldreturn [#object_id] The actual value to compare to the expected
|
31
|
-
# one.
|
32
|
-
#
|
33
|
-
# @return [Boolean] Comparison between actual and expected values.
|
34
|
-
def matches?(*, **)
|
35
|
-
yield
|
36
|
-
rescue @expected => _e
|
37
|
-
true
|
38
|
-
else
|
39
|
-
false
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/matchi/matchers_base.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Matchi
|
4
|
-
# Common matcher methods.
|
5
|
-
module MatchersBase
|
6
|
-
# Abstract matcher class.
|
7
|
-
#
|
8
|
-
# @raise [NotImplementedError] Override me inside a Matcher subclass please.
|
9
|
-
def matches?
|
10
|
-
raise ::NotImplementedError, 'matcher MUST respond to `matches?` method.'
|
11
|
-
end
|
12
|
-
|
13
|
-
# Returns a string representing the matcher.
|
14
|
-
#
|
15
|
-
# @example The readable definition of a FooBar matcher.
|
16
|
-
# matcher = Matchi::Matchers::FooBar::Matcher.new(42)
|
17
|
-
# matcher.to_s # => "foo_bar 42"
|
18
|
-
#
|
19
|
-
# @return [String] A string representing the matcher.
|
20
|
-
def to_s
|
21
|
-
s = matcher_name
|
22
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
23
|
-
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
24
|
-
.downcase
|
25
|
-
|
26
|
-
defined?(@expected) ? [s, @expected.inspect].join(' ') : s
|
27
|
-
end
|
28
|
-
|
29
|
-
# A string containing a human-readable representation of the matcher.
|
30
|
-
#
|
31
|
-
# @api public
|
32
|
-
#
|
33
|
-
# @return [String] The human-readable representation of the matcher.
|
34
|
-
def inspect
|
35
|
-
expected_inspect = @expected.inspect if defined?(@expected)
|
36
|
-
|
37
|
-
"#{matcher_name}(#{expected_inspect})"
|
38
|
-
end
|
39
|
-
|
40
|
-
# Returns a hash of one key-value pair with a key corresponding to the
|
41
|
-
# matcher and a value corresponding to its initialize parameters.
|
42
|
-
#
|
43
|
-
# @example A FooBar matcher serialized into a hash.
|
44
|
-
# matcher = Matchi::Matchers::FooBar::Matcher.new(42)
|
45
|
-
# matcher.to_h # => { FooBar: 42 }
|
46
|
-
#
|
47
|
-
# @return [Hash] A hash of one key-value pair.
|
48
|
-
def to_h
|
49
|
-
{ matcher_name.to_sym => (defined?(@expected) ? Array(@expected) : []) }
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def matcher_name
|
55
|
-
self
|
56
|
-
.class
|
57
|
-
.name
|
58
|
-
.gsub(/\AMatchi::Matchers::/, '')
|
59
|
-
.gsub(/::Matcher\z/, '')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/matchi.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = 'matchi'
|
5
|
-
spec.version = File.read('VERSION.semver').chomp
|
6
|
-
spec.authors = ['Cyril Kato']
|
7
|
-
spec.email = ['contact@cyril.email']
|
8
|
-
spec.summary = 'Collection of matchers.'
|
9
|
-
spec.description = 'Collection of expectation matchers for Ruby.'
|
10
|
-
spec.homepage = 'https://github.com/fixrb/matchi'
|
11
|
-
spec.license = 'MIT'
|
12
|
-
|
13
|
-
spec.files =
|
14
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
|
15
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
|
-
spec.require_paths = ['lib']
|
17
|
-
|
18
|
-
spec.add_development_dependency 'bundler', '~> 2.0'
|
19
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
20
|
-
spec.add_development_dependency 'rubocop'
|
21
|
-
spec.add_development_dependency 'rubocop-performance'
|
22
|
-
spec.add_development_dependency 'simplecov', '~> 0.17'
|
23
|
-
spec.add_development_dependency 'yard', '~> 0.9'
|
24
|
-
end
|
data/pkg_checksum
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'digest/sha2'
|
5
|
-
|
6
|
-
gemname = :matchi
|
7
|
-
ARGV[0] = File.read('VERSION.semver').chomp if ARGV[0].nil?
|
8
|
-
built_gem_path = "pkg/#{gemname}-#{ARGV[0]}.gem"
|
9
|
-
checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
|
10
|
-
checksum_path = "checksum/#{gemname}-#{ARGV[0]}.gem.sha512"
|
11
|
-
|
12
|
-
File.open(checksum_path, 'w') { |f| f.write("#{checksum}\n") }
|