tengu 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tengu/describe_block.rb +12 -8
- data/lib/tengu/version.rb +1 -1
- data/spec/describe_block_spec.rb +2 -2
- data/spec/fixtures/example.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5af8bd49ab18c5df87f95597d85710931e43b70c
|
4
|
+
data.tar.gz: f10cda26754deeb775e208ac09c9af549d33437c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45e37d875c7a30f6cd2aff30b316f7c1cb5a72ec0283339fe23e0c81415ac9b6d8515d825ea9cbbfa5d9d095809088b4ca0e063e2f8178b7a2787a14df9b2db7
|
7
|
+
data.tar.gz: dfd14c8623329403908f6ae11add774b1256a517c135b06a8876007e34d9bac0edc694cb618ea584cece2e591647baef701795b6fde18dfa3a57aa12864ddec4
|
data/lib/tengu/describe_block.rb
CHANGED
@@ -4,8 +4,8 @@ module Tengu
|
|
4
4
|
@description = description
|
5
5
|
@block = block
|
6
6
|
@test_cases = []
|
7
|
-
@
|
8
|
-
@
|
7
|
+
@before_each_hooks = []
|
8
|
+
@after_each_hooks = []
|
9
9
|
load_test_cases
|
10
10
|
end
|
11
11
|
|
@@ -31,12 +31,16 @@ module Tengu
|
|
31
31
|
singleton_class.send(:include, included_module)
|
32
32
|
end
|
33
33
|
|
34
|
-
def before(&block)
|
35
|
-
|
34
|
+
def before(type, &block)
|
35
|
+
if type == :each
|
36
|
+
@before_each_hooks << block
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
|
-
def after(&block)
|
39
|
-
|
40
|
+
def after(type, &block)
|
41
|
+
if type == :each
|
42
|
+
@after_each_hooks << block
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
|
@@ -46,9 +50,9 @@ module Tengu
|
|
46
50
|
|
47
51
|
def run_test_cases(runner, listeners = [])
|
48
52
|
@test_cases.each do |test_case|
|
49
|
-
@
|
53
|
+
@before_each_hooks.each { |hook| hook.call }
|
50
54
|
test_case.run(runner, listeners)
|
51
|
-
@
|
55
|
+
@after_each_hooks.each { |hook| hook.call }
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
data/lib/tengu/version.rb
CHANGED
data/spec/describe_block_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe Tengu::DescribeBlock do
|
|
21
21
|
expected = -> {}
|
22
22
|
allow(expected).to receive(:call)
|
23
23
|
allow(ItBlock).to receive(:new).and_return(double(ItBlock, run: true))
|
24
|
-
code = -> (wombat) { before &expected; it {} }
|
24
|
+
code = -> (wombat) { before :each, &expected; it {} }
|
25
25
|
DescribeBlock.new("test", code).run(nil, [])
|
26
26
|
expect(expected).to have_received(:call)
|
27
27
|
end
|
@@ -30,7 +30,7 @@ describe Tengu::DescribeBlock do
|
|
30
30
|
expected = -> {}
|
31
31
|
allow(expected).to receive(:call)
|
32
32
|
allow(ItBlock).to receive(:new).and_return(double(ItBlock, run: true))
|
33
|
-
code = -> (wombat) { after &expected; it {} }
|
33
|
+
code = -> (wombat) { after :each, &expected; it {} }
|
34
34
|
DescribeBlock.new("test", code).run(nil, [])
|
35
35
|
expect(expected).to have_received(:call)
|
36
36
|
end
|
data/spec/fixtures/example.rb
CHANGED