matchi 2.0.0 → 2.0.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/LICENSE.md +1 -1
- data/README.md +25 -45
- data/lib/matchi.rb +1 -1
- data/lib/matchi/helper.rb +1 -1
- data/lib/matchi/matcher.rb +1 -1
- data/lib/matchi/matcher/base.rb +3 -10
- data/lib/matchi/matcher/be_false.rb +1 -1
- data/lib/matchi/matcher/be_nil.rb +1 -1
- data/lib/matchi/matcher/be_true.rb +1 -1
- data/lib/matchi/matcher/eql.rb +2 -1
- data/lib/matchi/matcher/equal.rb +2 -1
- data/lib/matchi/matcher/match.rb +2 -1
- data/lib/matchi/matcher/raise_exception.rb +2 -1
- metadata +50 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9afc0e3e02c4150637f3d1080cf6eacd470ad7dec335417bda0e79ee60ecdea
|
4
|
+
data.tar.gz: d62e283556fc4f9d4a6d93bde1efb518861d482dba734786f00b57a166f4ade6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50d45962387971730773221e8756fa543457ebd1375f7205538040d2fb115eb1fae0784c1e9949794e9c990efc7788fda49ce03f8096918005eae384ed460a13
|
7
|
+
data.tar.gz: 12071d2d5462243d42eac25ca3d70fc5a236cd79b8cbdd20a608e4d2ceeacdbdddbaeeba06f30218c30d1cbf0c6f16279be655eead7a42dcf6b9cecdf1c645cf
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,30 +1,19 @@
|
|
1
1
|
# Matchi
|
2
2
|
|
3
|
-
[][travis]
|
4
4
|
[][codeclimate]
|
5
5
|
[][gem]
|
6
|
-
[][inchpages]
|
7
7
|
[][rubydoc]
|
8
8
|
|
9
9
|
> Collection of expectation matchers for Ruby.
|
10
10
|
|
11
|
-
## Contact
|
12
|
-
|
13
|
-
* Home page: https://github.com/fixrb/matchi
|
14
|
-
* Bugs/issues: https://github.com/fixrb/matchi/issues
|
15
|
-
|
16
|
-
## Rubies
|
17
|
-
|
18
|
-
* [MRI](https://www.ruby-lang.org/)
|
19
|
-
* [Rubinius](https://rubinius.com/)
|
20
|
-
* [JRuby](https://www.jruby.org/)
|
21
|
-
|
22
11
|
## Installation
|
23
12
|
|
24
13
|
Add this line to your application's Gemfile:
|
25
14
|
|
26
15
|
```ruby
|
27
|
-
gem
|
16
|
+
gem "matchi"
|
28
17
|
```
|
29
18
|
|
30
19
|
And then execute:
|
@@ -42,8 +31,8 @@ Or install it yourself as:
|
|
42
31
|
**Equivalence** matcher:
|
43
32
|
|
44
33
|
```ruby
|
45
|
-
eql = Matchi::Matcher::Eql.new(
|
46
|
-
eql.matches? {
|
34
|
+
eql = Matchi::Matcher::Eql.new("foo")
|
35
|
+
eql.matches? { "foo" } # => true
|
47
36
|
```
|
48
37
|
|
49
38
|
**Identity** matcher:
|
@@ -57,7 +46,7 @@ equal.matches? { :foo } # => true
|
|
57
46
|
|
58
47
|
```ruby
|
59
48
|
match = Matchi::Matcher::Match.new(/^foo$/)
|
60
|
-
match.matches? {
|
49
|
+
match.matches? { "foo" } # => true
|
61
50
|
```
|
62
51
|
|
63
52
|
**Expecting errors** matcher:
|
@@ -112,7 +101,7 @@ be_the_answer.matches? { 42 } # => true
|
|
112
101
|
A **Be prime** matcher:
|
113
102
|
|
114
103
|
```ruby
|
115
|
-
require
|
104
|
+
require "prime"
|
116
105
|
|
117
106
|
module Matchi
|
118
107
|
module Matcher
|
@@ -135,6 +124,7 @@ module Matchi
|
|
135
124
|
module Matcher
|
136
125
|
class StartWith < ::Matchi::Matcher::Base
|
137
126
|
def initialize(expected)
|
127
|
+
super()
|
138
128
|
@expected = expected
|
139
129
|
end
|
140
130
|
|
@@ -145,50 +135,40 @@ module Matchi
|
|
145
135
|
end
|
146
136
|
end
|
147
137
|
|
148
|
-
start_with = Matchi::Matcher::StartWith.new(
|
149
|
-
start_with.matches? {
|
138
|
+
start_with = Matchi::Matcher::StartWith.new("foo")
|
139
|
+
start_with.matches? { "foobar" } # => true
|
150
140
|
```
|
151
141
|
|
152
|
-
##
|
142
|
+
## Contact
|
153
143
|
|
154
|
-
|
155
|
-
|
156
|
-
Although these checksums do not prevent malicious users from tampering with a
|
157
|
-
built Gem they can be used for basic integrity verification purposes.
|
144
|
+
* Home page: https://github.com/fixrb/matchi
|
145
|
+
* Bugs/issues: https://github.com/fixrb/matchi/issues
|
158
146
|
|
159
|
-
|
160
|
-
example:
|
147
|
+
## Rubies
|
161
148
|
|
162
|
-
|
163
|
-
|
149
|
+
* [MRI](https://www.ruby-lang.org/)
|
150
|
+
* [Rubinius](https://rubinius.com/)
|
151
|
+
* [JRuby](https://www.jruby.org/)
|
164
152
|
|
165
153
|
## Versioning
|
166
154
|
|
167
155
|
__Matchi__ follows [Semantic Versioning 2.0](https://semver.org/).
|
168
156
|
|
169
|
-
## Contributing
|
170
|
-
|
171
|
-
1. [Fork it](https://github.com/fixrb/matchi/fork)
|
172
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
173
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
174
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
175
|
-
5. Create a new Pull Request
|
176
|
-
|
177
157
|
## License
|
178
158
|
|
179
|
-
|
180
|
-
|
181
|
-
[gem]: https://rubygems.org/gems/matchi
|
182
|
-
[travis]: https://travis-ci.org/fixrb/matchi
|
183
|
-
[codeclimate]: https://codeclimate.com/github/fixrb/matchi
|
184
|
-
[inchpages]: https://inch-ci.org/github/fixrb/matchi
|
185
|
-
[rubydoc]: https://rubydoc.info/gems/matchi/frames
|
159
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
186
160
|
|
187
161
|
***
|
188
162
|
|
189
163
|
<p>
|
190
164
|
This project is sponsored by:<br />
|
191
165
|
<a href="https://sashite.com/"><img
|
192
|
-
src="https://github.com/fixrb/matchi/raw/
|
166
|
+
src="https://github.com/fixrb/matchi/raw/main/img/sashite.png"
|
193
167
|
alt="Sashite" /></a>
|
194
168
|
</p>
|
169
|
+
|
170
|
+
[gem]: https://rubygems.org/gems/matchi
|
171
|
+
[travis]: https://travis-ci.org/fixrb/matchi
|
172
|
+
[codeclimate]: https://codeclimate.com/github/fixrb/matchi
|
173
|
+
[inchpages]: https://inch-ci.org/github/fixrb/matchi
|
174
|
+
[rubydoc]: https://rubydoc.info/gems/matchi/frames
|
data/lib/matchi.rb
CHANGED
data/lib/matchi/helper.rb
CHANGED
data/lib/matchi/matcher.rb
CHANGED
data/lib/matchi/matcher/base.rb
CHANGED
@@ -6,7 +6,7 @@ module Matchi
|
|
6
6
|
class Base
|
7
7
|
# @return [Symbol] A symbol identifying the matcher.
|
8
8
|
def self.to_sym
|
9
|
-
name.
|
9
|
+
name.delete_prefix("Matchi::Matcher::")
|
10
10
|
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
11
11
|
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
12
12
|
.downcase
|
@@ -16,13 +16,6 @@ module Matchi
|
|
16
16
|
# @return [#object_id] Any value to give to the matcher.
|
17
17
|
attr_reader :expected
|
18
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
19
|
# A string containing a human-readable representation of the matcher.
|
27
20
|
#
|
28
21
|
# @return [String] The human-readable representation of the matcher.
|
@@ -34,7 +27,7 @@ module Matchi
|
|
34
27
|
#
|
35
28
|
# @raise [NotImplementedError] Override me inside a matcher.
|
36
29
|
def matches?
|
37
|
-
raise ::NotImplementedError,
|
30
|
+
raise ::NotImplementedError, "matcher MUST respond to this method."
|
38
31
|
end
|
39
32
|
|
40
33
|
# Returns a string representing the matcher.
|
@@ -45,7 +38,7 @@ module Matchi
|
|
45
38
|
#
|
46
39
|
# @return [String] A string representing the matcher.
|
47
40
|
def to_s
|
48
|
-
[self.class.to_sym, expected&.inspect].compact.join(
|
41
|
+
[self.class.to_sym, expected&.inspect].compact.join(" ")
|
49
42
|
end
|
50
43
|
end
|
51
44
|
end
|
data/lib/matchi/matcher/eql.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "base"
|
4
4
|
|
5
5
|
module Matchi
|
6
6
|
module Matcher
|
@@ -13,6 +13,7 @@ module Matchi
|
|
13
13
|
#
|
14
14
|
# @param expected [#eql?] An expected equivalent object.
|
15
15
|
def initialize(expected)
|
16
|
+
super()
|
16
17
|
@expected = expected
|
17
18
|
end
|
18
19
|
|
data/lib/matchi/matcher/equal.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "base"
|
4
4
|
|
5
5
|
module Matchi
|
6
6
|
module Matcher
|
@@ -13,6 +13,7 @@ module Matchi
|
|
13
13
|
#
|
14
14
|
# @param expected [#equal?] An expected object.
|
15
15
|
def initialize(expected)
|
16
|
+
super()
|
16
17
|
@expected = expected
|
17
18
|
end
|
18
19
|
|
data/lib/matchi/matcher/match.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "base"
|
4
4
|
|
5
5
|
module Matchi
|
6
6
|
module Matcher
|
@@ -13,6 +13,7 @@ module Matchi
|
|
13
13
|
#
|
14
14
|
# @param expected [#match] A regular expression.
|
15
15
|
def initialize(expected)
|
16
|
+
super()
|
16
17
|
@expected = expected
|
17
18
|
end
|
18
19
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "base"
|
4
4
|
|
5
5
|
module Matchi
|
6
6
|
module Matcher
|
@@ -13,6 +13,7 @@ module Matchi
|
|
13
13
|
#
|
14
14
|
# @param expected [Exception] The class of the expected exception.
|
15
15
|
def initialize(expected)
|
16
|
+
super()
|
16
17
|
@expected = expected
|
17
18
|
end
|
18
19
|
|
metadata
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matchi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.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:
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
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: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubocop
|
42
|
+
name: rubocop-md
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -66,34 +66,62 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-thread_safety
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: simplecov
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
|
-
- - "
|
101
|
+
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
103
|
+
version: '0'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- - "
|
108
|
+
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
110
|
+
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: yard
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
|
-
- - "
|
115
|
+
- - ">="
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0
|
117
|
+
version: '0'
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
|
-
- - "
|
122
|
+
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0
|
124
|
+
version: '0'
|
97
125
|
description: Collection of expectation matchers for Ruby.
|
98
126
|
email: contact@cyril.email
|
99
127
|
executables: []
|
@@ -125,15 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
153
|
requirements:
|
126
154
|
- - ">="
|
127
155
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
156
|
+
version: 2.7.0
|
129
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
158
|
requirements:
|
131
159
|
- - ">="
|
132
160
|
- !ruby/object:Gem::Version
|
133
161
|
version: '0'
|
134
162
|
requirements: []
|
135
|
-
rubygems_version: 3.1.
|
163
|
+
rubygems_version: 3.1.4
|
136
164
|
signing_key:
|
137
165
|
specification_version: 4
|
138
|
-
summary: Collection of matchers.
|
166
|
+
summary: Collection of expectation matchers for Ruby.
|
139
167
|
test_files: []
|