module Cucumber::Hooks
Hooks quack enough like `Cucumber::Core::Ast` source nodes that we can use them as source for test steps
Public Class Methods
after_hook(source, location, &block)
click to toggle source
# File lib/cucumber/hooks.rb, line 15 def after_hook(source, location, &block) build_hook_step(source, location, block, AfterHook, Core::Test::UnskippableAction) end
after_step_hook(source, location, &block)
click to toggle source
# File lib/cucumber/hooks.rb, line 19 def after_step_hook(source, location, &block) raise ArgumentError unless source.last.is_a?(Core::Ast::Step) build_hook_step(source, location, block, AfterStepHook, Core::Test::Action) end
around_hook(_source, &block)
click to toggle source
# File lib/cucumber/hooks.rb, line 24 def around_hook(_source, &block) Core::Test::AroundHook.new(&block) end
before_hook(source, location, &block)
click to toggle source
# File lib/cucumber/hooks.rb, line 11 def before_hook(source, location, &block) build_hook_step(source, location, block, BeforeHook, Core::Test::UnskippableAction) end
Private Class Methods
build_hook_step(source, location, block, hook_type, action_type)
click to toggle source
# File lib/cucumber/hooks.rb, line 30 def build_hook_step(source, location, block, hook_type, action_type) action = action_type.new(location, &block) hook = hook_type.new(action.location) Core::Test::Step.new(source + [hook], action) end