matchi-fix 1.1.2 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -17
- data/lib/matchi/fix.rb +92 -4
- metadata +9 -10
- data/lib/matchi/matcher/fix.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 547d326ef94fd070ce52ea17e95d5f9a1de1821ffc469370a9dce1271295da4d
|
4
|
+
data.tar.gz: 11d030cc6082d07a41e0eacc81402d657328013874b39df928634ce80f41fd9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daceccfb49e044c04361c08e13d03c5c451fcbb2f6bf9566fe14d9b9ac0cf4f12fae1af73e3563aaa8c2fc0aabd770d8665ecb8cfe1f7d29cf7cbc5771ab5c5f
|
7
|
+
data.tar.gz: 6c6a5dc3779629b8b9783b8df577d3c9a225b58dcbccdcd4efc5ca99f2e8b7248f41f2cbb7915b0b1ae7c9743f0c273a21400deed47198521c8b6d7f64ddab36
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
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) specing matcher compatible with [Matchi](https://github.com/fixrb/matchi).
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -18,19 +18,48 @@ gem "matchi-fix"
|
|
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
|
+
|
29
35
|
```ruby
|
30
36
|
require "matchi/fix"
|
37
|
+
```
|
38
|
+
|
39
|
+
All examples here assume that this has been done.
|
40
|
+
|
41
|
+
### With a block of specifications
|
42
|
+
|
43
|
+
```ruby
|
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,7 +72,7 @@ __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
|
|
@@ -53,9 +82,3 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
53
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,95 @@
|
|
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** specing 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
|
+
@name = name
|
32
|
+
|
33
|
+
@expected = if unnamed?
|
34
|
+
raise ::ArgumentError, "Pass either an argument or a block" unless block
|
35
|
+
|
36
|
+
Fix(&block)
|
37
|
+
else
|
38
|
+
raise ::ArgumentError, "Can't pass both an argument and a block" if block
|
39
|
+
|
40
|
+
::Fix[name]
|
41
|
+
end
|
42
|
+
end
|
6
43
|
|
7
|
-
|
44
|
+
# Boolean comparison between an actual value and the expected specs.
|
45
|
+
#
|
46
|
+
# @example With a block of specifications
|
47
|
+
# require "matchi/fix"
|
48
|
+
#
|
49
|
+
# matcher = Matchi::Fix.new { it MUST be 42 }
|
50
|
+
#
|
51
|
+
# matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
|
52
|
+
# matcher.matches? { 42 } # => true
|
53
|
+
#
|
54
|
+
# @example With the constant name of the specifications
|
55
|
+
# require "matchi/fix"
|
56
|
+
#
|
57
|
+
# Fix :Answer do
|
58
|
+
# it MUST be 42
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# matcher = Matchi::Fix.new(:Answer)
|
62
|
+
#
|
63
|
+
# matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
|
64
|
+
# matcher.matches? { 42 } # => true
|
65
|
+
#
|
66
|
+
# @yieldreturn [#object_id] The value to be compared to the specifications.
|
67
|
+
#
|
68
|
+
# @return [Boolean] Determines whether the test has passed or failed.
|
69
|
+
def matches?(&block)
|
70
|
+
expected.against(log_level: 0, &block)
|
71
|
+
rescue ::SystemExit => e
|
72
|
+
e.success?
|
73
|
+
end
|
74
|
+
|
75
|
+
# A string containing a human-readable representation of the matcher.
|
76
|
+
def inspect
|
77
|
+
"#{self.class}(#{parameter})"
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns a string representing the matcher.
|
81
|
+
def to_s
|
82
|
+
"fix #{parameter}"
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def unnamed?
|
88
|
+
@name.nil?
|
89
|
+
end
|
90
|
+
|
91
|
+
def parameter
|
92
|
+
unnamed? ? "&specs" : ":#{@name}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matchi-fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.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: 2021-
|
11
|
+
date: 2021-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fix
|
@@ -16,28 +16,28 @@ dependencies:
|
|
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
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description: A Fix
|
153
|
+
description: A Fix specing matcher compatible with Matchi.
|
154
154
|
email: contact@cyril.email
|
155
155
|
executables: []
|
156
156
|
extensions: []
|
@@ -159,7 +159,6 @@ files:
|
|
159
159
|
- LICENSE.md
|
160
160
|
- README.md
|
161
161
|
- lib/matchi/fix.rb
|
162
|
-
- lib/matchi/matcher/fix.rb
|
163
162
|
homepage: https://github.com/fixrb/matchi-fix
|
164
163
|
licenses:
|
165
164
|
- MIT
|
@@ -179,8 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
178
|
- !ruby/object:Gem::Version
|
180
179
|
version: '0'
|
181
180
|
requirements: []
|
182
|
-
rubygems_version: 3.1.
|
181
|
+
rubygems_version: 3.1.6
|
183
182
|
signing_key:
|
184
183
|
specification_version: 4
|
185
|
-
summary: Fix
|
184
|
+
summary: Fix specing matcher.
|
186
185
|
test_files: []
|
data/lib/matchi/matcher/fix.rb
DELETED
@@ -1,39 +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
|
-
super()
|
19
|
-
@expected = expected
|
20
|
-
end
|
21
|
-
|
22
|
-
# @example Is 42 matching 6 * 7?
|
23
|
-
# fix = new(proc { it { MUST equal 42 } })
|
24
|
-
# fix.matches? { 6 * 7 } # => true
|
25
|
-
#
|
26
|
-
# @yieldreturn [#object_id] A front object to compare against the spec.
|
27
|
-
#
|
28
|
-
# @return [Boolean] The result of the test: _pass_ or _fail_.
|
29
|
-
def matches?
|
30
|
-
::Fix.describe(yield, &expected)
|
31
|
-
true
|
32
|
-
rescue ::SystemExit => e
|
33
|
-
e.success?
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
require "fix"
|