Sha256: b12203307940ed456a84008d0dde77a49d51148fa87dc640c0039f72212f4c1d

Contents?: true

Size: 592 Bytes

Versions: 4

Compression:

Stored size: 592 Bytes

Contents

module Gurke
  #
  class StepDefinition
    #
    attr_reader :pattern, :method_name, :opts

    def initialize(pattern, opts = {})
      @pattern      = pattern
      @opts         = opts
    end

    def method_name
      "#{type.to_s.capitalize} #{pattern}"
    end

    def type
      opts[:type] || :any
    end

    def match(name, type = :any)
      match = pattern.match(name)

      return unless match
      return if self.type != :any && self.type != type

      Match.new(method_name, match.to_a[1..-1])
    end

    class Match < Struct.new(:method_name, :params); end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gurke-2.0.0.dev.1.b20 lib/gurke/step_definition.rb
gurke-2.0.0.dev.1.b19 lib/gurke/step_definition.rb
gurke-2.0.0.dev.1.b18 lib/gurke/step_definition.rb
gurke-2.0.0.dev.1.b17 lib/gurke/step_definition.rb