matchi 1.0.7 → 2.1.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/LICENSE.md +1 -1
- data/README.md +59 -103
- 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 +45 -0
- data/lib/matchi/matcher/be_an_instance_of.rb +35 -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 +35 -0
- data/lib/matchi/matcher/equal.rb +35 -0
- data/lib/matchi/matcher/match.rb +35 -0
- data/lib/matchi/matcher/raise_exception.rb +39 -0
- metadata +63 -66
- 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/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 -51
- data/matchi.gemspec +0 -24
- data/pkg_checksum +0 -12
@@ -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,35 @@
|
|
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
|
+
super()
|
17
|
+
@expected = expected
|
18
|
+
end
|
19
|
+
|
20
|
+
# Boolean comparison between the actual value and the expected value.
|
21
|
+
#
|
22
|
+
# @example Is it equivalent to 'foo'?
|
23
|
+
# eql = Matchi::Matcher::Eql.new('foo')
|
24
|
+
# eql.matches? { 'foo' } # => true
|
25
|
+
#
|
26
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
27
|
+
# one.
|
28
|
+
#
|
29
|
+
# @return [Boolean] Comparison between actual and expected values.
|
30
|
+
def matches?(*, **)
|
31
|
+
expected.eql?(yield)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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
|
+
super()
|
17
|
+
@expected = expected
|
18
|
+
end
|
19
|
+
|
20
|
+
# Boolean comparison between the actual value and the expected value.
|
21
|
+
#
|
22
|
+
# @example Is it equal to :foo?
|
23
|
+
# equal = Matchi::Matcher::Equal.new(:foo)
|
24
|
+
# equal.matches? { :foo } # => true
|
25
|
+
#
|
26
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
27
|
+
# one.
|
28
|
+
#
|
29
|
+
# @return [Boolean] Comparison between actual and expected values.
|
30
|
+
def matches?(*, **)
|
31
|
+
expected.equal?(yield)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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
|
+
super()
|
17
|
+
@expected = expected
|
18
|
+
end
|
19
|
+
|
20
|
+
# Boolean comparison between the actual value and the expected value.
|
21
|
+
#
|
22
|
+
# @example Is it matching /^foo$/ regex?
|
23
|
+
# match = Matchi::Matcher::Match.new(/^foo$/)
|
24
|
+
# match.matches? { 'foo' } # => true
|
25
|
+
#
|
26
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
27
|
+
# one.
|
28
|
+
#
|
29
|
+
# @return [Boolean] Comparison between actual and expected values.
|
30
|
+
def matches?(*, **)
|
31
|
+
expected.match?(yield)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,39 @@
|
|
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
|
+
super()
|
17
|
+
@expected = expected
|
18
|
+
end
|
19
|
+
|
20
|
+
# Boolean comparison between the actual value and the expected value.
|
21
|
+
#
|
22
|
+
# @example Is it raising NameError?
|
23
|
+
# matcher = Matchi::Matcher::RaiseException.new(NameError)
|
24
|
+
# matcher.matches? { Boom } # => true
|
25
|
+
#
|
26
|
+
# @yieldreturn [#object_id] The actual value to compare to the expected
|
27
|
+
# one.
|
28
|
+
#
|
29
|
+
# @return [Boolean] Comparison between actual and expected values.
|
30
|
+
def matches?(*, **)
|
31
|
+
yield
|
32
|
+
rescue expected => _e
|
33
|
+
true
|
34
|
+
else
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
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: 1.0
|
4
|
+
version: 2.1.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:
|
11
|
+
date: 2021-06-16 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,85 +66,82 @@ 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
|
97
|
-
description: Collection of expectation matchers for Ruby
|
98
|
-
email:
|
99
|
-
- contact@cyril.email
|
124
|
+
version: '0'
|
125
|
+
description: "Collection of expectation matchers for Ruby \U0001F939"
|
126
|
+
email: contact@cyril.email
|
100
127
|
executables: []
|
101
128
|
extensions: []
|
102
129
|
extra_rdoc_files: []
|
103
130
|
files:
|
104
|
-
- ".gitignore"
|
105
|
-
- ".rubocop.yml"
|
106
|
-
- ".rubocop_todo.yml"
|
107
|
-
- ".travis.yml"
|
108
|
-
- ".yardopts"
|
109
|
-
- CODE_OF_CONDUCT.md
|
110
|
-
- Gemfile
|
111
131
|
- LICENSE.md
|
112
132
|
- 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
133
|
- lib/matchi.rb
|
137
|
-
- lib/matchi/
|
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
|
-
- matchi.
|
147
|
-
-
|
134
|
+
- lib/matchi/helper.rb
|
135
|
+
- lib/matchi/matcher.rb
|
136
|
+
- lib/matchi/matcher/base.rb
|
137
|
+
- lib/matchi/matcher/be_an_instance_of.rb
|
138
|
+
- lib/matchi/matcher/be_false.rb
|
139
|
+
- lib/matchi/matcher/be_nil.rb
|
140
|
+
- lib/matchi/matcher/be_true.rb
|
141
|
+
- lib/matchi/matcher/eql.rb
|
142
|
+
- lib/matchi/matcher/equal.rb
|
143
|
+
- lib/matchi/matcher/match.rb
|
144
|
+
- lib/matchi/matcher/raise_exception.rb
|
148
145
|
homepage: https://github.com/fixrb/matchi
|
149
146
|
licenses:
|
150
147
|
- MIT
|
@@ -157,15 +154,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
154
|
requirements:
|
158
155
|
- - ">="
|
159
156
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
157
|
+
version: 2.7.0
|
161
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
159
|
requirements:
|
163
160
|
- - ">="
|
164
161
|
- !ruby/object:Gem::Version
|
165
162
|
version: '0'
|
166
163
|
requirements: []
|
167
|
-
rubygems_version: 3.
|
164
|
+
rubygems_version: 3.1.6
|
168
165
|
signing_key:
|
169
166
|
specification_version: 4
|
170
|
-
summary: Collection of matchers
|
167
|
+
summary: "Collection of expectation matchers for Ruby \U0001F939"
|
171
168
|
test_files: []
|
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
|