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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcc4798a1f25e09eca4bafa1fcd12d394252cf41
4
- data.tar.gz: 760454e29ac6570d2656d668373d526b3db51bfa
3
+ metadata.gz: 420afdf0f30af8667f11814e760c70b0a6ff0379
4
+ data.tar.gz: 4a30ea973b6758e504197d7cbd1fd532237f42f9
5
5
  SHA512:
6
- metadata.gz: 944625dab26f7964579a42490722e1a1c02729172211feb3f5fbe6388925e99084faff054046b0a89848eb5b91f0e13fd5eee7f80713c871b9112b8e7b2e617e
7
- data.tar.gz: 4d0810069845ecc67a544461c6518f06cff5d33ef86db94fa4359ee3c0d703d75374a5af33ac9b263c83fda2aca4f91659e376c24835392ba149603c13418a47
6
+ metadata.gz: bf41052dfff58f36920bb0352a66560c6f898c3148366695a33ba0aea22c89bb4d823439bed7402555c5b4c71d9bb6c16529cca9e8e60bd8c4bcc77d89439ef8
7
+ data.tar.gz: 5a8d91a61e57734642a1e313b15f0b8657baa3557a4ab78255d78c65f7971daea7ded86cd97e0ae4f2bda2ffdf98fa410b4a5a4d1d6c52268ff592b4ed364314
@@ -55,18 +55,19 @@ module Specifier
55
55
  def run
56
56
  Specifier.formatter.context(self) do
57
57
  @examples.each do |example|
58
- setup(example)
59
- result = example.run
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(example)
67
- parent&.setup(example)
67
+ def setup(world)
68
+ parent&.setup(world)
68
69
  @definitions.each do |definition|
69
- definition.define(example)
70
+ definition.define(world)
70
71
  end
71
72
  end
72
73
 
@@ -8,7 +8,8 @@ module Specifier
8
8
  # expect(value).to equal(value)
9
9
  # end
10
10
  #
11
- # example.run
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 expect(value)
24
- Expectation.new(value)
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)
@@ -1,3 +1,3 @@
1
1
  module Specifier
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -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
@@ -7,6 +7,7 @@ require 'specifier/colorizer'
7
7
  require 'specifier/config'
8
8
  require 'specifier/logger'
9
9
  require 'specifier/runner'
10
+ require 'specifier/world'
10
11
  require 'specifier/context'
11
12
  require 'specifier/definition'
12
13
  require 'specifier/example'
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.2.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