Sha256: 91d6348da2e16374349c17704e48d28c39fc21bae3c32db897409edf76b4595f

Contents?: true

Size: 582 Bytes

Versions: 9

Compression:

Stored size: 582 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

9 entries across 9 versions & 1 rubygems

Version Path
gurke-2.1.0 lib/gurke/step_definition.rb
gurke-2.0.3 lib/gurke/step_definition.rb
gurke-2.0.2 lib/gurke/step_definition.rb
gurke-2.0.1 lib/gurke/step_definition.rb
gurke-2.0.0 lib/gurke/step_definition.rb
gurke-2.0.0.dev.1.b25 lib/gurke/step_definition.rb
gurke-2.0.0.dev.1.b24 lib/gurke/step_definition.rb
gurke-2.0.0.dev.1.b23 lib/gurke/step_definition.rb
gurke-2.0.0.dev.1.b22 lib/gurke/step_definition.rb