pact-support 1.9.0 → 1.15.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 (112) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +124 -0
  3. data/lib/pact/configuration.rb +7 -0
  4. data/lib/pact/consumer_contract/consumer_contract.rb +12 -1
  5. data/lib/pact/consumer_contract/http_consumer_contract_parser.rb +1 -1
  6. data/lib/pact/consumer_contract/interaction.rb +5 -1
  7. data/lib/pact/consumer_contract/interaction_v2_parser.rb +9 -1
  8. data/lib/pact/consumer_contract/interaction_v3_parser.rb +22 -3
  9. data/lib/pact/consumer_contract/pact_file.rb +32 -1
  10. data/lib/pact/matchers/matchers.rb +33 -13
  11. data/lib/pact/matching_rules/v3/merge.rb +4 -2
  12. data/lib/pact/shared/multipart_form_differ.rb +2 -0
  13. data/lib/pact/support/version.rb +1 -1
  14. data/lib/pact/term.rb +0 -1
  15. metadata +5 -228
  16. data/.gitignore +0 -32
  17. data/.rspec +0 -3
  18. data/.travis.yml +0 -29
  19. data/Appraisals +0 -7
  20. data/Gemfile +0 -4
  21. data/RELEASING.md +0 -5
  22. data/Rakefile +0 -4
  23. data/gemfiles/default.gemfile +0 -5
  24. data/gemfiles/ruby_under_22.gemfile +0 -8
  25. data/pact-support.gemspec +0 -39
  26. data/script/release.sh +0 -9
  27. data/script/update-pact-specification-v2 +0 -9
  28. data/spec/fixtures/interaction-with-matching-rules.json +0 -27
  29. data/spec/fixtures/multipart-form-diff.txt +0 -9
  30. data/spec/fixtures/not-a-pact.json +0 -3
  31. data/spec/fixtures/pact-http-v2.json +0 -36
  32. data/spec/fixtures/pact-http-v3.json +0 -36
  33. data/spec/integration/matching_rules_extract_and_merge_spec.rb +0 -127
  34. data/spec/lib/pact/array_like_spec.rb +0 -37
  35. data/spec/lib/pact/configuration_spec.rb +0 -61
  36. data/spec/lib/pact/consumer/request_spec.rb +0 -25
  37. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  38. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -142
  39. data/spec/lib/pact/consumer_contract/file_name_spec.rb +0 -24
  40. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  41. data/spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb +0 -25
  42. data/spec/lib/pact/consumer_contract/interaction_parser_spec.rb +0 -62
  43. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -121
  44. data/spec/lib/pact/consumer_contract/interaction_v2_parser_spec.rb +0 -54
  45. data/spec/lib/pact/consumer_contract/interaction_v3_parser_spec.rb +0 -48
  46. data/spec/lib/pact/consumer_contract/pact_file_spec.rb +0 -204
  47. data/spec/lib/pact/consumer_contract/query_hash_spec.rb +0 -154
  48. data/spec/lib/pact/consumer_contract/query_string_spec.rb +0 -131
  49. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -486
  50. data/spec/lib/pact/consumer_contract/response_spec.rb +0 -82
  51. data/spec/lib/pact/helpers_spec.rb +0 -143
  52. data/spec/lib/pact/matchers/differ_spec.rb +0 -215
  53. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  54. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  55. data/spec/lib/pact/matchers/extract_diff_messages_spec.rb +0 -78
  56. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  57. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -121
  58. data/spec/lib/pact/matchers/matchers_array_like_spec.rb +0 -222
  59. data/spec/lib/pact/matchers/matchers_messages_hash_and_array_spec.rb +0 -146
  60. data/spec/lib/pact/matchers/matchers_messages_mismatched_value_spec.rb +0 -71
  61. data/spec/lib/pact/matchers/matchers_messages_regexp_spec.rb +0 -103
  62. data/spec/lib/pact/matchers/matchers_spec.rb +0 -521
  63. data/spec/lib/pact/matchers/multipart_form_diff_formatter_spec.rb +0 -36
  64. data/spec/lib/pact/matchers/no_diff_at_index_spec.rb +0 -15
  65. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  66. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -36
  67. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  68. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  69. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -235
  70. data/spec/lib/pact/matching_rules/extract_spec.rb +0 -216
  71. data/spec/lib/pact/matching_rules/merge_spec.rb +0 -436
  72. data/spec/lib/pact/matching_rules/v3/extract_spec.rb +0 -238
  73. data/spec/lib/pact/matching_rules/v3/merge_spec.rb +0 -485
  74. data/spec/lib/pact/matching_rules_spec.rb +0 -82
  75. data/spec/lib/pact/reification_spec.rb +0 -172
  76. data/spec/lib/pact/shared/dsl_spec.rb +0 -100
  77. data/spec/lib/pact/shared/form_differ_spec.rb +0 -71
  78. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  79. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  80. data/spec/lib/pact/shared/multipart_form_differ_spec.rb +0 -39
  81. data/spec/lib/pact/shared/request_spec.rb +0 -235
  82. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  83. data/spec/lib/pact/something_like_spec.rb +0 -23
  84. data/spec/lib/pact/support_spec.rb +0 -9
  85. data/spec/lib/pact/symbolize_keys_spec.rb +0 -15
  86. data/spec/lib/pact/term_spec.rb +0 -89
  87. data/spec/pact_specification/compliance-2.0.rb +0 -66
  88. data/spec/spec_helper.rb +0 -18
  89. data/spec/support/a_consumer-a_producer.json +0 -32
  90. data/spec/support/a_consumer-a_provider.json +0 -32
  91. data/spec/support/active_support_if_configured.rb +0 -6
  92. data/spec/support/case-insensitive-response-header-matching.json +0 -21
  93. data/spec/support/consumer_contract_template.json +0 -24
  94. data/spec/support/dsl_spec_support.rb +0 -7
  95. data/spec/support/factories.rb +0 -87
  96. data/spec/support/generated_index.md +0 -4
  97. data/spec/support/generated_markdown.md +0 -55
  98. data/spec/support/interaction_view_model.json +0 -63
  99. data/spec/support/interaction_view_model_with_terms.json +0 -50
  100. data/spec/support/markdown_pact.json +0 -48
  101. data/spec/support/missing_provider_states_output.txt +0 -25
  102. data/spec/support/options.json +0 -21
  103. data/spec/support/ruby_version_helpers.rb +0 -23
  104. data/spec/support/shared_examples_for_request.rb +0 -132
  105. data/spec/support/spec_support.rb +0 -29
  106. data/spec/support/stubbing.json +0 -22
  107. data/spec/support/term.json +0 -48
  108. data/spec/support/test_app_fail.json +0 -61
  109. data/spec/support/test_app_pass.json +0 -38
  110. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  111. data/tasks/release.rake +0 -5
  112. data/tasks/spec.rake +0 -14
@@ -1,485 +0,0 @@
1
- require 'pact/matching_rules/v3/merge'
2
-
3
- module Pact
4
- module MatchingRules
5
- module V3
6
- describe Merge do
7
- subject { Merge.(expected, matching_rules) }
8
-
9
- before do
10
- allow($stderr).to receive(:puts) do | message |
11
- raise "Was not expecting stderr to receive #{message.inspect} in this spec. This may be because of a missed rule deletion in Merge."
12
- end
13
- end
14
-
15
- describe "no recognised rules" do
16
- before do
17
- allow($stderr).to receive(:puts)
18
- end
19
-
20
- let(:expected) do
21
- {
22
- "_links" => {
23
- "self" => {
24
- "href" => "http://localhost:1234/thing"
25
- }
26
- }
27
- }
28
- end
29
-
30
- let(:matching_rules) do
31
- {
32
- "$._links.self.href" => {
33
- "matchers" => [{ "type" => "unknown" }]
34
- }
35
- }
36
- end
37
-
38
- it "returns the object at that path unaltered" do
39
- expect(subject["_links"]["self"]["href"]).to eq "http://localhost:1234/thing"
40
- end
41
-
42
- it "it logs the rules it has ignored" do
43
- expect($stderr).to receive(:puts) do | message |
44
- expect(message).to include("WARN")
45
- expect(message).to include("type")
46
- expect(message).to include("unknown")
47
- expect(message).to include("$['_links']")
48
- end
49
- subject
50
- end
51
-
52
- end
53
-
54
- describe "with nil rules" do
55
- let(:expected) do
56
- {
57
- "_links" => {
58
- "self" => {
59
- "href" => "http://localhost:1234/thing"
60
- }
61
- }
62
- }
63
- end
64
-
65
- let(:matching_rules) { nil }
66
-
67
- it "returns the example unaltered" do
68
- expect(subject["_links"]["self"]["href"]).to eq "http://localhost:1234/thing"
69
- end
70
-
71
- end
72
-
73
- describe "type based matching" do
74
- before do
75
- allow($stderr).to receive(:puts)
76
- end
77
-
78
- let(:expected) do
79
- {
80
- "name" => "Mary"
81
- }
82
- end
83
-
84
- let(:matching_rules) do
85
- {
86
- "$.name" => {
87
- "matchers" => [{ "match" => "type", "ignored" => "matchingrule" }]
88
- }
89
- }
90
- end
91
-
92
- it "creates a SomethingLike at the appropriate path" do
93
- expect(subject['name']).to be_instance_of(Pact::SomethingLike)
94
- end
95
-
96
- it "it logs the rules it has ignored" do
97
- expect($stderr).to receive(:puts).once.with(/ignored.*matchingrule/)
98
- subject
99
- end
100
-
101
- it "does not alter the passed in rules hash" do
102
- original_matching_rules = JSON.parse(matching_rules.to_json)
103
- subject
104
- expect(matching_rules).to eq original_matching_rules
105
- end
106
- end
107
-
108
- describe "when a Pact.like is nested inside a Pact.each_like which is nested inside a Pact.like" do
109
- let(:original_definition) do
110
- Pact.like('foos' => Pact.each_like(Pact.like('name' => "foo1")))
111
- end
112
-
113
- let(:expected) do
114
- Pact::Reification.from_term(original_definition)
115
- end
116
-
117
- let(:matching_rules) do
118
- Extract.call(original_definition)
119
- end
120
-
121
- it "creates a Pact::SomethingLike containing a Pact::ArrayLike containing a Pact::SomethingLike" do
122
- expect(subject.to_hash).to eq original_definition.to_hash
123
- end
124
- end
125
-
126
- describe "when a Pact.array_like is the top level object" do
127
- let(:original_definition) do
128
- Pact.each_like('foos')
129
- end
130
-
131
- let(:expected) do
132
- Pact::Reification.from_term(original_definition)
133
- end
134
-
135
- let(:matching_rules) do
136
- Extract.call(original_definition)
137
- end
138
-
139
- it "creates a Pact::ArrayLike" do
140
- expect(subject.to_hash).to eq original_definition.to_hash
141
- end
142
- end
143
-
144
- describe "when a Pact.like containing an array is the top level object" do
145
- let(:original_definition) do
146
- Pact.like(['foos'])
147
- end
148
-
149
- let(:expected) do
150
- Pact::Reification.from_term(original_definition).tap { |it| puts it }
151
- end
152
-
153
- let(:matching_rules) do
154
- Extract.call(original_definition).tap { |it| puts it }
155
- end
156
-
157
- it "creates a Pact::SomethingLike" do
158
- expect(subject).to be_a(Pact::SomethingLike)
159
- expect(subject.to_hash).to eq original_definition.to_hash
160
- end
161
- end
162
-
163
- describe "regular expressions" do
164
- describe "in a hash" do
165
- before do
166
- allow($stderr).to receive(:puts)
167
- end
168
-
169
- let(:expected) do
170
- {
171
- "_links" => {
172
- "self" => {
173
- "href" => "http://localhost:1234/thing"
174
- }
175
- }
176
- }
177
- end
178
-
179
- let(:matching_rules) do
180
- {
181
- "$._links.self.href" => {
182
- "matchers" => [{ "regex" => "http:\\/\\/.*\\/thing", "match" => "regex", "ignored" => "somerule" }]
183
- }
184
- }
185
- end
186
-
187
- it "creates a Pact::Term at the appropriate path" do
188
- expect(subject["_links"]["self"]["href"]).to be_instance_of(Pact::Term)
189
- expect(subject["_links"]["self"]["href"].generate).to eq "http://localhost:1234/thing"
190
- expect(subject["_links"]["self"]["href"].matcher.inspect).to eq "/http:\\/\\/.*\\/thing/"
191
- end
192
-
193
- it "it logs the rules it has ignored" do
194
- expect($stderr).to receive(:puts) do | message |
195
- expect(message).to match /ignored.*"somerule"/
196
- expect(message).to_not match /regex/
197
- expect(message).to_not match /"match"/
198
- end
199
- subject
200
- end
201
- end
202
-
203
- describe "with an array" do
204
-
205
- let(:expected) do
206
- {
207
- "_links" => {
208
- "self" => [{
209
- "href" => "http://localhost:1234/thing"
210
- }]
211
- }
212
- }
213
- end
214
-
215
- let(:matching_rules) do
216
- {
217
- "$._links.self[0].href" => {
218
- "matchers" => [{ "regex" => "http:\\/\\/.*\\/thing" }]
219
- }
220
- }
221
- end
222
-
223
- it "creates a Pact::Term at the appropriate path" do
224
- expect(subject["_links"]["self"][0]["href"]).to be_instance_of(Pact::Term)
225
- expect(subject["_links"]["self"][0]["href"].generate).to eq "http://localhost:1234/thing"
226
- expect(subject["_links"]["self"][0]["href"].matcher.inspect).to eq "/http:\\/\\/.*\\/thing/"
227
- end
228
- end
229
-
230
- describe "with an ArrayLike containing a Term" do
231
- let(:expected) do
232
- ["foo"]
233
- end
234
-
235
- let(:matching_rules) do
236
- {
237
- "$" => {"matchers" => [{"min" => 1}]},
238
- "$[*].*" => {"matchers" => [{"match" => "type"}]},
239
- "$[*]" => {"matchers" => [{"match" => "regex", "regex"=>"f"}]}
240
- }
241
- end
242
-
243
- it "it creates an ArrayLike with a Pact::Term as the contents" do
244
- expect(subject).to be_a(Pact::ArrayLike)
245
- expect(subject.contents).to be_a(Pact::Term)
246
- end
247
- end
248
- end
249
-
250
- describe "with an array where all elements should match by type and the rule is specified on the parent element and there is no min specified" do
251
- let(:expected) do
252
- {
253
- 'alligators' => [{'name' => 'Mary'}]
254
- }
255
- end
256
-
257
- let(:matching_rules) do
258
- {
259
- "$.alligators" => {
260
- "matchers" => [{ 'match' => 'type' }]
261
- }
262
- }
263
- end
264
-
265
- it "creates a Pact::SomethingLike at the appropriate path" do
266
- expect(subject["alligators"]).to be_instance_of(Pact::SomethingLike)
267
- expect(subject["alligators"].contents).to eq ['name' => 'Mary']
268
- end
269
- end
270
-
271
- describe "with an array where all elements should match by type and the rule is specified on the child elements" do
272
- let(:expected) do
273
- {
274
- 'alligators' => [{'name' => 'Mary'}]
275
- }
276
- end
277
-
278
- let(:matching_rules) do
279
- {
280
- "$.alligators" => {
281
- "matchers" => [{ 'min' => 2}]
282
- },
283
- "$.alligators[*].*" => {
284
- "matchers" => [{ 'match' => 'type'}]
285
- }
286
- }
287
- end
288
- it "creates a Pact::ArrayLike at the appropriate path" do
289
- expect(subject["alligators"]).to be_instance_of(Pact::ArrayLike)
290
- expect(subject["alligators"].contents).to eq 'name' => 'Mary'
291
- expect(subject["alligators"].min).to eq 2
292
- end
293
- end
294
-
295
- describe "with an array where all elements should match by type and the rule is specified on both the parent element and the child elements" do
296
- let(:expected) do
297
- {
298
- 'alligators' => [{'name' => 'Mary'}]
299
- }
300
- end
301
-
302
- let(:matching_rules) do
303
- {
304
- "$.alligators" => {
305
- "matchers" => [{ 'min' => 2, 'match' => 'type' }]
306
- },
307
- "$.alligators[*].*" => {
308
- "matchers" => [{ 'match' => 'type' }]
309
- }
310
- }
311
- end
312
-
313
- it "creates a Pact::ArrayLike at the appropriate path" do
314
- expect(subject["alligators"]).to be_instance_of(Pact::SomethingLike)
315
- expect(subject["alligators"].contents).to be_instance_of(Pact::ArrayLike)
316
- expect(subject["alligators"].contents.contents).to eq 'name' => 'Mary'
317
- expect(subject["alligators"].contents.min).to eq 2
318
- end
319
- end
320
-
321
- describe "with an array where all elements should match by type and there is only a match:type on the parent element" do
322
- let(:expected) do
323
- {
324
- 'alligators' => [{'name' => 'Mary'}]
325
- }
326
- end
327
-
328
- let(:matching_rules) do
329
- {
330
- "$.alligators" => { 'matchers' => [{'min' => 2, 'match' => 'type'}] },
331
- }
332
- end
333
-
334
- it "creates a Pact::ArrayLike at the appropriate path" do
335
- expect(subject["alligators"]).to be_instance_of(Pact::ArrayLike)
336
- expect(subject["alligators"].contents).to eq 'name' => 'Mary'
337
- expect(subject["alligators"].min).to eq 2
338
- end
339
- end
340
-
341
- describe "with an array where all elements should match by type nested inside another array where all elements should match by type" do
342
- let(:expected) do
343
- {
344
-
345
- 'alligators' => [
346
- {
347
- 'name' => 'Mary',
348
- 'children' => [
349
- 'age' => 9
350
- ]
351
- }
352
- ]
353
-
354
- }
355
- end
356
-
357
- let(:matching_rules) do
358
- {
359
- "$.alligators" => { "matchers" => [{ 'min' => 2, 'match' => 'type' }] },
360
- "$.alligators[*].children" => { "matchers" => [{ 'min' => 1, 'match' => 'type' }]},
361
- }
362
- end
363
-
364
- it "creates a Pact::ArrayLike at the appropriate path" do
365
- expect(subject["alligators"].contents['children']).to be_instance_of(Pact::ArrayLike)
366
- expect(subject["alligators"].contents['children'].contents).to eq 'age' => 9
367
- expect(subject["alligators"].contents['children'].min).to eq 1
368
- end
369
- end
370
-
371
- describe "with an example array with more than one item" do
372
- before do
373
- allow($stderr).to receive(:puts)
374
- end
375
-
376
- let(:expected) do
377
- {
378
-
379
- 'alligators' => [
380
- {'name' => 'Mary'},
381
- {'name' => 'Joe'}
382
- ]
383
-
384
- }
385
- end
386
-
387
- let(:matching_rules) do
388
- {
389
- "$.alligators" => { "matchers" => [{'min' => 2, 'match' => 'type'}] }
390
- }
391
- end
392
-
393
- it "doesn't warn about the min size being ignored" do
394
- expect(Pact.configuration.error_stream).to receive(:puts).once
395
- subject
396
- end
397
-
398
- it "warns that the other items will be ignored" do
399
- allow(Pact.configuration.error_stream).to receive(:puts)
400
- expect(Pact.configuration.error_stream).to receive(:puts).with(/WARN: Only the first item/)
401
- subject
402
- end
403
- end
404
-
405
- describe "using bracket notation for a Hash" do
406
- let(:expected) do
407
- {
408
- "name" => "Mary"
409
- }
410
- end
411
-
412
- let(:matching_rules) do
413
- {
414
- "$['name']" => { "matchers" => [{"match" => "type"}] }
415
- }
416
- end
417
-
418
- it "applies the rule" do
419
- expect(subject['name']).to be_instance_of(Pact::SomethingLike)
420
- end
421
- end
422
-
423
- describe "with a dot in the path" do
424
- let(:expected) do
425
- {
426
- "first.name" => "Mary"
427
- }
428
- end
429
-
430
- let(:matching_rules) do
431
- {
432
- "$['first.name']" => { "matchers" => [{ "match" => "type" }] }
433
- }
434
- end
435
-
436
- it "applies the rule" do
437
- expect(subject['first.name']).to be_instance_of(Pact::SomethingLike)
438
- end
439
- end
440
-
441
- describe "with an @ in the path" do
442
- let(:expected) do
443
- {
444
- "@name" => "Mary"
445
- }
446
- end
447
-
448
- let(:matching_rules) do
449
- {
450
- "$['@name']" => { "matchers" => [ { "match" => "type" }] }
451
- }
452
- end
453
-
454
- it "applies the rule" do
455
- expect(subject['@name']).to be_instance_of(Pact::SomethingLike)
456
- end
457
- end
458
-
459
- describe "with a combine key" do
460
- let(:expected) do
461
- {
462
- "foo" => "bar"
463
- }
464
- end
465
-
466
- let(:matching_rules) do
467
- {
468
- "$.foo" => {
469
- "matchers" => [{ "match" => "type" }],
470
- "combine" => "AND"
471
- }
472
- }
473
-
474
- end
475
-
476
- it "logs the ignored rule" do
477
- allow(Pact.configuration.error_stream).to receive(:puts)
478
- expect(Pact.configuration.error_stream).to receive(:puts).with("WARN: Ignoring unsupported combine AND for path $['foo']")
479
- subject
480
- end
481
- end
482
- end
483
- end
484
- end
485
- end