fix 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -4
- data/README.md +18 -27
- data/VERSION.semver +1 -1
- data/example/duck/README.md +0 -1
- data/example/duck/test.rb +32 -2
- data/lib/fix.rb +1 -1
- data/lib/fix/{expectation_set.rb → db.rb} +5 -2
- data/lib/fix/dsl.rb +7 -0
- data/lib/fix/expectation.rb +12 -3
- data/lib/fix/expectation_high.rb +2 -2
- data/lib/fix/expectation_low.rb +1 -1
- data/lib/fix/expectation_medium.rb +1 -1
- data/lib/fix/helper/it_helper.rb +4 -4
- data/lib/fix/helper/its_helper.rb +13 -4
- data/lib/fix/helper/let_accessor_helper.rb +2 -2
- data/lib/fix/helper/let_reader_helper.rb +1 -1
- data/lib/fix/helper/let_writer_helper.rb +3 -1
- data/lib/fix/helper/on_helper.rb +10 -1
- data/lib/fix/helper/requirement_helper.rb +6 -6
- data/lib/fix/it.rb +4 -3
- data/lib/fix/its.rb +4 -3
- data/lib/fix/missing_subject_error.rb +7 -0
- data/lib/fix/on.rb +4 -3
- data/lib/fix/test.rb +7 -9
- metadata +4 -5
- metadata.gz.sig +0 -0
- data/example/duck/spec.rb +0 -31
- data/lib/fix/spec.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31c51a42cf1817594ac8acded17fe569bca8fbc5
|
4
|
+
data.tar.gz: 9e4fd8700a2c41a7420ed048b520fb802e485c34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d95d05cc3ba74fb316d61df20fd2519b52c3a3b52f3c8025d9cfe96c12fd05b6ba120118ab1d9ef09becb878c09eb703b6d69bfca3a3d5d5650d013027dfd53c
|
7
|
+
data.tar.gz: d1ee4975f7eac819051d464a83dfee7b617bf9cdd8bd6f26b68fb5210d0a7d4f34e16692e1f46402e4c98fc30181b8ec121986a82ddaed28abf1402c703936f3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,4 +1 @@
|
|
1
|
-
|
2
|
-
F;ߤhA�j������2f���sX4�`�4ժ,p8�E4l��SO���d�aټ"e�u���¿�%�����P���3�e
|
3
|
-
��ـ��D1ܴ&�ί?̮$[f�U�E��Gm2Ùk�=�9E���Qy�&��I
|
4
|
-
����4������~����
|
1
|
+
F!��c3Va�M�[k�X�;{�|��m�����"q�e��Q�Gݐ���iJ㹡��Bd�s�9m�P��@UOГc�����C7�^�A`��@y�T��A��(�"#�j�$�X��"���Н#~Ĉ��,4&v�Q�Hܔ|��,Q-]�α%��Z��z@��BCG ������-��0���[;R�xAV�;�ǦI��Xj�^�a-�#�UH��2�$'�q$�T��r�hƄ���t�!x[��;1�%x�8G��
|
data/README.md
CHANGED
@@ -76,47 +76,38 @@ class Duck
|
|
76
76
|
end
|
77
77
|
|
78
78
|
@bird = Duck.new
|
79
|
-
```
|
80
|
-
|
81
|
-
> When I see a `#<Duck:0x007f96b285d6d0>` that ...
|
82
79
|
|
83
|
-
```ruby
|
84
80
|
require 'fix'
|
85
81
|
|
86
|
-
|
87
|
-
on :swims do
|
88
|
-
it { SHALL eql: "Swoosh..." }
|
89
|
-
it { MAY capture_stdout: " ...\n" }
|
90
|
-
end
|
82
|
+
extend Fix::DSL
|
91
83
|
|
92
|
-
|
93
|
-
it { SHOULD capture_stdout: "Quaaaaaack!\n" }
|
94
|
-
end
|
84
|
+
subject @bird
|
95
85
|
|
96
|
-
|
97
|
-
|
98
|
-
|
86
|
+
on :swims do
|
87
|
+
it { SHALL eql: "Swoosh..." }
|
88
|
+
it { MAY capture_stdout: " ...\n" }
|
89
|
+
end
|
99
90
|
|
100
|
-
|
101
|
-
|
102
|
-
|
91
|
+
on :quacks do
|
92
|
+
it { SHOULD capture_stdout: "Quaaaaaack!\n" }
|
93
|
+
end
|
94
|
+
|
95
|
+
on :speaks do
|
96
|
+
it { MUST raise_exception: NoMethodError }
|
103
97
|
end
|
104
98
|
|
105
|
-
|
106
|
-
|
107
|
-
else warn 'WAT?'
|
99
|
+
on :sings do
|
100
|
+
it { MAY eql: "♪... ♫..." }
|
108
101
|
end
|
109
102
|
```
|
110
103
|
|
111
104
|
```bash
|
112
|
-
ruby
|
113
|
-
# Run options: --seed 241686681690348892099960370893524466040
|
114
|
-
# .....
|
115
|
-
# Finished in 0.001033 seconds.
|
116
|
-
# 5 tests, 0 failures, 0 errors
|
105
|
+
ruby duck_spec.rb
|
117
106
|
```
|
118
107
|
|
119
|
-
|
108
|
+
.....
|
109
|
+
Finished in 0.001033 seconds.
|
110
|
+
5 tests, 0 failures, 0 errors
|
120
111
|
|
121
112
|
## Contributing
|
122
113
|
|
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/example/duck/README.md
CHANGED
data/example/duck/test.rb
CHANGED
@@ -1,6 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
|
3
3
|
require_relative 'app'
|
4
|
-
|
4
|
+
require 'fix'
|
5
5
|
|
6
|
-
|
6
|
+
extend Fix::DSL
|
7
|
+
|
8
|
+
subject @app
|
9
|
+
|
10
|
+
let(:word) { "Quaaa" }
|
11
|
+
|
12
|
+
on :swims do
|
13
|
+
it { MUST capture_stderr: " ...\n" }
|
14
|
+
end
|
15
|
+
|
16
|
+
on :quacks do
|
17
|
+
let(:quaaaaaack) { word + "aaack!\n" }
|
18
|
+
|
19
|
+
it { SHOULD capture_stdout: quaaaaaack }
|
20
|
+
end
|
21
|
+
|
22
|
+
its(:speaks) { MUST raise_exception: NoMethodError }
|
23
|
+
|
24
|
+
on :sings do
|
25
|
+
it { MAY eql: "♪... ♫..." }
|
26
|
+
end
|
27
|
+
|
28
|
+
on :walks do
|
29
|
+
let(:walks) { "#{word}... Klop klop!" }
|
30
|
+
|
31
|
+
it { MUST eql: walks }
|
32
|
+
|
33
|
+
on :split, '... ' do
|
34
|
+
its(:last) { MUST eql: "Klop klop!" }
|
35
|
+
end
|
36
|
+
end
|
data/lib/fix.rb
CHANGED
data/lib/fix/dsl.rb
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
require_relative File.join 'helper', 'its_helper'
|
2
2
|
require_relative File.join 'helper', 'on_helper'
|
3
|
+
require_relative 'test'
|
3
4
|
|
4
5
|
module Fix
|
5
6
|
module DSL
|
6
7
|
include Helper::ItsHelper
|
7
8
|
include Helper::LetWriterHelper
|
8
9
|
include Helper::OnHelper
|
10
|
+
|
11
|
+
def subject object
|
12
|
+
@object = object
|
13
|
+
end
|
14
|
+
|
15
|
+
at_exit { Test.new }
|
9
16
|
end
|
10
17
|
end
|
data/lib/fix/expectation.rb
CHANGED
@@ -1,18 +1,27 @@
|
|
1
|
-
|
1
|
+
require 'set'
|
2
2
|
require 'spectus'
|
3
|
+
require_relative 'db'
|
3
4
|
|
4
5
|
module Fix
|
5
6
|
class Expectation
|
6
7
|
include Spectus::DSL
|
7
8
|
|
8
|
-
|
9
|
+
attr_reader :priority
|
10
|
+
|
11
|
+
def initialize object, positive, definition, *args
|
9
12
|
@positive = positive
|
10
13
|
@matcher, @expected = definition.to_a.flatten 1
|
11
14
|
@args = args
|
15
|
+
@priority = DB.instance.random.rand
|
12
16
|
|
13
17
|
freeze
|
14
18
|
|
15
|
-
|
19
|
+
DB.instance.update(object => SortedSet[]) unless DB.instance.key? object
|
20
|
+
DB.instance.fetch(object).add self
|
21
|
+
end
|
22
|
+
|
23
|
+
def <=> other
|
24
|
+
self.priority <=> other.priority
|
16
25
|
end
|
17
26
|
|
18
27
|
private
|
data/lib/fix/expectation_high.rb
CHANGED
data/lib/fix/expectation_low.rb
CHANGED
data/lib/fix/helper/it_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Fix
|
2
2
|
module Helper
|
3
|
-
module
|
4
|
-
def
|
5
|
-
i =
|
3
|
+
module ItHelper
|
4
|
+
def it &block
|
5
|
+
i = It.new @object, @defs, *@args
|
6
6
|
i.instance_eval(&block)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
require_relative File.join '..', '
|
12
|
+
require_relative File.join '..', 'it'
|
@@ -1,12 +1,21 @@
|
|
1
1
|
module Fix
|
2
2
|
module Helper
|
3
|
-
module
|
4
|
-
def
|
5
|
-
|
3
|
+
module ItsHelper
|
4
|
+
def its attribute, *args, &block
|
5
|
+
unless instance_variable_defined? :@object
|
6
|
+
raise MissingSubjectError, "Incomplete specifications. " \
|
7
|
+
"Please specify a `subject` on the top."
|
8
|
+
end
|
9
|
+
|
10
|
+
@defs = {} unless instance_variable_defined? :@defs
|
11
|
+
@args = [] unless instance_variable_defined? :@args
|
12
|
+
|
13
|
+
i = Its.new @object, @defs, *(@args + [[attribute] + args])
|
6
14
|
i.instance_eval(&block)
|
7
15
|
end
|
8
16
|
end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
|
12
|
-
require_relative File.join '..', '
|
20
|
+
require_relative File.join '..', 'its'
|
21
|
+
require_relative File.join '..', 'missing_subject_error'
|
@@ -2,7 +2,9 @@ module Fix
|
|
2
2
|
module Helper
|
3
3
|
module LetWriterHelper
|
4
4
|
def let name, &block
|
5
|
-
|
5
|
+
@defs = {} unless instance_variable_defined? :@defs
|
6
|
+
|
7
|
+
if @defs.key? name
|
6
8
|
raise IndexError, 'the given key is already present.'
|
7
9
|
else
|
8
10
|
@defs.update name => block
|
data/lib/fix/helper/on_helper.rb
CHANGED
@@ -2,11 +2,20 @@ module Fix
|
|
2
2
|
module Helper
|
3
3
|
module OnHelper
|
4
4
|
def on attribute, *args, &block
|
5
|
-
|
5
|
+
unless instance_variable_defined? :@object
|
6
|
+
raise MissingSubjectError, "Incomplete specifications. " \
|
7
|
+
"Please specify a `subject` on the top."
|
8
|
+
end
|
9
|
+
|
10
|
+
@defs = {} unless instance_variable_defined? :@defs
|
11
|
+
@args = [] unless instance_variable_defined? :@args
|
12
|
+
|
13
|
+
i = On.new @object, @defs, *(@args + [[attribute] + args])
|
6
14
|
i.instance_eval(&block)
|
7
15
|
end
|
8
16
|
end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
|
20
|
+
require_relative File.join '..', 'missing_subject_error'
|
12
21
|
require_relative File.join '..', 'on'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'let_reader_helper'
|
2
2
|
|
3
3
|
module Fix
|
4
4
|
module Helper
|
@@ -6,32 +6,32 @@ module Fix
|
|
6
6
|
include Helper::LetReaderHelper
|
7
7
|
|
8
8
|
def MUST definition
|
9
|
-
ExpectationHigh.new true, definition, *@args
|
9
|
+
ExpectationHigh.new @object, true, definition, *@args
|
10
10
|
end
|
11
11
|
|
12
12
|
alias_method :is_REQUIRED_to, :MUST
|
13
13
|
alias_method :SHALL, :MUST
|
14
14
|
|
15
15
|
def MUST_NOT definition
|
16
|
-
ExpectationHigh.new false, definition, *@args
|
16
|
+
ExpectationHigh.new @object, false, definition, *@args
|
17
17
|
end
|
18
18
|
|
19
19
|
alias_method :SHALL_NOT, :MUST_NOT
|
20
20
|
|
21
21
|
def SHOULD definition
|
22
|
-
ExpectationMedium.new true, definition, *@args
|
22
|
+
ExpectationMedium.new @object, true, definition, *@args
|
23
23
|
end
|
24
24
|
|
25
25
|
alias_method :is_RECOMMENDED_to, :SHOULD
|
26
26
|
|
27
27
|
def SHOULD_NOT definition
|
28
|
-
ExpectationMedium.new false, definition, *@args
|
28
|
+
ExpectationMedium.new @object, false, definition, *@args
|
29
29
|
end
|
30
30
|
|
31
31
|
alias_method :is_NOT_RECOMMENDED_to, :SHOULD_NOT
|
32
32
|
|
33
33
|
def MAY definition
|
34
|
-
ExpectationLow.new true, definition, *@args
|
34
|
+
ExpectationLow.new @object, true, definition, *@args
|
35
35
|
end
|
36
36
|
|
37
37
|
alias_method :is_OPTIONAL_to, :MAY
|
data/lib/fix/it.rb
CHANGED
data/lib/fix/its.rb
CHANGED
data/lib/fix/on.rb
CHANGED
@@ -10,9 +10,10 @@ module Fix
|
|
10
10
|
include Helper::LetAccessorHelper
|
11
11
|
include Helper::OnHelper
|
12
12
|
|
13
|
-
def initialize defs, *args
|
14
|
-
@
|
15
|
-
@
|
13
|
+
def initialize object, defs, *args
|
14
|
+
@object = object
|
15
|
+
@defs = defs
|
16
|
+
@args = args
|
16
17
|
|
17
18
|
freeze
|
18
19
|
end
|
data/lib/fix/test.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'db'
|
2
2
|
|
3
3
|
module Fix
|
4
4
|
class Test
|
5
5
|
attr_reader :total_time
|
6
6
|
|
7
|
-
def initialize
|
7
|
+
def initialize color: true, stdout: STDOUT, stderr: STDERR
|
8
8
|
@options = { color: color, stdout: stdout, stderr: stderr }
|
9
|
-
@options.fetch(:stdout).puts about "Run options: --seed #{seed}"
|
10
|
-
|
11
|
-
random = Random.new seed
|
12
|
-
expectations = ExpectationSet.instance.to_a.shuffle(random: random)
|
13
9
|
|
14
10
|
start_time = Time.now
|
15
|
-
@results =
|
16
|
-
|
17
|
-
|
11
|
+
@results = DB.instance.map do |object, expectations|
|
12
|
+
expectations.map do |expectation|
|
13
|
+
log expectation.evaluate object
|
14
|
+
end
|
15
|
+
end.flatten 1
|
18
16
|
@total_time = Time.now - start_time
|
19
17
|
|
20
18
|
@options.fetch(:stdout).puts about "\nFinished in #{@total_time} seconds."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
sQCgS9KCAyZ+aWNO1bUJcE3Bx1XXkMO3JEyVR1CoEcexg5Ci03/lAm7lL84DmlKR
|
31
31
|
3I7UWtomapPFbzC0J/5jzQ==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-09-
|
33
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: spectus
|
@@ -120,17 +120,16 @@ files:
|
|
120
120
|
- example/duck/README.md
|
121
121
|
- example/duck/app.rb
|
122
122
|
- example/duck/lib.rb
|
123
|
-
- example/duck/spec.rb
|
124
123
|
- example/duck/test.rb
|
125
124
|
- fix.gemspec
|
126
125
|
- fix.pem
|
127
126
|
- lib/fix.rb
|
127
|
+
- lib/fix/db.rb
|
128
128
|
- lib/fix/dsl.rb
|
129
129
|
- lib/fix/expectation.rb
|
130
130
|
- lib/fix/expectation_high.rb
|
131
131
|
- lib/fix/expectation_low.rb
|
132
132
|
- lib/fix/expectation_medium.rb
|
133
|
-
- lib/fix/expectation_set.rb
|
134
133
|
- lib/fix/helper/it_helper.rb
|
135
134
|
- lib/fix/helper/its_helper.rb
|
136
135
|
- lib/fix/helper/let_accessor_helper.rb
|
@@ -140,8 +139,8 @@ files:
|
|
140
139
|
- lib/fix/helper/requirement_helper.rb
|
141
140
|
- lib/fix/it.rb
|
142
141
|
- lib/fix/its.rb
|
142
|
+
- lib/fix/missing_subject_error.rb
|
143
143
|
- lib/fix/on.rb
|
144
|
-
- lib/fix/spec.rb
|
145
144
|
- lib/fix/subject.rb
|
146
145
|
- lib/fix/test.rb
|
147
146
|
- lib/fix/version.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/example/duck/spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'fix'
|
2
|
-
|
3
|
-
@spec = Fix::Spec.new :duck do
|
4
|
-
let(:word) { "Quaaa" }
|
5
|
-
|
6
|
-
on :swims do
|
7
|
-
it { MUST capture_stderr: " ...\n" }
|
8
|
-
end
|
9
|
-
|
10
|
-
on :quacks do
|
11
|
-
let(:quaaaaaack) { word + "aaack!\n" }
|
12
|
-
|
13
|
-
it { SHOULD capture_stdout: quaaaaaack }
|
14
|
-
end
|
15
|
-
|
16
|
-
its(:speaks) { MUST raise_exception: NoMethodError }
|
17
|
-
|
18
|
-
on :sings do
|
19
|
-
it { MAY eql: "♪... ♫..." }
|
20
|
-
end
|
21
|
-
|
22
|
-
on :walks do
|
23
|
-
let(:walks) { "#{word}... Klop klop!" }
|
24
|
-
|
25
|
-
it { MUST eql: walks }
|
26
|
-
|
27
|
-
on :split, '... ' do
|
28
|
-
its(:last) { MUST eql: "Klop klop!" }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/fix/spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require_relative File.join 'dsl'
|
2
|
-
require_relative File.join 'test'
|
3
|
-
|
4
|
-
module Fix
|
5
|
-
class Spec
|
6
|
-
include DSL
|
7
|
-
|
8
|
-
def initialize title = nil, &block
|
9
|
-
@title = title
|
10
|
-
@defs = {}
|
11
|
-
@args = []
|
12
|
-
|
13
|
-
instance_eval(&block)
|
14
|
-
|
15
|
-
freeze
|
16
|
-
end
|
17
|
-
|
18
|
-
def test front_object, seed: Random.new_seed, color: true, stdout: STDOUT, stderr: STDERR
|
19
|
-
Test.new front_object, seed: Random.new_seed, color: true, stdout: STDOUT, stderr: STDERR
|
20
|
-
end
|
21
|
-
|
22
|
-
def valid? front_object
|
23
|
-
Test.new(front_object).pass?
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|