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, &block) ⇒ Object



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

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

.after_step_hook(source, &block) ⇒ Object

Raises:

  • (ArgumentError)


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

def after_step_hook(source, &block)
  raise ArgumentError unless source.last.kind_of?(Core::Ast::Step)
  build_hook_step(source, block, AfterStepHook, Core::Test::Action)
end

.around_hook(source, &block) ⇒ Object



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

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

.before_hook(source, &block) ⇒ Object



10
11
12
# File 'lib/cucumber/hooks.rb', line 10

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