matchi 1.0.7 → 2.1.0
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 +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
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.7
|
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
|
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,51 +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
|
-
# Returns a hash of one key-value pair with a key corresponding to the
|
30
|
-
# matcher and a value corresponding to its initialize parameters.
|
31
|
-
#
|
32
|
-
# @example A FooBar matcher serialized into a hash.
|
33
|
-
# matcher = Matchi::Matchers::FooBar::Matcher.new(42)
|
34
|
-
# matcher.to_h # => { FooBar: 42 }
|
35
|
-
#
|
36
|
-
# @return [Hash] A hash of one key-value pair.
|
37
|
-
def to_h
|
38
|
-
{ matcher_name.to_sym => (defined?(@expected) ? Array(@expected) : []) }
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def matcher_name
|
44
|
-
self
|
45
|
-
.class
|
46
|
-
.name
|
47
|
-
.gsub(/\AMatchi::Matchers::/, '')
|
48
|
-
.gsub(/::Matcher\z/, '')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|