Module: Cucumber::Hooks

Defined in:
lib/cucumber/hooks.rb

Overview

Hooks quack enough like ‘Cucumber::Core::Ast` source nodes that we can use them as source for test steps

Defined Under Namespace

Classes: AfterHook, AfterStepHook, BeforeHook

Class Method Summary collapse

Class Method Details

.after_hook(source, location, &block) ⇒ Object



17
18
19
# File 'lib/cucumber/hooks.rb', line 17

def after_hook(source, location, &block)
  build_hook_step(source, location, block, AfterHook, Core::Test::UnskippableAction)
end

.after_step_hook(source, location, &block) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
# File 'lib/cucumber/hooks.rb', line 21

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) ⇒ Object



26
27
28
# File 'lib/cucumber/hooks.rb', line 26

def around_hook(_source, &block)
  Core::Test::AroundHook.new(&block)
end

.before_hook(source, location, &block) ⇒ Object



13
14
15
# File 'lib/cucumber/hooks.rb', line 13

def before_hook(source, location, &block)
  build_hook_step(source, location, block, BeforeHook, Core::Test::UnskippableAction)
end