Sha256: 16f98d674a3311cdffc271c107c72fb2715d946783faffa1901617230faf10d4

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

require 'cucumber/initializer'

module Cucumber
  module Core
    module Test
      module Hooks

        class BeforeHook
          include Cucumber.initializer(:location)
          public :location

          def name
            "Before hook"
          end

          def match_locations?(queried_locations)
            queried_locations.any? { |other_location| other_location.match?(location) }
          end

          def describe_to(visitor, *args)
            visitor.before_hook(self, *args)
          end
        end

        class AfterHook
          include Cucumber.initializer(:location)
          public :location

          def name
            "After hook"
          end

          def match_locations?(queried_locations)
            queried_locations.any? { |other_location| other_location.match?(location) }
          end

          def describe_to(visitor, *args)
            visitor.after_hook(self, *args)
          end
        end

        class AroundHook
          def initialize(&block)
            @block = block
          end

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

          def call(continue)
            @block.call(continue)
          end
        end

        class AfterStepHook
          include Cucumber.initializer(:location)
          public :location

          def name
            "AfterStep hook"
          end

          def match_locations?(queried_locations)
            queried_locations.any? { |other_location| other_location.match?(location) }
          end

          def describe_to(visitor, *args)
            visitor.after_step_hook(self, *args)
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-core-1.0.0.beta.3 lib/cucumber/core/test/hooks.rb
cucumber-core-1.0.0.beta.2 lib/cucumber/core/test/hooks.rb
cucumber-core-1.0.0.beta.1 lib/cucumber/core/test/hooks.rb