matchi-fix 1.1.1 → 2.1.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 +43 -20
- data/lib/matchi/fix.rb +87 -4
- metadata +62 -36
- data/lib/matchi/matcher/fix.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40d7531073da5b8a4303fc9c3cae6b9caae05084ab3d9522a8e1f5c5e7f1fe18
|
4
|
+
data.tar.gz: 6886e9b0c8339f4270522436eab1ed9df61a8ad98eea7486733afe4c113d849e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c884e1a53abe424c671cc9a2b9f66584422a045ae92c72009431c41c15bf7e970806ea09e6cbff6e447f362fd24e830bdac58a755d30700809d701d649dfe04
|
7
|
+
data.tar.gz: 6d053108ce76597356f41122a4718432cb78bd508c728ebdfa6f002382ae65f6cab6fbb6f87a8ecc783d821fdce6bc5a44e5ee2fb3a4d80c5667a47493b8b010
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,36 +1,65 @@
|
|
1
1
|
# Matchi::Fix
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
[![
|
3
|
+
[![Version](https://img.shields.io/github/v/tag/fixrb/matchi-fix?label=Version&logo=github)](https://github.com/fixrb/matchi-fix/releases)
|
4
|
+
[![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/fixrb/matchi-fix/main)
|
5
|
+
[![CI](https://github.com/fixrb/matchi-fix/workflows/CI/badge.svg?branch=main)](https://github.com/fixrb/matchi-fix/actions?query=workflow%3Aci+branch%3Amain)
|
6
|
+
[![RuboCop](https://github.com/fixrb/matchi-fix/workflows/RuboCop/badge.svg?branch=main)](https://github.com/fixrb/matchi-fix/actions?query=workflow%3Arubocop+branch%3Amain)
|
7
|
+
[![License](https://img.shields.io/github/license/fixrb/matchi-fix?label=License&logo=github)](https://github.com/fixrb/matchi-fix/raw/main/LICENSE.md)
|
8
8
|
|
9
|
-
> A [Fix](https://github.com/fixrb/fix)
|
9
|
+
> A [Fix](https://github.com/fixrb/fix) specifications matcher compatible with [Matchi](https://github.com/fixrb/matchi).
|
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-fix"
|
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-fix
|
29
|
+
```
|
26
30
|
|
27
31
|
## Usage
|
28
32
|
|
33
|
+
To make __Matchi::Fix__ available:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require "matchi/fix"
|
37
|
+
```
|
38
|
+
|
39
|
+
All examples here assume that this has been done.
|
40
|
+
|
41
|
+
### With a block of specifications
|
42
|
+
|
29
43
|
```ruby
|
30
|
-
|
44
|
+
matcher = Matchi::Fix.new { it MUST be 42 }
|
31
45
|
|
32
|
-
|
33
|
-
|
46
|
+
matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
|
47
|
+
matcher.matches? { 42 } # => true
|
48
|
+
```
|
49
|
+
|
50
|
+
### With the constant name of the specifications
|
51
|
+
|
52
|
+
If specifications have been defined and named, they can be mentioned:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
Fix :Answer do
|
56
|
+
it MUST be 42
|
57
|
+
end
|
58
|
+
|
59
|
+
matcher = Matchi::Fix.new(:Answer)
|
60
|
+
|
61
|
+
matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
|
62
|
+
matcher.matches? { 42 } # => true
|
34
63
|
```
|
35
64
|
|
36
65
|
## Contact
|
@@ -43,19 +72,13 @@ __Matchi::Fix__ follows [Semantic Versioning 2.0](https://semver.org/).
|
|
43
72
|
|
44
73
|
## License
|
45
74
|
|
46
|
-
The gem is available as open source under the terms of the [MIT License](https://
|
75
|
+
The [gem](https://rubygems.org/gems/matchi-fix) is available as open source under the terms of the [MIT License](https://github.com/fixrb/matchi-fix/raw/main/LICENSE.md).
|
47
76
|
|
48
77
|
***
|
49
78
|
|
50
79
|
<p>
|
51
80
|
This project is sponsored by:<br />
|
52
81
|
<a href="https://sashite.com/"><img
|
53
|
-
src="https://github.com/fixrb/matchi-fix/raw/
|
82
|
+
src="https://github.com/fixrb/matchi-fix/raw/main/img/sashite.png"
|
54
83
|
alt="Sashite" /></a>
|
55
84
|
</p>
|
56
|
-
|
57
|
-
[gem]: https://rubygems.org/gems/matchi-fix
|
58
|
-
[travis]: https://travis-ci.org/fixrb/matchi-fix
|
59
|
-
[codeclimate]: https://codeclimate.com/github/fixrb/matchi-fix
|
60
|
-
[inchpages]: https://inch-ci.org/github/fixrb/matchi-fix
|
61
|
-
[rubydoc]: https://rubydoc.info/gems/matchi-fix/frames
|
data/lib/matchi/fix.rb
CHANGED
@@ -1,7 +1,90 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require "fix"
|
4
|
+
|
5
|
+
# Namespace for the Matchi library.
|
6
|
+
module Matchi
|
7
|
+
# **Fix** matcher.
|
8
|
+
class Fix
|
9
|
+
# @return [#against] A set of specifications.
|
10
|
+
attr_reader :expected
|
11
|
+
|
12
|
+
# Initialize the matcher with a behavioral definition.
|
13
|
+
#
|
14
|
+
# @example With a block of specifications
|
15
|
+
# require "matchi/fix"
|
16
|
+
#
|
17
|
+
# Matchi::Fix.new { it MUST be 42 }
|
18
|
+
#
|
19
|
+
# @example With the constant name of the specifications
|
20
|
+
# require "matchi/fix"
|
21
|
+
#
|
22
|
+
# Fix :Answer do
|
23
|
+
# it MUST be 42
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# Matchi::Fix.new(:Answer)
|
27
|
+
#
|
28
|
+
# @param name [String, Symbol] The constant name of the specifications.
|
29
|
+
# @param block [Proc] A block of specifications.
|
30
|
+
def initialize(name = nil, &block)
|
31
|
+
@expected = if name.nil?
|
32
|
+
raise ::ArgumentError, "Pass either an argument or a block" unless block
|
33
|
+
|
34
|
+
Fix(&block)
|
35
|
+
else
|
36
|
+
raise ::ArgumentError, "Can't pass both an argument and a block" if block
|
37
|
+
|
38
|
+
@name = name
|
39
|
+
::Fix[name]
|
40
|
+
end
|
41
|
+
end
|
6
42
|
|
7
|
-
|
43
|
+
# Boolean comparison between an actual value and the expected specs.
|
44
|
+
#
|
45
|
+
# @example With a block of specifications
|
46
|
+
# require "matchi/fix"
|
47
|
+
#
|
48
|
+
# matcher = Matchi::Fix.new { it MUST be 42 }
|
49
|
+
#
|
50
|
+
# matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
|
51
|
+
# matcher.matches? { 42 } # => true
|
52
|
+
#
|
53
|
+
# @example With the constant name of the specifications
|
54
|
+
# require "matchi/fix"
|
55
|
+
#
|
56
|
+
# Fix :Answer do
|
57
|
+
# it MUST be 42
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# matcher = Matchi::Fix.new(:Answer)
|
61
|
+
#
|
62
|
+
# matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
|
63
|
+
# matcher.matches? { 42 } # => true
|
64
|
+
#
|
65
|
+
# @yieldreturn [#object_id] The value to be compared to the specifications.
|
66
|
+
#
|
67
|
+
# @return [Boolean] Determines whether the test has passed or failed.
|
68
|
+
def matches?(&block)
|
69
|
+
expected.against(log_level: 0, &block)
|
70
|
+
rescue ::SystemExit => e
|
71
|
+
e.success?
|
72
|
+
end
|
73
|
+
|
74
|
+
# A string containing a human-readable representation of the matcher.
|
75
|
+
def inspect
|
76
|
+
"#{self.class}(#{parameter})"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns a string representing the matcher.
|
80
|
+
def to_s
|
81
|
+
"fix #{parameter}"
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def parameter
|
87
|
+
@name.nil? ? "&specs" : ":#{@name}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matchi-fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.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-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fix
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0.
|
19
|
+
version: 1.0.0.beta8
|
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: 1.0.0.
|
26
|
+
version: 1.0.0.beta8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: matchi
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2
|
33
|
+
version: '3.2'
|
34
34
|
type: :runtime
|
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: 2
|
40
|
+
version: '3.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop
|
70
|
+
name: rubocop-md
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop-performance
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,37 +94,64 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-thread_safety
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: simplecov
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
|
-
- - "
|
129
|
+
- - ">="
|
102
130
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
131
|
+
version: '0'
|
104
132
|
type: :development
|
105
133
|
prerelease: false
|
106
134
|
version_requirements: !ruby/object:Gem::Requirement
|
107
135
|
requirements:
|
108
|
-
- - "
|
136
|
+
- - ">="
|
109
137
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
138
|
+
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: yard
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
|
-
- - "
|
143
|
+
- - ">="
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
145
|
+
version: '0'
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
|
-
- - "
|
150
|
+
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
125
|
-
description: A Fix
|
126
|
-
email:
|
127
|
-
- contact@cyril.email
|
152
|
+
version: '0'
|
153
|
+
description: A Fix specifications matcher compatible with Matchi.
|
154
|
+
email: contact@cyril.email
|
128
155
|
executables: []
|
129
156
|
extensions: []
|
130
157
|
extra_rdoc_files: []
|
@@ -132,7 +159,6 @@ files:
|
|
132
159
|
- LICENSE.md
|
133
160
|
- README.md
|
134
161
|
- lib/matchi/fix.rb
|
135
|
-
- lib/matchi/matcher/fix.rb
|
136
162
|
homepage: https://github.com/fixrb/matchi-fix
|
137
163
|
licenses:
|
138
164
|
- MIT
|
@@ -145,15 +171,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
171
|
requirements:
|
146
172
|
- - ">="
|
147
173
|
- !ruby/object:Gem::Version
|
148
|
-
version: 2.
|
174
|
+
version: 2.7.0
|
149
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
176
|
requirements:
|
151
177
|
- - ">="
|
152
178
|
- !ruby/object:Gem::Version
|
153
179
|
version: '0'
|
154
180
|
requirements: []
|
155
|
-
rubygems_version: 3.1.
|
181
|
+
rubygems_version: 3.1.6
|
156
182
|
signing_key:
|
157
183
|
specification_version: 4
|
158
|
-
summary: Fix
|
184
|
+
summary: Fix specifications matcher.
|
159
185
|
test_files: []
|
data/lib/matchi/matcher/fix.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'matchi/matcher/base'
|
4
|
-
|
5
|
-
# Namespace for the Matchi library.
|
6
|
-
module Matchi
|
7
|
-
# Collection of matcher classes.
|
8
|
-
module Matcher
|
9
|
-
# **Fix** matcher.
|
10
|
-
class Fix < ::Matchi::Matcher::Base
|
11
|
-
# Initialize the matcher with a spec.
|
12
|
-
#
|
13
|
-
# @example It MUST be equal to 42 matcher.
|
14
|
-
# new(proc { it { MUST equal 42 } })
|
15
|
-
#
|
16
|
-
# @param expected [Proc] A spec.
|
17
|
-
def initialize(expected)
|
18
|
-
@expected = expected
|
19
|
-
end
|
20
|
-
|
21
|
-
# @example Is 42 matching 6 * 7?
|
22
|
-
# fix = new(proc { it { MUST equal 42 } })
|
23
|
-
# fix.matches? { 6 * 7 } # => true
|
24
|
-
#
|
25
|
-
# @yieldreturn [#object_id] A front object to compare against the spec.
|
26
|
-
#
|
27
|
-
# @return [Boolean] The result of the test: _pass_ or _fail_.
|
28
|
-
def matches?
|
29
|
-
::Fix.describe(yield, &expected)
|
30
|
-
true
|
31
|
-
rescue ::SystemExit => e
|
32
|
-
e.success?
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
require 'fix'
|