Sha256: 935143e9c60ec7c72b1bdf7fa7fb8a5f894a509784587a7f77e6814e9ad34b10

Contents?: true

Size: 805 Bytes

Versions: 34

Compression:

Stored size: 805 Bytes

Contents

# frozen_string_literal: true

require 'cucumber/hooks'

module Cucumber
  class Runtime
    class BeforeHooks
      def initialize(id_generator, hooks, scenario, event_bus)
        @hooks = hooks
        @scenario = scenario
        @id_generator = id_generator
        @event_bus = event_bus
      end

      def apply_to(test_case)
        test_case.with_steps(
          before_hooks + test_case.test_steps
        )
      end

      private

      def before_hooks
        @hooks.map do |hook|
          action_block = ->(result) { hook.invoke('Before', @scenario.with_result(result)) }
          hook_step = Hooks.before_hook(@id_generator.new_id, hook.location, &action_block)
          @event_bus.hook_test_step_created(hook_step, hook)
          hook_step
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 4 rubygems

Version Path
cucumber-9.2.1 lib/cucumber/runtime/before_hooks.rb
cucumber-9.2.0 lib/cucumber/runtime/before_hooks.rb
cucumber-9.1.2 lib/cucumber/runtime/before_hooks.rb
cucumber-9.1.1 lib/cucumber/runtime/before_hooks.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.1.0/lib/cucumber/runtime/before_hooks.rb
cucumber-9.1.0 lib/cucumber/runtime/before_hooks.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.0.2/lib/cucumber/runtime/before_hooks.rb
cucumber-9.0.2 lib/cucumber/runtime/before_hooks.rb
cucumber-9.0.1 lib/cucumber/runtime/before_hooks.rb
cucumber-9.0.0 lib/cucumber/runtime/before_hooks.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/runtime/before_hooks.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/runtime/before_hooks.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/runtime/before_hooks.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/runtime/before_hooks.rb
cucumber-8.0.0 lib/cucumber/runtime/before_hooks.rb
cucumber-8.0.0.rc.1 lib/cucumber/runtime/before_hooks.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-7.1.0/lib/cucumber/runtime/before_hooks.rb
cucumber-7.1.0 lib/cucumber/runtime/before_hooks.rb
cucumber-7.0.0 lib/cucumber/runtime/before_hooks.rb
cucumber-6.1.0 lib/cucumber/runtime/before_hooks.rb