Sha256: 8a4bffaa4455f57604c7502c5ea058c74db7c6687619ec9c39afaab6fd3d27b6

Contents?: true

Size: 868 Bytes

Versions: 4

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

module Cucumber
  module Core
    module Test
      class AroundHook
        def initialize(&block)
          @block = block
          @timer = Timer.new
        end

        def describe_to(visitor, *args, &continue)
          visitor.around_hook(self, *args, &continue)
        end

        def hook?
          true
        end

        def execute(*_args, &continue)
          @timer.start
          @block.call(continue)
          Result::Unknown.new # Around hook does not know the result of the inner test steps
        rescue Result::Raisable => exception
          exception.with_duration(@timer.duration)
        rescue Exception => exception
          failed(exception)
        end

        private

        def failed(exception)
          Result::Failed.new(@timer.duration, exception)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber-core-13.0.3 lib/cucumber/core/test/around_hook.rb
cucumber-core-13.0.2 lib/cucumber/core/test/around_hook.rb
cucumber-core-13.0.1 lib/cucumber/core/test/around_hook.rb
cucumber-core-13.0.0 lib/cucumber/core/test/around_hook.rb