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



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

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)


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

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



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

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

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



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

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