170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/ruptr/rspec/example_group.rb', line 170
def setup_example_phase2_hooks
return if method_defined?(:wrap_example_phase2_hooks, false)
include ExampleHooksBaseInstanceMethods
eg = self
define_method(:wrap_example_phase2_hooks) do |down_h, &up|
super(down_h) do |h|
k = if eg.example_before_hook || eg.example_after_hook
lambda do |h|
instance_exec(h, &eg.example_before_hook) if eg.example_before_hook
up.call(h)
ensure
instance_exec(h.caught($!), &eg.example_after_hook) if eg.example_after_hook
end
else
up
end
if eg.example_around_layer_hook
instance_exec(h.chain(&k), &eg.example_around_layer_hook)
else
k.call(h)
end
end
end
end
|