Class: Cucumber::Filters::PrepareWorld::CaseFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/filters/prepare_world.rb

Instance Method Summary collapse

Constructor Details

#initialize(runtime, original_test_case) ⇒ CaseFilter

Returns a new instance of CaseFilter



15
16
17
# File 'lib/cucumber/filters/prepare_world.rb', line 15

def initialize(runtime, original_test_case)
  @runtime, @original_test_case = runtime, original_test_case
end

Instance Method Details

#test_caseObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cucumber/filters/prepare_world.rb', line 19

def test_case
  init_scenario = Cucumber::Hooks.around_hook(@original_test_case.source) do |continue|
    @runtime.begin_scenario(scenario)
    continue.call
    @runtime.end_scenario(scenario)
  end
  around_hooks = [init_scenario] + @original_test_case.around_hooks

  empty_hook = proc {} # no op - legacy format adapter expects a before hooks
  empty_hook_location = Cucumber::Core::Ast::Location.from_source_location(*empty_hook.source_location)
  default_hook = Cucumber::Hooks.before_hook(@original_test_case.source, empty_hook_location, &empty_hook)
  steps = [default_hook] + @original_test_case.test_steps

  @original_test_case.with_around_hooks(around_hooks).with_steps(steps)
end