module RSpec::Core::Hooks
def after(*args, &block)
def after(*args, &block) scope, options = scope_and_options_from(*args) hooks[:after][scope] << AfterHook.new(options, &block) end
def around(*args, &block)
def around(*args, &block) scope, options = scope_and_options_from(*args) hooks[:around][scope] << AroundHook.new(options, &block) end
def before(*args, &block)
def before(*args, &block) scope, options = scope_and_options_from(*args) hooks[:before][scope] << BeforeHook.new(options, &block) end
def find_hook(hook, scope, example_group_class)
def find_hook(hook, scope, example_group_class) hooks[hook][scope].find_hooks_for(example_group_class) end
def hooks
def hooks @hooks ||= { :around => { :each => AroundHooks.new }, :before => { :each => BeforeHooks.new, :all => BeforeHooks.new, :suite => BeforeHooks.new }, :after => { :each => AfterHooks.new, :all => AfterHooks.new, :suite => AfterHooks.new } } end
def run_hook(hook, scope, example_group_instance=nil)
Runs all of the blocks stored with the hook in the context of the
def run_hook(hook, scope, example_group_instance=nil) hooks[hook][scope].run_all(example_group_instance) end
def run_hook!(hook, scope, example_group_instance)
Just like run_hook, except it removes the blocks as it evalutes them,
def run_hook!(hook, scope, example_group_instance) hooks[hook][scope].run_all!(example_group_instance) end
def run_hook_filtered(hook, scope, group, example_group_instance)
def run_hook_filtered(hook, scope, group, example_group_instance) find_hook(hook, scope, group).run_all(example_group_instance) end
def scope_and_options_from(scope=:each, options={})
def scope_and_options_from(scope=:each, options={}) if Hash === scope options = scope scope = :each end return scope, options end