Class: WildcardMatchers::Matchers::WithUriTemplate

Inherits:
WildcardMatcher show all
Defined in:
lib/wildcard_matchers/matchers/with_uri_template.rb

Instance Attribute Summary

Attributes inherited from WildcardMatcher

#errors, #expectation, #position

Instance Method Summary collapse

Methods inherited from WildcardMatcher

#&, #===, check_errors, #|

Constructor Details

#initialize(expectations, position = ".", &block) ⇒ WithUriTemplate

Returns a new instance of WithUriTemplate.



8
9
10
11
12
13
14
15
# File 'lib/wildcard_matchers/matchers/with_uri_template.rb', line 8

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

Instance Method Details

#without_query!Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/wildcard_matchers/matchers/with_uri_template.rb', line 17

def without_query!
  @without_query = true

  # umhhh
  uri = ::Addressable::URI.parse(@template.pattern.split("{?").first)

  @template_without_query = ::Addressable::Template.new(uri.omit(:query).to_s)

  self
end