Class: WireMockMapper::Builders::MatchBuilder
- Inherits:
-
Object
- Object
- WireMockMapper::Builders::MatchBuilder
- Defined in:
- lib/builders/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.
4 5 6 7 8 9 |
# File 'lib/builders/match_builder.rb', line 4 def initialize(request_builder) @request_builder = request_builder @type = '' @value = '' @options = {} end |
Instance Method Details
#absent ⇒ RequestBuilder
Match if attribute is absent
13 14 15 16 17 |
# File 'lib/builders/match_builder.rb', line 13 def absent @type = :absent @value = true @request_builder end |
#containing(value) ⇒ RequestBuilder
Match if attribute value contains the arg
22 23 24 25 26 |
# File 'lib/builders/match_builder.rb', line 22 def containing(value) @type = :contains @value = value @request_builder end |
#equal_to(value) ⇒ RequestBuilder
Match if attribute value is equal to the arg
31 32 33 34 35 |
# File 'lib/builders/match_builder.rb', line 31 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
42 43 44 45 46 47 48 49 50 |
# File 'lib/builders/match_builder.rb', line 42 def equal_to_json(json, ignore_array_order = false, ignore_extra_elements = false) @type = :equalToJson @value = json @options[:ignoreArrayOrder] = true if ignore_array_order @options[:ignoreExtraElements] = true if ignore_extra_elements @request_builder end |
#equal_to_xml(xml) ⇒ RequestBuilder
Match if attribute xml is equal to the arg
55 56 57 58 59 |
# File 'lib/builders/match_builder.rb', line 55 def equal_to_xml(xml) @type = :equalToXml @value = xml @request_builder end |
#matching(regex_string) ⇒ RequestBuilder
Match if attribute value matches the regex_string
64 65 66 67 68 |
# File 'lib/builders/match_builder.rb', line 64 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
73 74 75 76 77 |
# File 'lib/builders/match_builder.rb', line 73 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
82 83 84 85 86 |
# File 'lib/builders/match_builder.rb', line 82 def matching_xpath(xpath) @type = :matchesXPath @value = xpath @request_builder end |
#not_matching(regex_string) ⇒ RequestBuilder
Match if attribute value does not match
91 92 93 94 95 |
# File 'lib/builders/match_builder.rb', line 91 def not_matching(regex_string) @type = :doesNotMatch @value = regex_string @request_builder end |
#to_hash ⇒ Object
97 98 99 |
# File 'lib/builders/match_builder.rb', line 97 def to_hash(*) { @type => @value }.merge(@options) end |
#to_json ⇒ Object
101 102 103 |
# File 'lib/builders/match_builder.rb', line 101 def to_json(*) to_hash.to_json end |