Sha256: 44dd5e7cf15e2afcb137794efe6430dbdb79dee810bf6b5367b37f507b5580e8

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

# coding: utf-8
require 'cucumber/messages'

module Cucumber
  module Wire
    class AddHooksFilter < Core::Filter.new(:connections)
      def test_case(test_case)
        test_case.
          with_steps([before_hook(test_case)] + test_case.test_steps + [after_hook(test_case)]).
          describe_to receiver
      end

      def before_hook(test_case)
        # TODO: is this dependency on Cucumber::Hooks OK? Feels a bit internal..
        # TODO: how do we express the location of the hook? Should we create one hook per connection so we can use the host:port of the connection?
        Cucumber::Hooks.before_hook(id_generator.new_id, Core::Test::Location.new('TODO:wire')) do
          connections.begin_scenario(test_case)
        end
      end

      def after_hook(test_case)
        Cucumber::Hooks.after_hook(id_generator.new_id, Core::Test::Location.new('TODO:wire')) do
          connections.end_scenario(test_case)
        end
      end

      def id_generator
        @id_generator ||= Cucumber::Messages::IdGenerator::UUID.new
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-wire-6.2.0/lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-6.2.0 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-6.1.1 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-6.1.0 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-6.0.1 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-6.0.0 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-5.0.1 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-5.0.0 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-4.0.1 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-3.1.0 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-3.0.0 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-2.0.1 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-2.0.0 lib/cucumber/wire/add_hooks_filter.rb
cucumber-wire-1.2.0 lib/cucumber/wire/add_hooks_filter.rb