# File lib/rspec/core/hooks.rb, line 93 def after(*args, &block) scope, options = scope_and_options_from(*args) hooks[:after][scope] << AfterHook.new(options, &block) end
# File lib/rspec/core/hooks.rb, line 98 def around(*args, &block) scope, options = scope_and_options_from(*args) hooks[:around][scope] << AroundHook.new(options, &block) end
# File lib/rspec/core/hooks.rb, line 88 def before(*args, &block) scope, options = scope_and_options_from(*args) hooks[:before][scope] << BeforeHook.new(options, &block) end
# File lib/rspec/core/hooks.rb, line 119 def find_hook(hook, scope, example_group_class) hooks[hook][scope].find_hooks_for(example_group_class) end
# File lib/rspec/core/hooks.rb, line 80 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
Runs all of the blocks stored with the hook in the context of the example. If no example is provided, just calls the hook directly.
# File lib/rspec/core/hooks.rb, line 105 def run_hook(hook, scope, example_group_instance=nil) hooks[hook][scope].run_all(example_group_instance) end
Just like run_hook, except it removes the blocks as it evalutes them, ensuring that they will only be run once.
# File lib/rspec/core/hooks.rb, line 111 def run_hook!(hook, scope, example_group_instance) hooks[hook][scope].run_all!(example_group_instance) end
Generated with the Darkfish Rdoc Generator 2.