pact-support 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/lib/pact/consumer_contract/consumer_contract.rb +11 -0
  4. data/lib/pact/consumer_contract/interaction.rb +4 -1
  5. data/lib/pact/consumer_contract/interaction_v2_parser.rb +9 -1
  6. data/lib/pact/consumer_contract/interaction_v3_parser.rb +10 -1
  7. data/lib/pact/support/version.rb +1 -1
  8. metadata +4 -227
  9. data/.github/ISSUE_TEMPLATE.md +0 -33
  10. data/.gitignore +0 -32
  11. data/.rspec +0 -3
  12. data/.travis.yml +0 -29
  13. data/Appraisals +0 -7
  14. data/Gemfile +0 -4
  15. data/RELEASING.md +0 -5
  16. data/Rakefile +0 -4
  17. data/gemfiles/default.gemfile +0 -5
  18. data/gemfiles/ruby_under_22.gemfile +0 -8
  19. data/pact-support.gemspec +0 -39
  20. data/script/release.sh +0 -9
  21. data/script/update-pact-specification-v2 +0 -9
  22. data/spec/fixtures/interaction-with-matching-rules.json +0 -27
  23. data/spec/fixtures/multipart-form-diff.txt +0 -9
  24. data/spec/fixtures/not-a-pact.json +0 -3
  25. data/spec/fixtures/pact-http-v2.json +0 -36
  26. data/spec/fixtures/pact-http-v3.json +0 -36
  27. data/spec/integration/matching_rules_extract_and_merge_spec.rb +0 -127
  28. data/spec/lib/pact/array_like_spec.rb +0 -37
  29. data/spec/lib/pact/configuration_spec.rb +0 -61
  30. data/spec/lib/pact/consumer/request_spec.rb +0 -25
  31. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  32. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -142
  33. data/spec/lib/pact/consumer_contract/file_name_spec.rb +0 -24
  34. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  35. data/spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb +0 -25
  36. data/spec/lib/pact/consumer_contract/interaction_parser_spec.rb +0 -62
  37. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -121
  38. data/spec/lib/pact/consumer_contract/interaction_v2_parser_spec.rb +0 -54
  39. data/spec/lib/pact/consumer_contract/interaction_v3_parser_spec.rb +0 -48
  40. data/spec/lib/pact/consumer_contract/pact_file_spec.rb +0 -204
  41. data/spec/lib/pact/consumer_contract/query_hash_spec.rb +0 -154
  42. data/spec/lib/pact/consumer_contract/query_string_spec.rb +0 -131
  43. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -486
  44. data/spec/lib/pact/consumer_contract/response_spec.rb +0 -82
  45. data/spec/lib/pact/helpers_spec.rb +0 -143
  46. data/spec/lib/pact/matchers/differ_spec.rb +0 -215
  47. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  48. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  49. data/spec/lib/pact/matchers/extract_diff_messages_spec.rb +0 -78
  50. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  51. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -121
  52. data/spec/lib/pact/matchers/matchers_array_like_spec.rb +0 -222
  53. data/spec/lib/pact/matchers/matchers_messages_hash_and_array_spec.rb +0 -146
  54. data/spec/lib/pact/matchers/matchers_messages_mismatched_value_spec.rb +0 -72
  55. data/spec/lib/pact/matchers/matchers_messages_regexp_spec.rb +0 -103
  56. data/spec/lib/pact/matchers/matchers_spec.rb +0 -561
  57. data/spec/lib/pact/matchers/multipart_form_diff_formatter_spec.rb +0 -36
  58. data/spec/lib/pact/matchers/no_diff_at_index_spec.rb +0 -15
  59. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  60. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -36
  61. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  62. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  63. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -235
  64. data/spec/lib/pact/matching_rules/extract_spec.rb +0 -216
  65. data/spec/lib/pact/matching_rules/merge_spec.rb +0 -436
  66. data/spec/lib/pact/matching_rules/v3/extract_spec.rb +0 -238
  67. data/spec/lib/pact/matching_rules/v3/merge_spec.rb +0 -485
  68. data/spec/lib/pact/matching_rules_spec.rb +0 -82
  69. data/spec/lib/pact/reification_spec.rb +0 -172
  70. data/spec/lib/pact/shared/dsl_spec.rb +0 -100
  71. data/spec/lib/pact/shared/form_differ_spec.rb +0 -71
  72. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  73. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  74. data/spec/lib/pact/shared/multipart_form_differ_spec.rb +0 -49
  75. data/spec/lib/pact/shared/request_spec.rb +0 -235
  76. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  77. data/spec/lib/pact/something_like_spec.rb +0 -23
  78. data/spec/lib/pact/support_spec.rb +0 -9
  79. data/spec/lib/pact/symbolize_keys_spec.rb +0 -15
  80. data/spec/lib/pact/term_spec.rb +0 -89
  81. data/spec/pact_specification/compliance-2.0.rb +0 -66
  82. data/spec/spec_helper.rb +0 -18
  83. data/spec/support/a_consumer-a_producer.json +0 -32
  84. data/spec/support/a_consumer-a_provider.json +0 -32
  85. data/spec/support/active_support_if_configured.rb +0 -6
  86. data/spec/support/case-insensitive-response-header-matching.json +0 -21
  87. data/spec/support/consumer_contract_template.json +0 -24
  88. data/spec/support/dsl_spec_support.rb +0 -7
  89. data/spec/support/factories.rb +0 -87
  90. data/spec/support/generated_index.md +0 -4
  91. data/spec/support/generated_markdown.md +0 -55
  92. data/spec/support/interaction_view_model.json +0 -63
  93. data/spec/support/interaction_view_model_with_terms.json +0 -50
  94. data/spec/support/markdown_pact.json +0 -48
  95. data/spec/support/missing_provider_states_output.txt +0 -25
  96. data/spec/support/options.json +0 -21
  97. data/spec/support/ruby_version_helpers.rb +0 -23
  98. data/spec/support/shared_examples_for_request.rb +0 -132
  99. data/spec/support/spec_support.rb +0 -29
  100. data/spec/support/stubbing.json +0 -22
  101. data/spec/support/term.json +0 -48
  102. data/spec/support/test_app_fail.json +0 -61
  103. data/spec/support/test_app_pass.json +0 -38
  104. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  105. data/tasks/release.rake +0 -5
  106. data/tasks/spec.rake +0 -14
@@ -1,131 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/consumer_contract/query_string'
3
-
4
- module Pact
5
- describe QueryString do
6
-
7
- subject { QueryString.new(query) }
8
-
9
- context "when the query a Pact::Term" do
10
-
11
- let(:query) { Pact::Term.new(generate: "param=thing", matcher: /param=.*/) }
12
-
13
- describe "#as_json" do
14
- it "returns the query as a string" do
15
- expect(subject.as_json).to eq query
16
- end
17
- end
18
-
19
- describe "#to_json" do
20
- it "returns the query as JSON" do
21
- expect(subject.to_json).to eq query.to_json
22
- end
23
- end
24
-
25
- describe "#==" do
26
- context "when the query is not an identical string match" do
27
- let(:other) { QueryString.new("param=thing2")}
28
- it "returns false" do
29
- expect(subject == other).to be false
30
- end
31
- end
32
-
33
- context "when the query is an identical string match" do
34
- let(:other) { QueryString.new(query) }
35
- it "returns true" do
36
- expect(subject == other).to be true
37
- end
38
- end
39
- end
40
-
41
- describe "#to_s" do
42
- it "returns the query string" do
43
- expect(subject.to_s).to eq query
44
- end
45
- end
46
-
47
- end
48
-
49
- context "when the query is not nil" do
50
-
51
- let(:query) { "param=thing" }
52
-
53
- describe "#as_json" do
54
- it "returns the query as a string" do
55
- expect(subject.as_json).to eq query
56
- end
57
- end
58
-
59
- describe "#to_json" do
60
- it "returns the query as JSON" do
61
- expect(subject.to_json).to eq query.to_json
62
- end
63
- end
64
-
65
- describe "#==" do
66
- context "when the query is not an identical string match" do
67
- let(:other) { QueryString.new("param=thing2")}
68
- it "returns false" do
69
- expect(subject == other).to be false
70
- end
71
- end
72
-
73
- context "when the query is an identical string match" do
74
- let(:other) { QueryString.new(query) }
75
- it "returns true" do
76
- expect(subject == other).to be true
77
- end
78
- end
79
- end
80
-
81
- describe "#to_s" do
82
- it "returns the query string" do
83
- expect(subject.to_s).to eq query
84
- end
85
- end
86
-
87
- end
88
-
89
- context "when the query is nil" do
90
-
91
- let(:query) { nil }
92
-
93
- describe "#as_json" do
94
- it "returns the query as a string" do
95
- expect(subject.as_json).to eq query
96
- end
97
- end
98
-
99
- describe "#to_json" do
100
- it "returns the query as JSON" do
101
- expect(subject.to_json).to eq query.to_json
102
- end
103
- end
104
-
105
- describe "#==" do
106
- context "when the query is not an identical string match" do
107
- let(:other) { QueryString.new("param=thing2")}
108
- it "returns false" do
109
- expect(subject == other).to be false
110
- end
111
- end
112
-
113
- context "when the query is an identical string match" do
114
- let(:other) { QueryString.new(query) }
115
- it "returns true" do
116
- expect(subject == other).to be true
117
- end
118
- end
119
- end
120
-
121
- describe "#to_s" do
122
- it "returns the query string" do
123
- expect(subject.to_s).to eq query
124
- end
125
- end
126
-
127
- end
128
-
129
-
130
- end
131
- end
@@ -1,486 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/consumer_contract/request'
3
- require 'pact/consumer/request'
4
- require 'support/shared_examples_for_request'
5
-
6
- module Pact
7
-
8
- describe Request::Expected do
9
- it_behaves_like "a request"
10
-
11
- let(:raw_request) do
12
- {
13
- 'method' => 'get',
14
- 'path' => '/mallory'
15
- }
16
- end
17
-
18
- describe "from_hash" do
19
- context "when optional field are not defined" do
20
- subject { described_class.from_hash(raw_request) }
21
- it "sets their values to NullExpectation" do
22
- expect(subject.body).to be_instance_of(Pact::NullExpectation)
23
- expect(subject.query).to be_instance_of(Pact::NullExpectation)
24
- expect(subject.headers).to be_instance_of(Pact::NullExpectation)
25
- end
26
- end
27
- end
28
-
29
- describe "matches_route?" do
30
- context "when the case of the method is different but the path is the same" do
31
- subject { Request::Expected.from_hash(method: 'get', path: '/') }
32
- let(:other) { Consumer::Request::Actual.from_hash(method: 'get', path: '/', query: nil, headers: {}) }
33
-
34
- it "returns true" do
35
- expect(subject.matches_route?(other)).to be true
36
- end
37
- end
38
-
39
- context "when the path is a Pact::Term" do
40
- subject { Request::Expected.from_hash(method: 'get', path: Pact::Term.new(matcher: %r{/alligators/.*}, generate: '/alligators/Mary')) }
41
- let(:other) { Consumer::Request::Actual.from_hash(method: 'get', path: '/alligators/John', query: nil, headers: {}) }
42
-
43
- it "returns true" do
44
- expect(subject.matches_route?(other)).to be true
45
- end
46
- end
47
- end
48
-
49
- describe "matching to actual requests" do
50
-
51
- subject { Request::Expected.new(expected_method, expected_path, expected_headers, expected_body, expected_query, options) }
52
- let(:options) { {} }
53
-
54
- let(:expected_method) { 'get' }
55
- let(:expected_path) { '/foo' }
56
- let(:expected_headers) { Pact::NullExpectation.new }
57
- let(:expected_body) { Pact::NullExpectation.new }
58
- let(:expected_query) { '' }
59
-
60
- let(:actual_request) { Consumer::Request::Actual.new(actual_method, actual_path, actual_headers, actual_body, actual_query) }
61
-
62
- let(:actual_method) { 'get' }
63
- let(:actual_path) { '/foo' }
64
- let(:actual_headers) { {} }
65
- let(:actual_body) { '' }
66
- let(:actual_query) { '' }
67
-
68
- it "matches identical requests" do
69
- expect(subject.matches? actual_request).to be true
70
- end
71
-
72
- context "when the Content-Type header is a Pact::Term" do
73
- let(:expected_headers) { {'Content-Type' => Pact::Term.new(generate: 'application/json', matcher: /json/) } }
74
- let(:expected_body) { {'foo' => 'bar'} }
75
- let(:actual_headers) { {'Content-Type' => 'foo/json'} }
76
- let(:actual_body) { {'foo' => 'bar'} }
77
-
78
- it "reifies the term before matching" do
79
- expect(subject.matches? actual_request).to be true
80
- end
81
- end
82
-
83
- context "when the methods are the same but one is symbolized" do
84
- let(:expected_method) { :get }
85
- let(:actual_method) { 'get' }
86
-
87
- it "matches" do
88
- expect(subject.matches? actual_request).to be true
89
- end
90
- end
91
-
92
- context "when the methods are different" do
93
- let(:expected_method) { 'get' }
94
- let(:actual_method) { 'post' }
95
-
96
- it "does not match" do
97
- expect(subject.matches? actual_request).to be false
98
- end
99
- end
100
-
101
- context "when the methods are the same but different case" do
102
- let(:expected_method) { 'get' }
103
- let(:actual_method) { 'GET' }
104
-
105
- it "matches" do
106
- expect(subject.matches? actual_request).to be true
107
- end
108
- end
109
-
110
- context "when the paths are different" do
111
- let(:expected_path) { '/foo' }
112
- let(:actual_path) { '/bar' }
113
-
114
- it "does not match" do
115
- expect(subject.matches? actual_request).to be false
116
- end
117
- end
118
-
119
- context "when the paths vary only by a trailing slash" do
120
- let(:expected_path) { '/foo' }
121
- let(:actual_path) { '/foo/' }
122
-
123
- it "does not match" do
124
- expect(subject.matches? actual_request).to be false
125
- end
126
- end
127
-
128
- context "when the expected body is nil and the actual body is empty" do
129
- let(:expected_body) { nil }
130
- let(:actual_body) { '' }
131
-
132
- it "does not match" do
133
- expect(subject.matches? actual_request).to be false
134
- end
135
- end
136
-
137
- context "when the expected body has no expectation and the actual body is empty" do
138
- let(:expected_body) { Pact::NullExpectation.new }
139
- let(:actual_body) { '' }
140
-
141
- it "matches" do
142
- expect(subject.matches? actual_request).to be true
143
- end
144
- end
145
-
146
- context "when the expected body is nested and the actual body is nil" do
147
- let(:expected_body) do
148
- {
149
- a: 'a'
150
- }
151
- end
152
-
153
- let(:actual_body) { nil }
154
-
155
- it "does not match" do
156
- expect(subject.matches? actual_request).to be false
157
- end
158
- end
159
-
160
- context "when the bodies are different" do
161
- let(:expected_body) { 'foo' }
162
- let(:actual_body) { 'bar' }
163
-
164
- it "does not match" do
165
- expect(subject.matches? actual_request).to be false
166
- end
167
- end
168
-
169
- context "when the expected body contains matching regexes" do
170
- let(:expected_body) do
171
- {
172
- name: 'Bob',
173
- customer_id: /CN.*/
174
- }
175
- end
176
-
177
- let(:actual_body) do
178
- {
179
- name: 'Bob',
180
- customer_id: 'CN1234'
181
- }
182
- end
183
-
184
- it "matches" do
185
- expect(subject.matches? actual_request).to be true
186
- end
187
- end
188
-
189
- context "when the expected body contains non-matching regexes" do
190
- let(:expected_body) do
191
- {
192
- name: 'Bob',
193
- customer_id: /foo/
194
- }
195
- end
196
-
197
- let(:actual_body) do
198
- {
199
- name: 'Bob',
200
- customer_id: 'CN1234'
201
- }
202
- end
203
-
204
- it "does not match" do
205
- expect(subject.matches? actual_request).to be false
206
- end
207
- end
208
-
209
- context "when the expected body contains matching terms" do
210
- let(:expected_body) do
211
- {
212
- name: 'Bob',
213
- customer_id: Term.new(matcher: /CN.*/, generate: 'CN789')
214
- }
215
- end
216
-
217
- let(:actual_body) do
218
- {
219
- name: 'Bob',
220
- customer_id: 'CN1234'
221
- }
222
- end
223
-
224
- it "matches" do
225
- expect(subject.matches? actual_request).to be true
226
- end
227
- end
228
-
229
- context "when the expected body contains non-matching terms" do
230
- let(:expected_body) do
231
- {
232
- name: 'Bob',
233
- customer_id: Term.new(matcher: /foo/, generate: 'fooool')
234
- }
235
- end
236
-
237
- let(:actual_body) do
238
- {
239
- name: 'Bob',
240
- customer_id: 'CN1234'
241
- }
242
- end
243
-
244
- it "does not match" do
245
- expect(subject.matches? actual_request).to be false
246
- end
247
- end
248
-
249
- context "when the expected body contains non-matching arrays" do
250
- let(:expected_body) do
251
- {
252
- name: 'Robert',
253
- nicknames: ['Bob', 'Bobert']
254
- }
255
- end
256
-
257
- let(:actual_body) do
258
- {
259
- name: 'Bob',
260
- nicknames: ['Bob']
261
- }
262
- end
263
-
264
- it "does not match" do
265
- expect(subject.matches? actual_request).to be false
266
- end
267
- end
268
- context "when the expected body contains non-matching hash where one field contains a substring of the other" do
269
- let(:expected_body) do
270
- {
271
- name: 'Robert',
272
- }
273
- end
274
-
275
- let(:actual_body) do
276
- {
277
- name: 'Rob'
278
- }
279
- end
280
-
281
- it "does not match" do
282
- expect(subject.matches? actual_request).to be false
283
- end
284
- end
285
-
286
- context "when the expected body contains matching arrays" do
287
- let(:expected_body) do
288
- {
289
- name: 'Robert',
290
- nicknames: ['Bob', 'Bobert']
291
- }
292
- end
293
-
294
- let(:actual_body) do
295
- {
296
- name: 'Robert',
297
- nicknames: ['Bob', 'Bobert']
298
- }
299
- end
300
-
301
- it "does not match" do
302
- expect(subject.matches? actual_request).to be true
303
- end
304
- end
305
-
306
- context "when the queries are different" do
307
- let(:expected_query) { 'foo' }
308
- let(:actual_query) { 'bar' }
309
-
310
- it "does not match" do
311
- expect(subject.matches? actual_request).to be false
312
- end
313
- end
314
-
315
- context 'when there is no query expectation' do
316
- let(:expected_query) { Pact::NullExpectation.new }
317
- let(:actual_query) { 'bar' }
318
-
319
- it 'matches' do
320
- expect(subject.matches? actual_request).to be true
321
- end
322
- end
323
-
324
- context 'when a query is specified' do
325
- context 'when the queries are defined by hashes, order does not matter' do
326
- let(:expected_query) { { params: 'hello', params2: 'world', params3: 'small' } }
327
- let(:actual_query) { 'params3=small&params2=world&params=hello' }
328
-
329
- it "does match" do
330
- expect(subject.matches? actual_request).to be true
331
- end
332
- end
333
-
334
- context 'when the queries are defined by nested hashes' do
335
- let(:expected_query) { { params: 'hello', nested: { a: { aa: '11', bb: '22' }, b: '2' }, params3: 'small' } }
336
- let(:actual_query) { 'params3=small&nested[a][aa]=11&nested[a][bb]=22&nested[b]=2&params=hello' }
337
-
338
- it "does match" do
339
- expect(subject.matches? actual_request).to be true
340
- end
341
- end
342
-
343
- context 'when the queries are defined by hashes, order does not matter but content does' do
344
- let(:expected_query) { { params: 'hello', params2: 'world', params3: 'small' } }
345
- let(:actual_query) { 'params3=big&params2=world&params=hello' }
346
-
347
- it "does not match" do
348
- expect(subject.matches? actual_request).to be false
349
- end
350
- end
351
-
352
- context 'when the queries are defined by hashes, with extra unmatched parameters' do
353
- let(:expected_query) { { params: 'hello', params2: 'world', params3: 'small' } }
354
- let(:actual_query) { 'params2=world&params=hello' }
355
-
356
- it "does not match" do
357
- expect(subject.matches? actual_request).to be false
358
- end
359
- end
360
-
361
- context 'when the queries are defined by hashes holding Pact Terms, order does not matter but content does' do
362
- let(:expected_query) { { params: 'hello', params2: Term.new(generate: 'world', matcher: /w\w+/), params3: 'small' } }
363
- let(:actual_query) { 'params3=small&params=hello&params2=wroom'}
364
-
365
- it "does match" do
366
- expect(subject.matches? actual_request).to be true
367
- end
368
- end
369
-
370
- context 'when the queries are defined by nested hashes holding Pact Terms, order does not matter but content does' do
371
- let(:expected_query) { { params: { a: 'hello', b: Term.new(generate: 'world', matcher: /w\w+/) } } }
372
- let(:actual_query) { 'params[a]=hello&params[b]=wroom'}
373
-
374
- it "does match" do
375
- expect(subject.matches? actual_request).to be true
376
- end
377
- end
378
-
379
- context 'when the queries are defined by hashes holding Pact Terms and the regex does not match' do
380
- let(:expected_query) { { params: 'hello', params2: Term.new(generate: 'world', matcher: /w\w+/), params3: 'small' } }
381
- let(:actual_query) { 'params3=small&params=hello&params2=bonjour'}
382
-
383
- it "does not match" do
384
- expect(subject.matches? actual_request).to be false
385
- end
386
- end
387
-
388
- context 'when the queries are defined by nested hashes holding Pact Terms and the regex does not match' do
389
- let(:expected_query) { { params: { a: 'hello', b: Term.new(generate: 'world', matcher: /w\w+/) } } }
390
- let(:actual_query) { 'params[a]=hello&params[b]=bonjour'}
391
-
392
- it "does match" do
393
- expect(subject.matches? actual_request).to be false
394
- end
395
- end
396
-
397
- context 'when the query is a hash containing arrays, to denote multiple parameters with the same name' do
398
- let(:expected_query) {
399
- { simple_param: "hi",
400
- double_param: ["hello", "world"],
401
- simple2: "bye",
402
- }
403
- }
404
- context 'when the multipe terms are in the correct order - order 1' do
405
- let(:actual_query) {['simple_param=hi', 'double_param=hello', 'double_param=world', 'simple2=bye'].join('&')}
406
- it "does match" do
407
- expect(subject.matches? actual_request).to be true
408
- end
409
- end
410
- context 'when the multipe terms are in the correct order - order 2' do
411
- let(:actual_query) {['simple_param=hi', 'double_param=hello', 'simple2=bye', 'double_param=world'].join('&')}
412
- it "does match" do
413
- expect(subject.matches? actual_request).to be true
414
- end
415
- end
416
- context 'when the multipe terms are in the correct order - order 3' do
417
- let(:actual_query) {['simple2=bye', 'double_param=hello', 'double_param=world', 'simple_param=hi'].join('&')}
418
- it "does match" do
419
- expect(subject.matches? actual_request).to be true
420
- end
421
- end
422
- context 'when the multiple terms are in incorrect order' do
423
- let(:actual_query) {['simple2=bye', 'double_param=world', 'double_param=hello', 'simple_param=hi'].join('&')}
424
- it "does not match" do
425
- expect(subject.matches? actual_request).to be false
426
- end
427
- end
428
- context 'when the first of the multiple terms is missing' do
429
- let(:actual_query) {['simple_param=hi', 'double_param=world', 'simple2=bye', ].join('&')}
430
- it "does not match" do
431
- expect(subject.matches? actual_request).to be false
432
- end
433
- end
434
- context 'when the last of the multiple terms is missing' do
435
- let(:actual_query) {['simple_param=hi', 'double_param=hello', 'simple2=bye', ].join('&')}
436
- it "does not match" do
437
- expect(subject.matches? actual_request).to be false
438
- end
439
- end
440
- end
441
-
442
- context 'when the query does not contain multiple params of the same name, but the request does' do
443
- let(:expected_query) { {param1: 'hi', param2: 'there'} }
444
- context 'when the param is duplicated' do
445
- let(:actual_query) { 'param1=hi&param2=there&param2=there'}
446
- it "does not match" do
447
- expect(subject.matches? actual_request).to be false
448
- end
449
- end
450
- context 'when the duplicated param has different values' do
451
- let(:actual_query) { 'param1=hi&param2=there&param2=overthere' }
452
- it "does not match" do
453
- expect(subject.matches? actual_request).to be false
454
- end
455
- end
456
- end
457
- end
458
-
459
- context "when in the body a string is expected, but a number is found" do
460
- let(:actual_body) { { thing: 123} }
461
- let(:expected_body) { { thing: "123" } }
462
-
463
- it 'does not match' do
464
- expect(subject.matches? actual_request).to be false
465
- end
466
- end
467
-
468
- context "when unexpected keys are found in the body" do
469
- let(:expected_body) { {a: 1} }
470
- let(:actual_body) { {a: 1, b: 2} }
471
- context "when allowing unexpected keys" do
472
- let(:options) { {'allow_unexpected_keys_in_body' => true} } #From json, these will be strings
473
- it "matches" do
474
- expect(subject.matches? actual_request).to be true
475
- end
476
- end
477
- context "when not allowing unexpected keys" do
478
- let(:options) { {'allow_unexpected_keys_in_body' => false} }
479
- it "does not match" do
480
- expect(subject.matches? actual_request).to be false
481
- end
482
- end
483
- end
484
- end
485
- end
486
- end