specifier 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
- data/lib/specifier/context.rb +6 -5
- data/lib/specifier/example.rb +4 -11
- data/lib/specifier/version.rb +1 -1
- data/lib/specifier/world.rb +21 -0
- data/lib/specifier.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 420afdf0f30af8667f11814e760c70b0a6ff0379
|
4
|
+
data.tar.gz: 4a30ea973b6758e504197d7cbd1fd532237f42f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf41052dfff58f36920bb0352a66560c6f898c3148366695a33ba0aea22c89bb4d823439bed7402555c5b4c71d9bb6c16529cca9e8e60bd8c4bcc77d89439ef8
|
7
|
+
data.tar.gz: 5a8d91a61e57734642a1e313b15f0b8657baa3557a4ab78255d78c65f7971daea7ded86cd97e0ae4f2bda2ffdf98fa410b4a5a4d1d6c52268ff592b4ed364314
|
data/lib/specifier/context.rb
CHANGED
@@ -55,18 +55,19 @@ module Specifier
|
|
55
55
|
def run
|
56
56
|
Specifier.formatter.context(self) do
|
57
57
|
@examples.each do |example|
|
58
|
-
|
59
|
-
|
58
|
+
world = Specifier::World.new
|
59
|
+
setup(world)
|
60
|
+
result = example.run(world)
|
60
61
|
Specifier.formatter.record(example, result)
|
61
62
|
end
|
62
63
|
@children.each(&:run)
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
66
|
-
def setup(
|
67
|
-
parent&.setup(
|
67
|
+
def setup(world)
|
68
|
+
parent&.setup(world)
|
68
69
|
@definitions.each do |definition|
|
69
|
-
definition.define(
|
70
|
+
definition.define(world)
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
data/lib/specifier/example.rb
CHANGED
@@ -8,7 +8,8 @@ module Specifier
|
|
8
8
|
# expect(value).to equal(value)
|
9
9
|
# end
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# world = Specifier::World.new
|
12
|
+
# example.run(world)
|
12
13
|
#
|
13
14
|
class Example
|
14
15
|
Result = Struct.new(:status, :message)
|
@@ -20,16 +21,8 @@ module Specifier
|
|
20
21
|
@block = block
|
21
22
|
end
|
22
23
|
|
23
|
-
def
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def equal(value)
|
28
|
-
Matcher::Equal.new(value)
|
29
|
-
end
|
30
|
-
|
31
|
-
def run
|
32
|
-
instance_eval(&@block)
|
24
|
+
def run(world)
|
25
|
+
world.instance_eval(&@block)
|
33
26
|
return Result.new(:pass)
|
34
27
|
rescue Specifier::Expectation::Miss => miss
|
35
28
|
return Result.new(:fail, miss.message)
|
data/lib/specifier/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Specifier
|
2
|
+
|
3
|
+
# Defines a world for a specification to execute within.
|
4
|
+
#
|
5
|
+
# Usage:
|
6
|
+
#
|
7
|
+
# world = Specifier::World.new
|
8
|
+
# world.expect('today').to equal('tomorrow')
|
9
|
+
#
|
10
|
+
class World
|
11
|
+
|
12
|
+
def expect(value)
|
13
|
+
Expectation.new(value)
|
14
|
+
end
|
15
|
+
|
16
|
+
def equal(value)
|
17
|
+
Matcher::Equal.new(value)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/specifier.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Sylvestre
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/specifier/memoizer.rb
|
126
126
|
- lib/specifier/runner.rb
|
127
127
|
- lib/specifier/version.rb
|
128
|
+
- lib/specifier/world.rb
|
128
129
|
homepage: https://github.com/ksylvest/specifier
|
129
130
|
licenses:
|
130
131
|
- MIT
|