Module: Ruptr::Compat::RSpec::ExampleGroupHooks::ContextHooksInstanceMethods

Defined in:
lib/ruptr/rspec/example_group.rb

Instance Method Summary collapse

Instance Method Details

#wrap_context_handle(h) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/ruptr/rspec/example_group.rb', line 120

def wrap_context_handle(h)
  eg = self.class
  # NOTE: Hooks for the parent example groups will already have been called by the runner.
  k = lambda do |h|
    instance_exec(h, &eg.context_before_hook) if eg.context_before_hook
    yield h
  ensure
    instance_exec(h, &eg.context_after_hook) if eg.context_after_hook
  end
  if eg.context_around_layer_hook
    instance_exec(h.chain(&k), &eg.context_around_layer_hook)
  else
    k.call(h)
  end
end