matchi-fix 1.1.0 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3237654827785d3e875580e063d599bbadb3ac1393bbcb8c7651f18fdd5be90c
4
- data.tar.gz: 00fccfb2f02b690557bfbab0a118ab8016351433a71ec9b736a6cf5cda265fc3
3
+ metadata.gz: 8dda03096cb67cd0a3552246a0e0ae676a346e3483cbfd5fd88eaded3ed9020e
4
+ data.tar.gz: 01b9f0fa9e7dfe4b07c279209f7dfdc36085d1652bf5167b67e6c890d7ff7653
5
5
  SHA512:
6
- metadata.gz: edf896389b7104920f99eb5210d548082e50c654d8809a7a2787e5d00b0b69a9be77dcb52e15941049bbeb5bf0a407ec7ba449aab8f94265ec492b237603583b
7
- data.tar.gz: f0fb10d502c19fe69cb0d73513a8bf11058430b8c90230d89eb82160fd4666247eb562a12a7f6e7cc65f68cca180ca8d2c1b813b69e06383ae09a0ed040e4c43
6
+ metadata.gz: d96d65f1086745d2f8a71aeb007911c93b2f14b7943762c5068f31090185b54af4d1bd96c469762cff956ce13bdcfd99593e0c192e3265515be8d2d9100ceec8
7
+ data.tar.gz: cd08c56a584d6c460d621d4e29de1c9f4ddb1bbc783ef23e04cc56e41bf9cc04ca2e6b0a612933ed067ac2a5981435436057719b1bd0a81b31e31139eb6a1cb3
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2020 Cyril Kato
3
+ Copyright (c) 2015-2021 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,68 +1,84 @@
1
1
  # Matchi::Fix
2
2
 
3
- [![Build Status](https://api.travis-ci.org/fixrb/matchi-fix.svg?branch=master)][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=master)][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
- > A [Fix](https://github.com/fixrb/fix) expectation matcher for [Matchi](https://github.com/fixrb/matchi).
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 'matchi-fix'
16
+ gem "matchi-fix"
17
17
  ```
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
 
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
- require 'matchi/fix'
44
+ matcher = Matchi::Fix.new { it MUST be 42 }
31
45
 
32
- fix = Matchi::Matcher::Fix.new(proc { it { MUST equal 42 } })
33
- fix.matches? { 6 * 7 } # => true
46
+ matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
47
+ matcher.matches? { 42 } # => true
34
48
  ```
35
49
 
36
- ## Contact
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
37
58
 
38
- * Home page: https://github.com/fixrb/matchi-fix
39
- * Bugs/issues: https://github.com/fixrb/matchi-fix/issues
59
+ matcher = Matchi::Fix.new(:Answer)
40
60
 
41
- ## Rubies
61
+ matcher.expected # => #<Fix::Set:0x00007fd96915dc28 ...>
62
+ matcher.matches? { 42 } # => true
63
+ ```
64
+
65
+ ## Contact
42
66
 
43
- * [MRI](https://www.ruby-lang.org/)
44
- * [Rubinius](https://rubinius.com/)
45
- * [JRuby](https://www.jruby.org/)
67
+ * Source code: https://github.com/fixrb/matchi-fix
46
68
 
47
69
  ## Versioning
48
70
 
49
- __Matchi::Fix__ follows [Semantic Versioning 2.0](http://semver.org/).
71
+ __Matchi::Fix__ follows [Semantic Versioning 2.0](https://semver.org/).
50
72
 
51
73
  ## License
52
74
 
53
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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).
54
76
 
55
77
  ***
56
78
 
57
79
  <p>
58
80
  This project is sponsored by:<br />
59
81
  <a href="https://sashite.com/"><img
60
- src="https://github.com/fixrb/matchi-fix/raw/master/img/sashite.png"
82
+ src="https://github.com/fixrb/matchi-fix/raw/main/img/sashite.png"
61
83
  alt="Sashite" /></a>
62
84
  </p>
63
-
64
- [gem]: https://rubygems.org/gems/matchi-fix
65
- [travis]: https://travis-ci.org/fixrb/matchi-fix
66
- [codeclimate]: https://codeclimate.com/github/fixrb/matchi-fix
67
- [inchpages]: https://inch-ci.org/github/fixrb/matchi-fix
68
- [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
- 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 [#test] 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
- require 'matchi/helper'
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] Actual value test on specifications.
68
+ def matches?(&block)
69
+ expected.test(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: 1.1.0
4
+ version: 2.1.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: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2021-07-28 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.beta1
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.beta1
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.0
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.0.0
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: '2.1'
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: '2.1'
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: '13.0'
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: '13.0'
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.79'
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.79'
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.17'
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.17'
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.9'
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.9'
125
- description: A Fix expectation matcher for Matchi.
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: '0'
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.2
181
+ rubygems_version: 3.1.6
156
182
  signing_key:
157
183
  specification_version: 4
158
- summary: Fix expectation matcher.
184
+ summary: Fix specifications matcher.
159
185
  test_files: []
@@ -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'