Class: WireMockMapper::Builders::UrlMatchBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/builders/url_match_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(request_builder, path = false) ⇒ UrlMatchBuilder

Returns a new instance of UrlMatchBuilder.



4
5
6
7
8
9
# File 'lib/builders/url_match_builder.rb', line 4

def initialize(request_builder, path = false)
  @request_builder = request_builder
  @path = path
  @type = ''
  @url_or_pattern = ''
end

Instance Method Details

#equal_to(url) ⇒ RequestBuilder

Expect url to equal

Parameters:

  • url (String)

    url to match against

Returns:

  • (RequestBuilder)

    calling request builder for chaining additional attributes



14
15
16
17
18
# File 'lib/builders/url_match_builder.rb', line 14

def equal_to(url)
  @type = @path ? :urlPath : :url
  @url_or_pattern = url
  @request_builder
end

#matching(regexp) ⇒ RequestBuilder

Expect url to match

Parameters:

  • regexp (Regexp, String)

    regex for url to match against

Returns:

  • (RequestBuilder)

    calling request builder for chaining additional attributes



23
24
25
26
27
28
# File 'lib/builders/url_match_builder.rb', line 23

def matching(regexp)
  regexp = Helpers.regexp_to_string regexp if regexp.is_a? Regexp
  @type = @path ? :urlPathPattern : :urlPattern
  @url_or_pattern = regexp
  @request_builder
end

#to_hashObject



30
31
32
# File 'lib/builders/url_match_builder.rb', line 30

def to_hash(*)
  { @type => @url_or_pattern }
end

#to_jsonObject



34
35
36
# File 'lib/builders/url_match_builder.rb', line 34

def to_json(*)
  to_hash.to_json
end