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 +4 -4
- data/.travis.yml +0 -1
- data/lib/microspec/scope.rb +17 -23
- data/lib/microspec/spec.rb +36 -5
- data/lib/microspec/version.rb +1 -1
- data/spec/microspec/scope.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22d9f8b237e3592794549b7ff3beeca7931d259e
|
4
|
+
data.tar.gz: c152859b1a2f15fbcee3c7d4811e7cf91f4261b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2725335e2d84c4192228106e9da187b919f04b52f358238b9443f4b382f47b8f2c3ad16719c5fca85869eb5da04d24d64d5b1a3464bcbf4bbbedd589be8ac704
|
7
|
+
data.tar.gz: b04ef3b8d9369d62e98c0007f541fbd30ffa9d37c9ac04978b9529dfb816c5e00add4bb39efbe836758d86fc264f8077b487636e75cac90474de37028dedfb4a
|
data/.travis.yml
CHANGED
data/lib/microspec/scope.rb
CHANGED
@@ -50,14 +50,8 @@ module Microspec
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def spec(description = nil, &block)
|
53
|
-
|
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
|
-
|
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
|
-
|
72
|
+
context.instance_eval(&setup)
|
89
73
|
end
|
90
74
|
end
|
91
75
|
|
92
|
-
def finish(
|
93
|
-
parent.finish
|
76
|
+
def finish(context)
|
77
|
+
parent.finish context if parent
|
94
78
|
|
95
79
|
teardowns.each do |teardown|
|
96
|
-
|
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
|
data/lib/microspec/spec.rb
CHANGED
@@ -8,22 +8,53 @@ module Microspec
|
|
8
8
|
@_description
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
@
|
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,
|
31
|
+
def initialize(description = nil, scope:, &block)
|
20
32
|
@_description = description
|
21
|
-
@
|
33
|
+
@_scope = scope
|
34
|
+
@_context = scope.context.new
|
22
35
|
@_block = block
|
23
36
|
end
|
24
37
|
|
25
38
|
def perform
|
26
|
-
|
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
|
data/lib/microspec/version.rb
CHANGED
data/spec/microspec/scope.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|