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



21
22
23
24
25
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 21

def after_hook(test_case)
  Cucumber::Hooks.after_hook(id_generator.new_id, Core::Test::Location.new('TODO:wire')) do
    connections.end_scenario(test_case)
  end
end

#before_hook(test_case) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 13

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?
  Cucumber::Hooks.before_hook(id_generator.new_id, Core::Test::Location.new('TODO:wire')) do
    connections.begin_scenario(test_case)
  end
end

#id_generatorObject



27
28
29
# File 'lib/cucumber/wire/add_hooks_filter.rb', line 27

def id_generator
  @id_generator ||= Cucumber::Messages::IdGenerator::UUID.new
end

#test_case(test_case) ⇒ Object



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

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