Sha256: 24cce3f7dc894c86c99128c9abc6f4aa968d77cd6c46f2153f067d7f55958b5f

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

require "addressable/template"

module WildcardMatchers
  module Matchers
    define_wildcard_matcher(:with_uri_template)

    class WithUriTemplate < ::WildcardMatchers::WildcardMatcher
      def initialize(expectations, position = ".", &block)
        template, expectation = *expectations

        @template    = template.is_a?(::Addressable::Template) ? template : ::Addressable::Template.new(template)

        @expectation = (block_given? ? block : expectation)
        @position    = position
      end

      protected
      def wildcard_match(actual)
        extracted = @template.extract(actual)

        errors.push(*self.class.superclass.check_errors(extracted, expectation, position))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wildcard_matchers-0.1.4 lib/wildcard_matchers/matchers/with_uri_template.rb