fix 1.0.0.beta7 → 1.0.0.beta8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -30
- data/lib/fix.rb +2 -2
- data/lib/fix/doc.rb +1 -1
- data/lib/fix/matcher.rb +32 -0
- data/lib/fix/set.rb +4 -9
- data/lib/kernel.rb +3 -3
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d095777befeb78f0e16a218f3f14c0f8b39955265db3848cd26a0afb0b224f3
|
4
|
+
data.tar.gz: d918e8bfd693765450dfb14477f4fe9285642e22a35995446b89acac78662837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c063f295f4d133635d70da15659c613018b51931db21d40c3bedb7db9b442fa756e8ed52833fc49333a816749df99c73956d43c237159f7bd6e728ea36e7791d
|
7
|
+
data.tar.gz: 1e4317121e610e67d0d396571b86e0a82b07c16122cc0be5c2c7ee5514136d9ec349282b643f06fe6d7f7b33cd04584048cf72ec3d8d88345e93f1135e7d5dee
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
* Extract specs from the tests.
|
17
17
|
* Look like English documents.
|
18
|
-
* Be minimalist and easy to
|
18
|
+
* Be minimalist and easy to use.
|
19
19
|
* Run tests quickly.
|
20
20
|
|
21
21
|
## Installation
|
@@ -23,7 +23,7 @@
|
|
23
23
|
Add this line to your application's Gemfile:
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
gem "fix", ">= 1.0.0.
|
26
|
+
gem "fix", ">= 1.0.0.beta8"
|
27
27
|
```
|
28
28
|
|
29
29
|
And then execute:
|
@@ -40,31 +40,12 @@ gem install fix --pre
|
|
40
40
|
|
41
41
|
## Example
|
42
42
|
|
43
|
-
Given
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
# examples/duck/app.rb
|
47
|
-
class Duck
|
48
|
-
def walks
|
49
|
-
"Klop klop!"
|
50
|
-
end
|
51
|
-
|
52
|
-
def swims
|
53
|
-
"Swoosh..."
|
54
|
-
end
|
55
|
-
|
56
|
-
def quacks
|
57
|
-
puts "Quaaaaaack!"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
```
|
61
|
-
|
62
|
-
And this fixed behavior:
|
43
|
+
Given these specifications:
|
63
44
|
|
64
45
|
```ruby
|
65
46
|
# examples/duck/fix.rb
|
66
47
|
|
67
|
-
|
48
|
+
require "fix"
|
68
49
|
|
69
50
|
Fix :Duck do
|
70
51
|
it SHOULD be_an_instance_of :Duck
|
@@ -84,7 +65,26 @@ Fix :Duck do
|
|
84
65
|
end
|
85
66
|
```
|
86
67
|
|
87
|
-
When
|
68
|
+
When we load this `Duck` application:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# examples/duck/app.rb
|
72
|
+
class Duck
|
73
|
+
def walks
|
74
|
+
"Klop klop!"
|
75
|
+
end
|
76
|
+
|
77
|
+
def swims
|
78
|
+
"Swoosh..."
|
79
|
+
end
|
80
|
+
|
81
|
+
def quacks
|
82
|
+
puts "Quaaaaaack!"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
And we run this test:
|
88
88
|
|
89
89
|
```ruby
|
90
90
|
# examples/duck/test.rb
|
@@ -92,20 +92,21 @@ When I run this test:
|
|
92
92
|
require_relative "app"
|
93
93
|
require_relative "fix"
|
94
94
|
|
95
|
-
Fix[:Duck].
|
95
|
+
Fix[:Duck].against { Duck.new }
|
96
96
|
```
|
97
97
|
|
98
98
|
```sh
|
99
99
|
ruby examples/duck/test.rb
|
100
100
|
```
|
101
101
|
|
102
|
-
|
102
|
+
We should see this output:
|
103
103
|
|
104
104
|
```txt
|
105
|
-
Success: expected #<Duck:
|
106
|
-
Success: expected to
|
107
|
-
|
108
|
-
|
105
|
+
(irb):3 Success: expected #<Duck:0x00007fb2fa208708> to be an instance of Duck.
|
106
|
+
(irb):7 Success: expected to eq "Swoosh...".
|
107
|
+
(irb):15 NoMethodError: undefined method `sings' for #<Duck:0x00007fb2fd8371d0>.
|
108
|
+
(irb):6 Success: expected "Swoosh..." to be an instance of String.
|
109
|
+
(irb):11 Success: undefined method `speaks' for #<Duck:0x00007fb2fcc79258>.
|
109
110
|
```
|
110
111
|
|
111
112
|
## Contact
|
data/lib/fix.rb
CHANGED
@@ -11,9 +11,9 @@ module Fix
|
|
11
11
|
# Test a built specification.
|
12
12
|
#
|
13
13
|
# @example Run _Answer_ specification against `42`.
|
14
|
-
# Fix[:Answer].
|
14
|
+
# Fix[:Answer].against(42)
|
15
15
|
#
|
16
|
-
# @param name [String, Symbol] The name of the
|
16
|
+
# @param name [String, Symbol] The constant name of the specifications.
|
17
17
|
#
|
18
18
|
# @return [::Fix::Test] The specification document.
|
19
19
|
def self.[](name)
|
data/lib/fix/doc.rb
CHANGED
data/lib/fix/matcher.rb
CHANGED
@@ -205,5 +205,37 @@ module Fix
|
|
205
205
|
def satisfy(&expected)
|
206
206
|
::Matchi::Satisfy.new(&expected)
|
207
207
|
end
|
208
|
+
|
209
|
+
private
|
210
|
+
|
211
|
+
# Predicate matcher, or default method missing behavior.
|
212
|
+
#
|
213
|
+
# @example Empty predicate matcher
|
214
|
+
# matcher = be_empty
|
215
|
+
# matcher.matches? { [] } # => true
|
216
|
+
# matcher.matches? { [4] } # => false
|
217
|
+
def method_missing(name, *args, **kwargs, &block)
|
218
|
+
return super unless predicate_matcher_name?(name)
|
219
|
+
|
220
|
+
::Matchi::Predicate.new(name, *args, **kwargs, &block)
|
221
|
+
end
|
222
|
+
|
223
|
+
# :nocov:
|
224
|
+
|
225
|
+
# Hook method to return whether the obj can respond to id method or not.
|
226
|
+
def respond_to_missing?(name, include_private = false)
|
227
|
+
predicate_matcher_name?(name) || super
|
228
|
+
end
|
229
|
+
|
230
|
+
# :nocov:
|
231
|
+
|
232
|
+
# Predicate matcher name detector.
|
233
|
+
#
|
234
|
+
# @param name [Array, Symbol] The name of a potential predicate matcher.
|
235
|
+
#
|
236
|
+
# @return [Boolean] Indicates if it is a predicate matcher name or not.
|
237
|
+
def predicate_matcher_name?(name)
|
238
|
+
name.start_with?("be_", "have_") && !name.end_with?("!", "?")
|
239
|
+
end
|
208
240
|
end
|
209
241
|
end
|
data/lib/fix/set.rb
CHANGED
@@ -32,7 +32,7 @@ module Fix
|
|
32
32
|
# @return [Array] A list of specifications.
|
33
33
|
attr_reader :specs
|
34
34
|
|
35
|
-
# @param name [String, Symbol] The name of the
|
35
|
+
# @param name [String, Symbol] The constant name of the specifications.
|
36
36
|
#
|
37
37
|
# @api public
|
38
38
|
def self.load(name)
|
@@ -47,10 +47,10 @@ module Fix
|
|
47
47
|
|
48
48
|
# @param subject [Proc] The block of code to be tested.
|
49
49
|
#
|
50
|
-
# @raise [::SystemExit] The
|
50
|
+
# @raise [::SystemExit] The test set failed!
|
51
51
|
#
|
52
52
|
# @api public
|
53
|
-
def
|
53
|
+
def against(log_level: 5, &subject)
|
54
54
|
randomize!
|
55
55
|
|
56
56
|
specs.each do |environment, location, requirement, challenges|
|
@@ -61,7 +61,7 @@ module Fix
|
|
61
61
|
report!(location, result, log_level: log_level)
|
62
62
|
end
|
63
63
|
|
64
|
-
exit
|
64
|
+
passed? || ::Kernel.exit(false)
|
65
65
|
end
|
66
66
|
|
67
67
|
private
|
@@ -70,11 +70,6 @@ module Fix
|
|
70
70
|
specs.shuffle!
|
71
71
|
end
|
72
72
|
|
73
|
-
# @raise [::SystemExit] The result of the test.
|
74
|
-
def exit!
|
75
|
-
::Kernel.exit(passed?)
|
76
|
-
end
|
77
|
-
|
78
73
|
def failed!
|
79
74
|
@passed = false
|
80
75
|
end
|
data/lib/kernel.rb
CHANGED
@@ -17,12 +17,12 @@ module Kernel
|
|
17
17
|
# end
|
18
18
|
#
|
19
19
|
# # A test
|
20
|
-
# Fix[:Answer].
|
20
|
+
# Fix[:Answer].against { 42 }
|
21
21
|
#
|
22
|
-
# @param name [String, Symbol] The name of the
|
22
|
+
# @param name [String, Symbol] The constant name of the specifications.
|
23
23
|
# @param block [Proc] The specifications.
|
24
24
|
#
|
25
|
-
# @return [#
|
25
|
+
# @return [#against] The collection of specifications.
|
26
26
|
#
|
27
27
|
# @api public
|
28
28
|
def Fix(name = nil, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta8
|
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-07-
|
11
|
+
date: 2021-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: defi
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: 3.3.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: 3.
|
40
|
+
version: 3.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: spectus
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-rspec
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: rubocop-thread_safety
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|