gurke 2.0.0.dev.1.b18 → 2.0.0.dev.1.b19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/gurke/cli.rb +1 -1
- data/lib/gurke/configuration.rb +41 -15
- data/lib/gurke/runner.rb +4 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzAxYTk2ODk0YzgxZWM2OTBkM2QzY2ZkYTIzOWI2NWIyODJmYjE0Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTQ2NWJmMzY0MGE2Y2NjMjRiMWEwMTc5ODhlZGU3Nzg5ZmU5Y2ZjMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmI4ZGViNDEyYmZmZDAzMWI2MDI4ZmE3OTgzODU5MjJhZDMzZDk2Y2I1MjQ0
|
10
|
+
ZWUxNTUwOWUzNDI2ZjNkM2RkMjMyMmE3NWE5YjE0YjIzMjE0YmIxMjgwM2I2
|
11
|
+
MzFjZWFjZjllMDhjODEwOGYxMjJmMjcwNWI2Zjk3ZDE2ZmM3NmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjU2ZDUzYzcxOGMxZTk5YTEzZGRlNmRmNmJmOTE4ODlkYWJmZjc3NmI1YTE2
|
14
|
+
MDU4MjI2NDYwNjAxNjI0NDgzODM4OWFmYjEzNGFlZmNjODljZDI2Yjc1OTAx
|
15
|
+
NmQ1M2RlZjliMjBmYjViNThjMDhlYmMwMmU3MGRhZjNkOTIzNjA=
|
data/lib/gurke/cli.rb
CHANGED
data/lib/gurke/configuration.rb
CHANGED
@@ -15,11 +15,15 @@ module Gurke
|
|
15
15
|
# @yield Before any matching action is executed.
|
16
16
|
#
|
17
17
|
def before(action = :scenario, opts = nil, &block)
|
18
|
-
|
18
|
+
raise ArgumentError.new "Unknown hook: #{action}" unless hooks[action]
|
19
|
+
|
20
|
+
hooks[action].append :before, Hook.new(opts, &block)
|
19
21
|
end
|
20
22
|
|
21
23
|
def around(action = :scenario, opts = nil, &block)
|
22
|
-
|
24
|
+
raise ArgumentError.new "Unknown hook: #{action}" unless hooks[action]
|
25
|
+
|
26
|
+
hooks[action].append :around, Hook.new(opts, &block)
|
23
27
|
end
|
24
28
|
|
25
29
|
# Define a after filter running after given action.
|
@@ -35,7 +39,9 @@ module Gurke
|
|
35
39
|
# @yield After any matching action is executed.
|
36
40
|
#
|
37
41
|
def after(action = :scenario, opts = nil, &block)
|
38
|
-
|
42
|
+
raise ArgumentError.new "Unknown hook: #{action}" unless hooks[action]
|
43
|
+
|
44
|
+
hooks[action].append :after, Hook.new(opts, &block)
|
39
45
|
end
|
40
46
|
|
41
47
|
# Include given module into all or specific features or
|
@@ -58,7 +64,17 @@ module Gurke
|
|
58
64
|
|
59
65
|
# @api private
|
60
66
|
def hooks
|
61
|
-
@hooks ||=
|
67
|
+
@hooks ||= begin
|
68
|
+
hooks = {
|
69
|
+
features: HookSet.new,
|
70
|
+
feature: HookSet.new,
|
71
|
+
scenario: HookSet.new,
|
72
|
+
step: HookSet.new
|
73
|
+
}
|
74
|
+
|
75
|
+
hooks.merge each: hooks[:scenario]
|
76
|
+
hooks
|
77
|
+
end
|
62
78
|
end
|
63
79
|
|
64
80
|
# @api private
|
@@ -73,25 +89,35 @@ module Gurke
|
|
73
89
|
|
74
90
|
# @api private
|
75
91
|
class HookSet
|
76
|
-
attr_reader :hooks
|
77
|
-
|
78
92
|
def initialize
|
79
|
-
@
|
93
|
+
@before = []
|
94
|
+
@after = []
|
95
|
+
@around = []
|
80
96
|
end
|
81
97
|
|
82
|
-
def
|
83
|
-
|
98
|
+
def append(set, hook)
|
99
|
+
case set
|
100
|
+
when :before then @before << hook
|
101
|
+
when :after then @after << hook
|
102
|
+
when :around then @around << hook
|
103
|
+
else raise ArgumentError.new "Unknown hook set: #{set}"
|
104
|
+
end
|
84
105
|
end
|
85
106
|
|
86
|
-
def
|
87
|
-
|
107
|
+
def run(world, &block)
|
108
|
+
@before.each{|hook| hook.run world }
|
109
|
+
@around.reduce(block){|blk, hook| proc{ hook.run world, blk }}.call
|
110
|
+
ensure
|
111
|
+
@after.each do |hook|
|
112
|
+
begin
|
113
|
+
hook.run world
|
114
|
+
rescue => e
|
115
|
+
warn "Rescued error in after hook: #{e}\n#{e.backtrace.join("\n")}"
|
116
|
+
end
|
117
|
+
end
|
88
118
|
end
|
89
119
|
end
|
90
120
|
|
91
|
-
BEFORE_HOOKS = HookSet.new
|
92
|
-
AROUND_HOOKS = HookSet.new
|
93
|
-
AFTER_HOOKS = HookSet.new
|
94
|
-
|
95
121
|
# @api private
|
96
122
|
class Hook
|
97
123
|
attr_reader :opts, :block
|
data/lib/gurke/runner.rb
CHANGED
@@ -4,8 +4,10 @@ module Gurke
|
|
4
4
|
attr_reader :builder
|
5
5
|
attr_reader :files
|
6
6
|
attr_reader :options
|
7
|
+
attr_reader :config
|
7
8
|
|
8
|
-
def initialize(files, options = {})
|
9
|
+
def initialize(config, files, options = {})
|
10
|
+
@config = config
|
9
11
|
@options = options
|
10
12
|
@files = files
|
11
13
|
@builder = Builder.new options
|
@@ -24,18 +26,7 @@ module Gurke
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def hook(scope, world, &block)
|
27
|
-
|
28
|
-
Configuration::AROUND_HOOKS.for(scope).reduce(block) do |blk, hook|
|
29
|
-
proc { hook.run(world, blk) }
|
30
|
-
end.call
|
31
|
-
ensure
|
32
|
-
Configuration::AFTER_HOOKS.for(scope).each do |hook|
|
33
|
-
begin
|
34
|
-
hook.run world
|
35
|
-
rescue => e
|
36
|
-
warn "Rescued error in after hook: #{e}\n#{e.backtrace.join("\n")}"
|
37
|
-
end
|
38
|
-
end
|
29
|
+
config.hooks[scope].run world, &block
|
39
30
|
end
|
40
31
|
|
41
32
|
def with_filtered_backtrace
|