Sha256: 7e7d802c1de63d119b2b79cbf9875102ceb63e5687536e1ccc233b3e2fb75feb

Contents?: true

Size: 630 Bytes

Versions: 6

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true
require 'cucumber/hooks'

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

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

      private

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cucumber-3.1.0 lib/cucumber/runtime/before_hooks.rb
cucumber-3.0.2 lib/cucumber/runtime/before_hooks.rb
cucumber-3.0.1 lib/cucumber/runtime/before_hooks.rb
cucumber-3.0.0 lib/cucumber/runtime/before_hooks.rb
cucumber-3.0.0.pre.2 lib/cucumber/runtime/before_hooks.rb
cucumber-3.0.0.pre.1 lib/cucumber/runtime/before_hooks.rb