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(regexp) ⇒ RequestBuilder
Match if attribute value matches the regexp.
-
#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(regexp) ⇒ 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.
6 7 8 9 10 11 |
# File 'lib/builders/match_builder.rb', line 6 def initialize(request_builder) @request_builder = request_builder @type = '' @value = '' @options = {} end |
Instance Method Details
#absent ⇒ RequestBuilder
Match if attribute is absent
15 16 17 18 19 |
# File 'lib/builders/match_builder.rb', line 15 def absent @type = :absent @value = true @request_builder end |
#containing(value) ⇒ RequestBuilder
Match if attribute value contains the arg
24 25 26 27 28 |
# File 'lib/builders/match_builder.rb', line 24 def containing(value) @type = :contains @value = value @request_builder end |
#equal_to(value) ⇒ RequestBuilder
Match if attribute value is equal to the arg
33 34 35 36 37 |
# File 'lib/builders/match_builder.rb', line 33 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
44 45 46 47 48 49 50 51 52 |
# File 'lib/builders/match_builder.rb', line 44 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
57 58 59 60 61 |
# File 'lib/builders/match_builder.rb', line 57 def equal_to_xml(xml) @type = :equalToXml @value = xml @request_builder end |
#matching(regexp) ⇒ RequestBuilder
Match if attribute value matches the regexp
66 67 68 69 70 71 |
# File 'lib/builders/match_builder.rb', line 66 def matching(regexp) regexp = Helpers.regexp_to_string regexp if regexp.is_a? Regexp @type = :matches @value = regexp @request_builder end |
#matching_json_path(json_path) ⇒ RequestBuilder
Match if attribute json matches the json_path
76 77 78 79 80 |
# File 'lib/builders/match_builder.rb', line 76 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
85 86 87 88 89 |
# File 'lib/builders/match_builder.rb', line 85 def matching_xpath(xpath) @type = :matchesXPath @value = xpath @request_builder end |
#not_matching(regexp) ⇒ RequestBuilder
Match if attribute value does not match
94 95 96 97 98 99 |
# File 'lib/builders/match_builder.rb', line 94 def not_matching(regexp) regexp = Helpers.regexp_to_string regexp if regexp.is_a? Regexp @type = :doesNotMatch @value = regexp @request_builder end |
#to_hash ⇒ Object
101 102 103 |
# File 'lib/builders/match_builder.rb', line 101 def to_hash(*) { @type => @value }.merge(@options) end |
#to_json ⇒ Object
105 106 107 |
# File 'lib/builders/match_builder.rb', line 105 def to_json(*) to_hash.to_json end |