microspec 0.1.0.beta3 → 0.1.0.beta4

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: eb62dd0a6caad6dd7e63ce8c2cf6976ad57285ad
4
- data.tar.gz: 6f75dbc1f3de73a8900b590cdf2b0ab05031fffb
3
+ metadata.gz: 22d9f8b237e3592794549b7ff3beeca7931d259e
4
+ data.tar.gz: c152859b1a2f15fbcee3c7d4811e7cf91f4261b3
5
5
  SHA512:
6
- metadata.gz: aea5d0d34e2bfdfc6bc42c5c333e249bfb7cad1adef3496cb0ecae726568118630d52ace61dce9acec7a3530e166e6c8ed339c107251b8b501dd56d155b280be
7
- data.tar.gz: 7435d5ec8341ea6b4ff62a995392378b2c4a51edbf4dbaaa73918ad42488d3b8c1c543b29c6e7349634e0c2e9dd7ea7e1e0b064a451afe83ae53eaf7402282db
6
+ metadata.gz: 2725335e2d84c4192228106e9da187b919f04b52f358238b9443f4b382f47b8f2c3ad16719c5fca85869eb5da04d24d64d5b1a3464bcbf4bbbedd589be8ac704
7
+ data.tar.gz: b04ef3b8d9369d62e98c0007f541fbd30ffa9d37c9ac04978b9529dfb816c5e00add4bb39efbe836758d86fc264f8077b487636e75cac90474de37028dedfb4a
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
3
  - 2.1.5
5
4
  - 2.2.0
6
5
  env:
@@ -50,14 +50,8 @@ module Microspec
50
50
  end
51
51
 
52
52
  def spec(description = nil, &block)
53
- instance = context.new
54
-
55
- start instance
56
-
57
- spec = Spec.new description, instance: instance, &block
53
+ spec = Spec.new description, scope: self, &block
58
54
  spec.perform
59
-
60
- finish instance
61
55
  end
62
56
 
63
57
  def initialize(description = nil, parent: nil, context: nil, &block)
@@ -71,30 +65,30 @@ module Microspec
71
65
  instance_eval(&block)
72
66
  end
73
67
 
74
- protected
75
-
76
- def setups
77
- @_setups ||= []
78
- end
79
-
80
- def teardowns
81
- @_setups ||= []
82
- end
83
-
84
- def start(instance)
85
- parent.start instance if parent
68
+ def start(context)
69
+ parent.start context if parent
86
70
 
87
71
  setups.each do |setup|
88
- instance.instance_exec(&setup)
72
+ context.instance_eval(&setup)
89
73
  end
90
74
  end
91
75
 
92
- def finish(instance)
93
- parent.finish instance if parent
76
+ def finish(context)
77
+ parent.finish context if parent
94
78
 
95
79
  teardowns.each do |teardown|
96
- instance.instance_exec(&teardown)
80
+ context.instance_eval(&teardown)
97
81
  end
98
82
  end
83
+
84
+ protected
85
+
86
+ def setups
87
+ @_setups ||= []
88
+ end
89
+
90
+ def teardowns
91
+ @_teardowns ||= []
92
+ end
99
93
  end
100
94
  end
@@ -8,22 +8,53 @@ module Microspec
8
8
  @_description
9
9
  end
10
10
 
11
- def instance
12
- @_instance
11
+ def scope
12
+ @_scope
13
+ end
14
+
15
+ def constants
16
+ @_constants ||= []
17
+ end
18
+
19
+ def namespace
20
+ @_namespace ||= block.binding.eval "Module.nesting.first"
21
+ end
22
+
23
+ def context
24
+ @_context
13
25
  end
14
26
 
15
27
  def block
16
28
  @_block
17
29
  end
18
30
 
19
- def initialize(description = nil, instance:, &block)
31
+ def initialize(description = nil, scope:, &block)
20
32
  @_description = description
21
- @_instance = instance
33
+ @_scope = scope
34
+ @_context = scope.context.new
22
35
  @_block = block
23
36
  end
24
37
 
25
38
  def perform
26
- instance.instance_eval(&block)
39
+ sweep do
40
+ scope.start context
41
+
42
+ context.instance_eval(&block)
43
+
44
+ scope.finish context
45
+ end
46
+ end
47
+
48
+ def sweep
49
+ constants.push(*namespace.constants)
50
+
51
+ yield
52
+
53
+ constants = namespace.constants - self.constants
54
+
55
+ constants.each do |constant|
56
+ namespace.send :remove_const, constant
57
+ end
27
58
  end
28
59
  end
29
60
  end
@@ -1,3 +1,3 @@
1
1
  module Microspec
2
- VERSION = '0.1.0.beta3'
2
+ VERSION = '0.1.0.beta4'
3
3
  end
@@ -54,6 +54,32 @@ spec do
54
54
  asserts(value) == 1
55
55
  end
56
56
 
57
+ scope do
58
+ setup do
59
+ class Klass
60
+ end
61
+ end
62
+
63
+ spec do
64
+ class Klass
65
+ def new
66
+ end
67
+ end
68
+
69
+ asserts(Klass.new.methods).include? :new
70
+ end
71
+
72
+ spec do
73
+ refutes(Klass.new.methods).include? :new
74
+ end
75
+ end
76
+
77
+ spec do
78
+ raises NameError do
79
+ Klass.new
80
+ end
81
+ end
82
+
57
83
  scope do
58
84
  setup do
59
85
  $a = :a
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta3
4
+ version: 0.1.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erol Fornoles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-31 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler