Class: Cucumber::Wire::AddHooksFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/wire/add_hooks_filter.rb

Instance Method Summary collapse

Instance Method Details

#after_hook(test_case) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 26

def after_hook(test_case)
  hook = instanciate_wire_hook(:end_scenario)
  action = ->(result) { hook.invoke('After', [Cucumber::RunningTestCase.new(test_case).with_result(result), connections]) }

  hook_step = Cucumber::Hooks.after_hook(id_generator.new_id, Core::Test::Location.new('wire'), &action)

  configuration.event_bus.hook_test_step_created(hook_step, hook)

  hook_step
end

#before_hook(test_case) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 12

def before_hook(test_case)
  # TODO: is this dependency on Cucumber::Hooks OK? Feels a bit internal..
  # TODO: how do we express the location of the hook? Should we create one hook per connection so we can use the host:port of the connection?

  hook = instanciate_wire_hook(:begin_scenario)
  action = ->(result) { hook.invoke('Before', [Cucumber::RunningTestCase.new(test_case).with_result(result), connections]) }

  hook_step = Cucumber::Hooks.before_hook(id_generator.new_id, Core::Test::Location.new('wire'), &action)

  configuration.event_bus.hook_test_step_created(hook_step, hook)

  hook_step
end

#configurationObject



41
42
43
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 41

def configuration
  @configuration ||= connections.configuration
end

#id_generatorObject



37
38
39
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 37

def id_generator
  @id_generator ||= connections.configuration.id_generator
end

#test_case(test_case) ⇒ Object



6
7
8
9
10
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 6

def test_case(test_case)
  test_case.
    with_steps([before_hook(test_case)] + test_case.test_steps + [after_hook(test_case)]).
    describe_to receiver
end