Sha256: 3502b760e88c1eda35f537ebf188792ad41e9dd44290aaaba107069f4925997f

Contents?: true

Size: 1.03 KB

Versions: 37

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'cucumber/core/filter'
require 'cucumber/core/test/location'
require 'cucumber/running_test_case'

module Cucumber
  module Filters
    class PrepareWorld < Core::Filter.new(:runtime)
      def test_case(test_case)
        CaseFilter.new(runtime, test_case).test_case.describe_to receiver
      end

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

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

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

        private

        def scenario
          @scenario ||= RunningTestCase.new(test_case)
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
cucumber-6.0.0 lib/cucumber/filters/prepare_world.rb
cucumber-5.3.0 lib/cucumber/filters/prepare_world.rb
cucumber-5.2.0 lib/cucumber/filters/prepare_world.rb
cucumber-5.1.3 lib/cucumber/filters/prepare_world.rb
cucumber-5.1.2 lib/cucumber/filters/prepare_world.rb
cucumber-5.1.1 lib/cucumber/filters/prepare_world.rb
cucumber-5.1.0 lib/cucumber/filters/prepare_world.rb
cucumber-5.0.0 lib/cucumber/filters/prepare_world.rb
cucumber-4.1.0 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.1 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.0 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.0.rc.6 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.0.rc.5 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.0.rc.4 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.0.rc.3 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.0.rc.2 lib/cucumber/filters/prepare_world.rb
cucumber-4.0.0.rc.1 lib/cucumber/filters/prepare_world.rb