matchi 1.0.6 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/README.md +47 -100
  4. data/lib/matchi.rb +1 -1
  5. data/lib/matchi/helper.rb +28 -0
  6. data/lib/matchi/matcher.rb +11 -0
  7. data/lib/matchi/matcher/base.rb +45 -0
  8. data/lib/matchi/matcher/be_false.rb +24 -0
  9. data/lib/matchi/matcher/be_nil.rb +24 -0
  10. data/lib/matchi/matcher/be_true.rb +24 -0
  11. data/lib/matchi/matcher/eql.rb +35 -0
  12. data/lib/matchi/matcher/equal.rb +35 -0
  13. data/lib/matchi/matcher/match.rb +35 -0
  14. data/lib/matchi/matcher/raise_exception.rb +39 -0
  15. metadata +62 -65
  16. data/.gitignore +0 -10
  17. data/.rubocop.yml +0 -1
  18. data/.rubocop_todo.yml +0 -7
  19. data/.travis.yml +0 -28
  20. data/.yardopts +0 -1
  21. data/CODE_OF_CONDUCT.md +0 -13
  22. data/Gemfile +0 -5
  23. data/Rakefile +0 -22
  24. data/VERSION.semver +0 -1
  25. data/bin/console +0 -8
  26. data/bin/setup +0 -6
  27. data/checksum/matchi-0.0.1.gem.sha512 +0 -1
  28. data/checksum/matchi-0.0.2.gem.sha512 +0 -1
  29. data/checksum/matchi-0.0.3.gem.sha512 +0 -1
  30. data/checksum/matchi-0.0.4.gem.sha512 +0 -1
  31. data/checksum/matchi-0.0.5.gem.sha512 +0 -1
  32. data/checksum/matchi-0.0.6.gem.sha512 +0 -1
  33. data/checksum/matchi-0.0.7.gem.sha512 +0 -1
  34. data/checksum/matchi-0.0.8.gem.sha512 +0 -1
  35. data/checksum/matchi-0.0.9.gem.sha512 +0 -1
  36. data/checksum/matchi-0.1.0.gem.sha512 +0 -1
  37. data/checksum/matchi-0.1.1.gem.sha512 +0 -1
  38. data/checksum/matchi-0.1.2.gem.sha512 +0 -1
  39. data/checksum/matchi-1.0.0.gem.sha512 +0 -1
  40. data/checksum/matchi-1.0.1.gem.sha512 +0 -1
  41. data/checksum/matchi-1.0.2.gem.sha512 +0 -1
  42. data/checksum/matchi-1.0.3.gem.sha512 +0 -1
  43. data/checksum/matchi-1.0.4.gem.sha512 +0 -1
  44. data/checksum/matchi-1.0.5.gem.sha512 +0 -1
  45. data/lib/matchi/matchers.rb +0 -11
  46. data/lib/matchi/matchers/be_false.rb +0 -30
  47. data/lib/matchi/matchers/be_nil.rb +0 -30
  48. data/lib/matchi/matchers/be_true.rb +0 -30
  49. data/lib/matchi/matchers/eql.rb +0 -40
  50. data/lib/matchi/matchers/equal.rb +0 -40
  51. data/lib/matchi/matchers/match.rb +0 -40
  52. data/lib/matchi/matchers/raise_exception.rb +0 -48
  53. data/lib/matchi/matchers_base.rb +0 -51
  54. data/matchi.gemspec +0 -24
  55. 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)
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.6
4
+ version: 2.0.2
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-11 00:00:00.000000000 Z
11
+ date: 2021-06-07 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: '2.0'
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: '2.0'
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: '13.0'
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: '13.0'
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,84 +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.17'
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.17'
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.9'
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.9'
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
133
  - lib/matchi.rb
136
- - lib/matchi/matchers.rb
137
- - lib/matchi/matchers/be_false.rb
138
- - lib/matchi/matchers/be_nil.rb
139
- - lib/matchi/matchers/be_true.rb
140
- - lib/matchi/matchers/eql.rb
141
- - lib/matchi/matchers/equal.rb
142
- - lib/matchi/matchers/match.rb
143
- - lib/matchi/matchers/raise_exception.rb
144
- - lib/matchi/matchers_base.rb
145
- - matchi.gemspec
146
- - 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
147
144
  homepage: https://github.com/fixrb/matchi
148
145
  licenses:
149
146
  - MIT
@@ -156,15 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
153
  requirements:
157
154
  - - ">="
158
155
  - !ruby/object:Gem::Version
159
- version: '0'
156
+ version: 2.7.0
160
157
  required_rubygems_version: !ruby/object:Gem::Requirement
161
158
  requirements:
162
159
  - - ">="
163
160
  - !ruby/object:Gem::Version
164
161
  version: '0'
165
162
  requirements: []
166
- rubygems_version: 3.0.6
163
+ rubygems_version: 3.1.6
167
164
  signing_key:
168
165
  specification_version: 4
169
- summary: Collection of matchers.
166
+ summary: "Collection of expectation matchers for Ruby \U0001F939"
170
167
  test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.ruby-version
3
- /.yardoc
4
- /Gemfile.lock
5
- /_yardoc/
6
- /coverage/
7
- /doc/
8
- /pkg/
9
- /spec/reports/
10
- /tmp/
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
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
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]