Class: WireMockMapper::MatchBuilder
- Inherits:
-
Object
- Object
- WireMockMapper::MatchBuilder
- Defined in:
- lib/match_builder.rb
Instance Method Summary collapse
-
#absent ⇒ RequestBuilder
Match if attribute is absent.
-
#containing(value) ⇒ RequestBuilder
Match if attribute value contains the arg.
-
#equal_to(value) ⇒ RequestBuilder
Match if attribute value is equal to the arg.
-
#equal_to_json(json, ignore_array_order = false, ignore_extra_elements = false) ⇒ RequestBuilder
Match if attribute json is equal to the arg.
-
#equal_to_xml(xml) ⇒ RequestBuilder
Match if attribute xml is equal to the arg.
-
#initialize(request_builder) ⇒ MatchBuilder
constructor
A new instance of MatchBuilder.
-
#matching(regex_string) ⇒ RequestBuilder
Match if attribute value matches the regex_string.
-
#matching_json_path(json_path) ⇒ RequestBuilder
Match if attribute json matches the json_path.
-
#matching_xpath(xpath) ⇒ RequestBuilder
Match if attribute xml matches the xpath.
-
#not_matching(regex_string) ⇒ RequestBuilder
Match if attribute value does not match.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(request_builder) ⇒ MatchBuilder
Returns a new instance of MatchBuilder.
3 4 5 6 7 8 |
# File 'lib/match_builder.rb', line 3 def initialize(request_builder) @request_builder = request_builder @type = '' @value = '' = {} end |
Instance Method Details
#absent ⇒ RequestBuilder
Match if attribute is absent
12 13 14 15 16 |
# File 'lib/match_builder.rb', line 12 def absent @type = :absent @value = true @request_builder end |
#containing(value) ⇒ RequestBuilder
Match if attribute value contains the arg
21 22 23 24 25 |
# File 'lib/match_builder.rb', line 21 def containing(value) @type = :contains @value = value @request_builder end |
#equal_to(value) ⇒ RequestBuilder
Match if attribute value is equal to the arg
30 31 32 33 34 |
# File 'lib/match_builder.rb', line 30 def equal_to(value) @type = :equalTo @value = value @request_builder end |
#equal_to_json(json, ignore_array_order = false, ignore_extra_elements = false) ⇒ RequestBuilder
Match if attribute json is equal to the arg
41 42 43 44 45 46 47 48 49 |
# File 'lib/match_builder.rb', line 41 def equal_to_json(json, ignore_array_order = false, ignore_extra_elements = false) @type = :equalToJson @value = json [:ignoreArrayOrder] = true if ignore_array_order [:ignoreExtraElements] = true if ignore_extra_elements @request_builder end |
#equal_to_xml(xml) ⇒ RequestBuilder
Match if attribute xml is equal to the arg
54 55 56 57 58 |
# File 'lib/match_builder.rb', line 54 def equal_to_xml(xml) @type = :equalToXml @value = xml @request_builder end |
#matching(regex_string) ⇒ RequestBuilder
Match if attribute value matches the regex_string
63 64 65 66 67 |
# File 'lib/match_builder.rb', line 63 def matching(regex_string) @type = :matches @value = regex_string @request_builder end |
#matching_json_path(json_path) ⇒ RequestBuilder
Match if attribute json matches the json_path
72 73 74 75 76 |
# File 'lib/match_builder.rb', line 72 def matching_json_path(json_path) @type = :matchesJsonPath @value = json_path @request_builder end |
#matching_xpath(xpath) ⇒ RequestBuilder
Match if attribute xml matches the xpath
81 82 83 84 85 |
# File 'lib/match_builder.rb', line 81 def matching_xpath(xpath) @type = :matchesXPath @value = xpath @request_builder end |
#not_matching(regex_string) ⇒ RequestBuilder
Match if attribute value does not match
90 91 92 93 94 |
# File 'lib/match_builder.rb', line 90 def not_matching(regex_string) @type = :doesNotMatch @value = regex_string @request_builder end |
#to_hash ⇒ Object
96 97 98 |
# File 'lib/match_builder.rb', line 96 def to_hash(*) { @type => @value }.merge() end |
#to_json ⇒ Object
100 101 102 |
# File 'lib/match_builder.rb', line 100 def to_json(*) to_hash.to_json end |