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.
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(regexp) ⇒ RequestBuilder
Match if attribute value matches the regexp
64 65 66 67 68 69 |
# File 'lib/builders/match_builder.rb', line 64 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
74 75 76 77 78 |
# File 'lib/builders/match_builder.rb', line 74 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
83 84 85 86 87 |
# File 'lib/builders/match_builder.rb', line 83 def matching_xpath(xpath) @type = :matchesXPath @value = xpath @request_builder end |
#not_matching(regexp) ⇒ RequestBuilder
Match if attribute value does not match
92 93 94 95 96 97 |
# File 'lib/builders/match_builder.rb', line 92 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
99 100 101 |
# File 'lib/builders/match_builder.rb', line 99 def to_hash(*) { @type => @value }.merge(@options) end |
#to_json ⇒ Object
103 104 105 |
# File 'lib/builders/match_builder.rb', line 103 def to_json(*) to_hash.to_json end |