Sha256: 89dc3e7daf4e91aebac51f1b034a65efb7835d5a775a33f10a32e2c1940cfc70

Contents?: true

Size: 832 Bytes

Versions: 15

Compression:

Stored size: 832 Bytes

Contents

module Gherkin
  module Parser
    class Event < Array
      def event
        self[0]
      end

      def keyword
        self[1]
      end
      
      def line_match?(lines)
        lines.include?(line)
      end

      def name_match?(name_regexen)
        return false unless [:feature, :background, :scenario, :scenario_outline, :examples].include?(event)
        name_regexen.detect{|name_regex| name =~ name_regex}
      end

      def replay(listener)
        begin
          listener.__send__(event, *args)
        rescue ArgumentError => e
          e.message << "\nListener: #{listener.class}, args: #{args.inspect}"
          raise e
        end
      end

    private

      def name
        self[2]
      end

      def line
        self[-1]
      end

      def args
        self[1..-1]
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gherkin-2.0.2 lib/gherkin/parser/event.rb
gherkin-2.0.2-i386-mswin32 lib/gherkin/parser/event.rb
gherkin-2.0.2-i386-mingw32 lib/gherkin/parser/event.rb
gherkin-2.0.2-universal-dotnet lib/gherkin/parser/event.rb
gherkin-2.0.2-java lib/gherkin/parser/event.rb
gherkin-2.0.1 lib/gherkin/parser/event.rb
gherkin-2.0.1-i386-mswin32 lib/gherkin/parser/event.rb
gherkin-2.0.1-i386-mingw32 lib/gherkin/parser/event.rb
gherkin-2.0.1-universal-dotnet lib/gherkin/parser/event.rb
gherkin-2.0.1-java lib/gherkin/parser/event.rb
gherkin-2.0.0 lib/gherkin/parser/event.rb
gherkin-2.0.0-i386-mswin32 lib/gherkin/parser/event.rb
gherkin-2.0.0-i386-mingw32 lib/gherkin/parser/event.rb
gherkin-2.0.0-universal-dotnet lib/gherkin/parser/event.rb
gherkin-2.0.0-java lib/gherkin/parser/event.rb