matchi-rspec 1.0.1 → 1.2.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/README.md +27 -19
- data/lib/matchi/matcher/be.rb +6 -2
- data/lib/matchi/matcher/be_instance_of.rb +7 -28
- data/lib/matchi/matcher/eq.rb +6 -2
- data/lib/matchi/rspec.rb +1 -3
- metadata +36 -9
- data/lib/matchi/matcher/be_an_instance_of.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a658fa412a593b6c1e2dbd68a98c401321b7659f6df879ba1792a461b419a57
|
4
|
+
data.tar.gz: d3813724683ee24594a2505807a59a18451ecee68a2d0025e61ed00c6d4fe85f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb024ad43b0f2cd8a7ffb82dc80190a7aea4109ee98b68e23ebfb2e15d3003a3a09b4dc7c1b71a02e4aa35eb12a3b973501d8b1d1cefef80346e2a24c2e243b
|
7
|
+
data.tar.gz: f0c2d5a6166063e1ccc1485e1cf87dde9b194a537b5ada646036596f3619483e1f734c8b2493895f2e78643d477021cc6c377c2823024a6b39b0c5cabf0e8ecf
|
data/README.md
CHANGED
@@ -1,31 +1,45 @@
|
|
1
1
|
# Matchi::Rspec
|
2
2
|
|
3
|
-
[](https://github.com/fixrb/matchi-rspec/releases)
|
4
|
+
[](https://rubydoc.info/github/fixrb/matchi-rspec/main)
|
5
|
+
[](https://github.com/fixrb/matchi-rspec/actions?query=workflow%3Aci+branch%3Amain)
|
6
|
+
[](https://github.com/fixrb/matchi-rspec/actions?query=workflow%3Arubocop+branch%3Amain)
|
7
|
+
[](https://github.com/fixrb/matchi-rspec/raw/main/LICENSE.md)
|
8
8
|
|
9
|
-
> Extend [Matchi](https://github.com/fixrb/matchi) matchers with some
|
9
|
+
> Extend [Matchi](https://github.com/fixrb/matchi) matchers with some RSpec's ones.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem
|
16
|
+
gem "matchi-rspec"
|
17
17
|
```
|
18
18
|
|
19
19
|
And then execute:
|
20
20
|
|
21
|
-
|
21
|
+
```sh
|
22
|
+
bundle
|
23
|
+
```
|
22
24
|
|
23
25
|
Or install it yourself as:
|
24
26
|
|
25
|
-
|
27
|
+
```sh
|
28
|
+
gem install matchi-rspec
|
29
|
+
```
|
26
30
|
|
27
31
|
## Usage
|
28
32
|
|
33
|
+
To make __Matchi::Rspec__ available:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require "matchi/rspec"
|
37
|
+
```
|
38
|
+
|
39
|
+
All examples here assume that this has been done.
|
40
|
+
|
41
|
+
### Built-in matchers
|
42
|
+
|
29
43
|
**Identity** matcher:
|
30
44
|
|
31
45
|
```ruby
|
@@ -37,14 +51,14 @@ be.matches? { 42 } # => true
|
|
37
51
|
|
38
52
|
```ruby
|
39
53
|
be_instance_of = Matchi::Matcher::BeInstanceOf.new(String)
|
40
|
-
be_instance_of.matches? {
|
54
|
+
be_instance_of.matches? { "foo" } # => true
|
41
55
|
```
|
42
56
|
|
43
57
|
**Equivalence** matcher:
|
44
58
|
|
45
59
|
```ruby
|
46
|
-
eq = Matchi::Matcher::Eq.new(
|
47
|
-
eq.matches? {
|
60
|
+
eq = Matchi::Matcher::Eq.new("foo")
|
61
|
+
eq.matches? { "foo" } # => true
|
48
62
|
```
|
49
63
|
|
50
64
|
## Contact
|
@@ -64,12 +78,6 @@ The [gem](https://rubygems.org/gems/matchi-rspec) is available as open source un
|
|
64
78
|
<p>
|
65
79
|
This project is sponsored by:<br />
|
66
80
|
<a href="https://sashite.com/"><img
|
67
|
-
src="https://github.com/fixrb/matchi-rspec/raw/
|
81
|
+
src="https://github.com/fixrb/matchi-rspec/raw/main/img/sashite.png"
|
68
82
|
alt="Sashite" /></a>
|
69
83
|
</p>
|
70
|
-
|
71
|
-
[workflow_rubocop]: https://github.com/fixrb/matchi-rspec/actions?query=workflow%3ARuboCop
|
72
|
-
[gem]: https://rubygems.org/gems/matchi-rspec
|
73
|
-
[travis]: https://travis-ci.org/fixrb/matchi-rspec
|
74
|
-
[inchpages]: https://inch-ci.org/github/fixrb/matchi-rspec
|
75
|
-
[rubydoc]: https://rubydoc.info/gems/matchi-rspec/frames
|
data/lib/matchi/matcher/be.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "matchi/matcher/equal"
|
4
4
|
|
5
5
|
# Namespace for the Matchi library.
|
6
6
|
module Matchi
|
7
7
|
# Collection of matcher classes.
|
8
8
|
module Matcher
|
9
|
-
#
|
9
|
+
# *Identity* matcher.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# equal = Matchi::Matcher::Equal.new(:foo)
|
13
|
+
# equal.matches? { :foo } # => true
|
10
14
|
class Be < ::Matchi::Matcher::Equal
|
11
15
|
end
|
12
16
|
end
|
@@ -1,38 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "matchi/matcher/be_an_instance_of"
|
4
4
|
|
5
5
|
# Namespace for the Matchi library.
|
6
6
|
module Matchi
|
7
7
|
# Collection of matcher classes.
|
8
8
|
module Matcher
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
# @param expected [#object_id] An expected class.
|
17
|
-
def initialize(expected)
|
18
|
-
@expected = expected
|
19
|
-
end
|
20
|
-
|
21
|
-
# @todo For security reasons, instead of comparing actual with expected,
|
22
|
-
# we should compare expected with actual. Using something such as:
|
23
|
-
# `expected.class_of?(actual)`.
|
24
|
-
#
|
25
|
-
# @example Is it an instance of string?
|
26
|
-
# be_instance_of = Matchi::Matcher::BeInstanceOf.new(String)
|
27
|
-
# be_instance_of.matches? { 'foo' } # => true
|
28
|
-
#
|
29
|
-
# @yieldreturn [#instance_of?] the actual value to compare to the
|
30
|
-
# expected one.
|
31
|
-
#
|
32
|
-
# @return [Boolean] Comparison between actual and expected values.
|
33
|
-
def matches?
|
34
|
-
yield.instance_of?(expected)
|
35
|
-
end
|
9
|
+
# *Type/class* matcher.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# be_instance_of = Matchi::Matcher::BeInstanceOf.new(String)
|
13
|
+
# be_instance_of.matches? { "foo" } # => true
|
14
|
+
class BeInstanceOf < ::Matchi::Matcher::BeAnInstanceOf
|
36
15
|
end
|
37
16
|
end
|
38
17
|
end
|
data/lib/matchi/matcher/eq.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "matchi/matcher/eql"
|
4
4
|
|
5
5
|
# Namespace for the Matchi library.
|
6
6
|
module Matchi
|
7
7
|
# Collection of matcher classes.
|
8
8
|
module Matcher
|
9
|
-
#
|
9
|
+
# *Equivalence* matcher.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# eql = Matchi::Matcher::Eql.new("foo")
|
13
|
+
# eql.matches? { "foo" } # => true
|
10
14
|
class Eq < ::Matchi::Matcher::Eql
|
11
15
|
end
|
12
16
|
end
|
data/lib/matchi/rspec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matchi-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matchi
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.1.1
|
20
20
|
type: :runtime
|
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.
|
26
|
+
version: 2.1.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-md
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rubocop-performance
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rake
|
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: rubocop-thread_safety
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,7 +145,6 @@ files:
|
|
117
145
|
- LICENSE.md
|
118
146
|
- README.md
|
119
147
|
- lib/matchi/matcher/be.rb
|
120
|
-
- lib/matchi/matcher/be_an_instance_of.rb
|
121
148
|
- lib/matchi/matcher/be_instance_of.rb
|
122
149
|
- lib/matchi/matcher/eq.rb
|
123
150
|
- lib/matchi/rspec.rb
|
@@ -125,7 +152,7 @@ homepage: https://github.com/fixrb/matchi-rspec
|
|
125
152
|
licenses:
|
126
153
|
- MIT
|
127
154
|
metadata: {}
|
128
|
-
post_install_message:
|
155
|
+
post_install_message:
|
129
156
|
rdoc_options: []
|
130
157
|
require_paths:
|
131
158
|
- lib
|
@@ -140,8 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
167
|
- !ruby/object:Gem::Version
|
141
168
|
version: '0'
|
142
169
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
170
|
+
rubygems_version: 3.1.4
|
171
|
+
signing_key:
|
145
172
|
specification_version: 4
|
146
173
|
summary: Matchi extension gem to provide some RSpec matchers.
|
147
174
|
test_files: []
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'be_instance_of'
|
4
|
-
|
5
|
-
# Namespace for the Matchi library.
|
6
|
-
module Matchi
|
7
|
-
# Collection of matcher classes.
|
8
|
-
module Matcher
|
9
|
-
# **Type/class** matcher.
|
10
|
-
class BeAnInstanceOf < BeInstanceOf
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|