Sha256: d9f603826db387c126894fd5351ceb7d865bccc36689a28f002b5affb496fe1d

Contents?: true

Size: 1.73 KB

Versions: 10

Compression:

Stored size: 1.73 KB

Contents

require 'cucumber/step_match'
require 'cucumber/step_definition_light'

module Cucumber
  module LanguageSupport
    module LanguageMethods

      def after_configuration(configuration)
        hooks[:after_configuration].each do |hook|
          hook.invoke('AfterConfiguration', configuration)
        end
      end

      def execute_transforms(args)
        args.map do |arg|
          matching_transform = transforms.detect {|transform| transform.match(arg) }
          matching_transform ? matching_transform.invoke(arg) : arg
        end
      end

      def add_hook(phase, hook)
        hooks[phase.to_sym] << hook
        hook
      end

      def clear_hooks
        @hooks = nil
      end

      def add_transform(transform)
        transforms.unshift transform
        transform
      end

      def hooks_for(phase, scenario) #:nodoc:
        hooks[phase.to_sym].select{|hook| scenario.accept_hook?(hook)}
      end

      def unmatched_step_definitions
        available_step_definition_hash.keys - invoked_step_definition_hash.keys
      end

      def available_step_definition(regexp_source, file_colon_line)
        available_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil
      end

      def invoked_step_definition(regexp_source, file_colon_line)
        invoked_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil
      end

      private

      def available_step_definition_hash
        @available_step_definition_hash ||= {}
      end

      def invoked_step_definition_hash
        @invoked_step_definition_hash ||= {}
      end

      def hooks
        @hooks ||= Hash.new{|h,k| h[k] = []}
      end

      def transforms
        @transforms ||= []
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cucumber-2.0.2 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.1 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0.rc.5 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0.rc.4 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0.rc.3 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0.rc.2 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0.rc.1 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0.beta.5 lib/cucumber/language_support/language_methods.rb
cucumber-2.0.0.beta.4 lib/cucumber/language_support/language_methods.rb