matchi 1.0.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +50 -97
- 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_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 +61 -63
- 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/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,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).nil?.equal?(false)
|
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:
|
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,83 +66,81 @@ 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
|
-
email:
|
99
|
-
- contact@cyril.email
|
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
133
|
- lib/matchi.rb
|
135
|
-
- lib/matchi/
|
136
|
-
- lib/matchi/
|
137
|
-
- lib/matchi/
|
138
|
-
- lib/matchi/
|
139
|
-
- lib/matchi/
|
140
|
-
- lib/matchi/
|
141
|
-
- lib/matchi/
|
142
|
-
- lib/matchi/
|
143
|
-
- lib/matchi/
|
144
|
-
- matchi.
|
145
|
-
- pkg_checksum
|
134
|
+
- lib/matchi/helper.rb
|
135
|
+
- lib/matchi/matcher.rb
|
136
|
+
- lib/matchi/matcher/base.rb
|
137
|
+
- lib/matchi/matcher/be_false.rb
|
138
|
+
- lib/matchi/matcher/be_nil.rb
|
139
|
+
- lib/matchi/matcher/be_true.rb
|
140
|
+
- lib/matchi/matcher/eql.rb
|
141
|
+
- lib/matchi/matcher/equal.rb
|
142
|
+
- lib/matchi/matcher/match.rb
|
143
|
+
- lib/matchi/matcher/raise_exception.rb
|
146
144
|
homepage: https://github.com/fixrb/matchi
|
147
145
|
licenses:
|
148
146
|
- MIT
|
@@ -155,15 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
153
|
requirements:
|
156
154
|
- - ">="
|
157
155
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
156
|
+
version: 2.7.0
|
159
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
158
|
requirements:
|
161
159
|
- - ">="
|
162
160
|
- !ruby/object:Gem::Version
|
163
161
|
version: '0'
|
164
162
|
requirements: []
|
165
|
-
rubygems_version: 3.
|
163
|
+
rubygems_version: 3.1.4
|
166
164
|
signing_key:
|
167
165
|
specification_version: 4
|
168
|
-
summary: Collection of matchers.
|
166
|
+
summary: Collection of expectation matchers for Ruby.
|
169
167
|
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
|
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]
|