matchi-fix 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afff23e5efffcaad1a7ffa2ca418dd515b3e471af252b5e81cd0e598a1a316b8
4
- data.tar.gz: 2f19eb9106a4ada078cb276bd01d6efd5cef69b330c69b56765798e72c643055
3
+ metadata.gz: 6ccabebdd23eb7e82cbfd9a24decb4b6e310019699c5b4960357c84be7c2853a
4
+ data.tar.gz: d72041ff77469fa635b4454212760a1185556684eec0369aa6b78d0eb5a1d7f3
5
5
  SHA512:
6
- metadata.gz: b05bbb94e4f9d03b43640b0c4af0bfef16dea618d739d729037b17984dd08b925567ffd3fbfe92d74dcd1685fc8d828f17419a90f34312e8ac554e8e4c8dcdf5
7
- data.tar.gz: 97795b76e5137c2c8239919c552ed4ff92f5d3e123fd593f7afcda1bb8b780c72a5987e57940dcc54bafe185df3fbbb0aac52b41a0dbcefc0a894381f18e3dbf
6
+ metadata.gz: fb77ea77128e0dd6949828125a9dbcb877c8585a4fa0eafbbc4054ab0b612f89cd7ecc2a416d5d82181dafd58b689855ca746102b956f8760f88e25060922cda
7
+ data.tar.gz: a74e2afd1548eecefbd6f9b65b8916158bfc20f6525850fa53acf7036ef77ab4fa7228a3e13f14d053e5d7fefcb80c98144df2dd08a7c16437e21c9875eb819e
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Matchi::Fix
2
2
 
3
- [![Build Status](https://api.travis-ci.org/fixrb/matchi-fix.svg?branch=main)][travis]
4
- [![Code Climate](https://codeclimate.com/github/fixrb/matchi-fix/badges/gpa.svg)][codeclimate]
5
- [![Gem Version](https://badge.fury.io/rb/matchi-fix.svg)][gem]
6
- [![Inline docs](https://inch-ci.org/github/fixrb/matchi-fix.svg?branch=main)][inchpages]
7
- [![Documentation](https://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
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
9
  > A [Fix](https://github.com/fixrb/fix) expectation matcher for [Matchi](https://github.com/fixrb/matchi).
10
10
 
@@ -18,19 +18,25 @@ gem "matchi-fix"
18
18
 
19
19
  And then execute:
20
20
 
21
- $ bundle
21
+ ```sh
22
+ bundle
23
+ ```
22
24
 
23
25
  Or install it yourself as:
24
26
 
25
- $ gem install matchi-fix
27
+ ```sh
28
+ gem install matchi-fix
29
+ ```
26
30
 
27
31
  ## Usage
28
32
 
29
33
  ```ruby
30
34
  require "matchi/fix"
31
35
 
32
- fix = Matchi::Matcher::Fix.new(proc { it { MUST equal 42 } })
33
- fix.matches? { 6 * 7 } # => true
36
+ matcher = Matchi::Fix.new { it MUST be 42 }
37
+
38
+ matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
39
+ matcher.matches? { 42 } # => true
34
40
  ```
35
41
 
36
42
  ## Contact
@@ -43,7 +49,7 @@ __Matchi::Fix__ follows [Semantic Versioning 2.0](https://semver.org/).
43
49
 
44
50
  ## License
45
51
 
46
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+ The [gem](https://rubygems.org/gems/matchi-fix) is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
53
 
48
54
  ***
49
55
 
@@ -53,9 +59,3 @@ The gem is available as open source under the terms of the [MIT License](https:/
53
59
  src="https://github.com/fixrb/matchi-fix/raw/main/img/sashite.png"
54
60
  alt="Sashite" /></a>
55
61
  </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,54 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Dir[File.join File.dirname(__FILE__), "matcher", "*.rb"].each do |fname|
4
- require_relative fname
5
- end
3
+ require "fix"
4
+
5
+ # Namespace for the Matchi library.
6
+ module Matchi
7
+ # **Fix** matcher.
8
+ class Fix
9
+ # @return [Proc] A set of specifications.
10
+ attr_reader :expected
11
+
12
+ # Initialize the matcher with a block of specs.
13
+ #
14
+ # @example
15
+ # require "matchi/fix"
16
+ #
17
+ # Matchi::Fix.new { it MUST be 42 }
18
+ #
19
+ # @param block [Proc] A block of code.
20
+ def initialize(&block)
21
+ @expected = Fix(&block)
22
+ end
6
23
 
7
- require "matchi/helper"
24
+ # Boolean comparison between the actual value and the expected specs.
25
+ #
26
+ # @example
27
+ # require "matchi/fix"
28
+ #
29
+ # matcher = Matchi::Fix.new { it MUST be 42 }
30
+ #
31
+ # matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
32
+ # matcher.matches? { 42 } # => true
33
+ #
34
+ # @yieldreturn [#object_id] The actual value to compare to the expected
35
+ # one.
36
+ #
37
+ # @return [Boolean] Comparison between actual and expected values.
38
+ def matches?(&block)
39
+ expected.test(log_level: 0, &block)
40
+ rescue ::SystemExit => e
41
+ e.success?
42
+ end
43
+
44
+ # A string containing a human-readable representation of the matcher.
45
+ def inspect
46
+ "#{self.class}(&specs)"
47
+ end
48
+
49
+ # Returns a string representing the matcher.
50
+ def to_s
51
+ "fix &specs"
52
+ end
53
+ end
54
+ 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: 1.1.2
4
+ version: 2.0.0
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-05-13 00:00:00.000000000 Z
11
+ date: 2021-07-27 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.beta4
19
+ version: 1.0.0.beta7
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.beta4
26
+ version: 1.0.0.beta7
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.0.1
33
+ version: 3.2.0
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.0.1
40
+ version: 3.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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,7 +178,7 @@ 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.4
181
+ rubygems_version: 3.1.6
183
182
  signing_key:
184
183
  specification_version: 4
185
184
  summary: Fix expectation matcher.
@@ -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"