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,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/key_not_found'
3
-
4
- module Pact
5
- describe KeyNotFound do
6
-
7
- describe "#as_json" do
8
- it "returns a string representation of the object" do
9
- expect(subject.as_json).to eq subject.to_s
10
- end
11
- end
12
-
13
- describe "#to_json" do
14
- it "serialises the object to JSON" do
15
- expect(subject.to_json).to eq "\"#{subject.to_s}\""
16
- end
17
- end
18
-
19
- end
20
- end
@@ -1,39 +0,0 @@
1
- require 'pact/shared/multipart_form_differ'
2
-
3
- module Pact
4
- describe MultipartFormDiffer do
5
-
6
- describe ".call" do
7
-
8
- let(:expected_body) do
9
- "-------------RubyMultipartPost-1e4912957c7bb64de3c444568326663b\r\nContent-Disposition: form-data; name=\"file\"; filename=\"text.txt\"\r\nContent-Length: 14\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nThis is a file\r\n-------------RubyMultipartPost-1e4912957c7bb64de3c444568326663b--\r\n\r\n"
10
- end
11
-
12
- let(:actual_body) do
13
- "-------------RubyMultipartPost-1e4912957c7bb64de3c4445683266XXX\r\nContent-Disposition: form-data; name=\"file\"; filename=\"text.txt\"\r\nContent-Length: 14\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nThis is a file\r\n-------------RubyMultipartPost-1e4912957c7bb64de3c4445683266XXX--\r\n\r\n"
14
- end
15
-
16
- let(:options) do
17
- {}
18
- end
19
-
20
- subject { MultipartFormDiffer.call(expected_body, actual_body, options) }
21
-
22
- context "when the bodies are the same apart from the boundary" do
23
- it "returns an empty diff" do
24
- expect(subject).to eq({})
25
- end
26
- end
27
-
28
- context "when the bodies are not the same" do
29
- let(:actual_body) do
30
- "-------------RubyMultipartPost-1e4912957c7bb64de3c4445683266XXX\r\nContent-Disposition: form-data; name=\"file\"; filename=\"bar.txt\"\r\nContent-Length: 14\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nThis is a file\r\n-------------RubyMultipartPost-1e4912957c7bb64de3c4445683266XXX--\r\n\r\n"
31
- end
32
-
33
- it "returns a text diff" do
34
- expect(subject).to_not eq({})
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,235 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/request'
3
- require 'pact/shared/key_not_found'
4
-
5
- module Pact
6
-
7
- module Request
8
-
9
- describe Base do
10
-
11
- class TestRequest < Base
12
-
13
- def self.key_not_found
14
- Pact::KeyNotFound.new
15
- end
16
-
17
- end
18
-
19
- subject { TestRequest.new("get", "/", {some: "things"}, {some: "things"} , "some=things") }
20
-
21
- describe "#full_path" do
22
-
23
- subject { TestRequest.new("get", "/something", {}, {some: "things"} , query).full_path }
24
-
25
- context "with a query that is a Pact::Term" do
26
- let(:query) { Pact::Term.new(generate: "some=things", matcher: /some/) }
27
- it "reifies and appends the query" do
28
- expect(subject).to eq("/something?some=things")
29
- end
30
- end
31
-
32
- context "with a query that is a string" do
33
- let(:query) { "some=things" }
34
- it "appends the query" do
35
- expect(subject).to eq("/something?some=things")
36
- end
37
- end
38
-
39
- context "with a query that is a hash" do
40
- let(:query) { { params: 'hello', params2: Term.new(generate: 'world', matcher: /w\w+/), params3: 'small' } }
41
- it "appends the query" do
42
- expect(subject).to eq("/something?params=hello&params2=world&params3=small")
43
- end
44
- end
45
-
46
- context "with an empty query" do
47
- let(:query) { "" }
48
- it "does include a query" do
49
- expect(subject).to eq("/something")
50
- end
51
- end
52
-
53
- context "with a nil query" do
54
- let(:query) { nil }
55
- it "does not include a query" do
56
- expect(subject).to eq("/something")
57
- end
58
- end
59
- end
60
-
61
- describe "#method_and_path" do
62
- context "with an empty path" do
63
- subject { TestRequest.new("get", "", {}, {} , "").method_and_path }
64
-
65
- it "includes a slash" do
66
- expect(subject).to eq("GET /")
67
- end
68
- end
69
-
70
- context "with a Pact::Term for the path" do
71
- subject { TestRequest.new("get", Pact::Term.new(matcher: /a/, generate: '/apple'), {}, {} , "").method_and_path }
72
-
73
- it "uses the generate value" do
74
- expect(subject).to eq("GET /apple")
75
- end
76
- end
77
-
78
- context "with a path" do
79
- subject { TestRequest.new("get", "/something", {}, {} , "").method_and_path }
80
-
81
- it "includes the path" do
82
- expect(subject).to eq("GET /something")
83
- end
84
- end
85
-
86
- context "with a query" do
87
- subject { TestRequest.new("get", "/something", {}, {} , "test=query").method_and_path }
88
-
89
- it "includes the query" do
90
- expect(subject).to eq("GET /something?test=query")
91
- end
92
- end
93
- end
94
-
95
- describe "#content_type" do
96
-
97
- subject { TestRequest.new("get", "/something", headers, {} , "") }
98
-
99
- context "when there are no expected headers" do
100
- let(:headers) { Pact::KeyNotFound.new }
101
- it "returns nil" do
102
- expect(subject.send(:content_type)).to be nil
103
- end
104
- end
105
- context "when there is no Content-Type header" do
106
- let(:headers) { {} }
107
- it "returns nil" do
108
- expect(subject.send(:content_type)).to be nil
109
- end
110
- end
111
- context "when there is a Content-Type header" do
112
- let(:headers) { {'Content-Type' => 'blah'} }
113
- it "returns the Content-Type" do
114
- expect(subject.send(:content_type)).to eq 'blah'
115
- end
116
- end
117
- context "when there is a content-type header" do
118
- let(:headers) { {'content-type' => 'blah'} }
119
- it "returns the content-type" do
120
- expect(subject.send(:content_type)).to eq 'blah'
121
- end
122
- end
123
- context "when the Content-Type header is a Pact::Term" do
124
- let(:headers) { {'Content-Type' => Pact::Term.new(generate: 'application/json', matcher: /json/)} }
125
- it "returns the reified Content-Type" do
126
- expect(subject.send(:content_type)).to eq 'application/json'
127
- end
128
- end
129
- end
130
-
131
- describe "content_type?" do
132
- subject { TestRequest.new("get", "/something", headers, {} , "") }
133
- let(:headers) { {'content-type' => 'blah'} }
134
-
135
- context "when the content type is the same" do
136
- it "returns true" do
137
- expect(subject.content_type?('blah')).to be true
138
- end
139
- end
140
- context "when the content type is not the same" do
141
- it "returns false" do
142
- expect(subject.content_type?('apple')).to be false
143
- end
144
- end
145
-
146
- end
147
-
148
- describe "modifies_resource?" do
149
-
150
- subject { Pact::Request::Expected.from_hash(request).modifies_resource? }
151
-
152
- shared_examples_for "may modify resource" do
153
- context "when the request body is not specified" do
154
- let(:request) { {method: http_method, path: '/'} }
155
-
156
- it "returns false" do
157
- expect(subject).to be false
158
- end
159
- end
160
-
161
- context "when the request body is an empty Hash" do
162
- let(:request) { {method: http_method, path: '/', body: {}} }
163
-
164
- it "returns true" do
165
- expect(subject).to be true
166
- end
167
- end
168
-
169
- context "when the request body is a Hash and not empty" do
170
- let(:request) { {method: http_method, path: '/', body: {some: 'body'}} }
171
-
172
- it "returns true" do
173
- expect(subject).to be true
174
- end
175
- end
176
-
177
- context "when the request body is a String and not empty" do
178
- let(:request) { {method: http_method, path: '/', body: 'some body'} }
179
-
180
- it "returns true" do
181
- expect(subject).to be true
182
- end
183
- end
184
-
185
- context "when the request body is a String and is empty" do
186
- let(:request) { {method: http_method, path: '/', body: ''} }
187
-
188
- it "returns true" do
189
- expect(subject).to be true
190
- end
191
- end
192
- end
193
-
194
- describe "when the method is PUT" do
195
- let(:http_method) { :put }
196
- include_examples 'may modify resource'
197
- end
198
-
199
- describe "when the method is POST" do
200
- let(:http_method) { :post }
201
- include_examples 'may modify resource'
202
- end
203
-
204
- describe "when the method is PATCH" do
205
- let(:http_method) { :post }
206
- include_examples 'may modify resource'
207
- end
208
-
209
- shared_examples_for "does not modify resource" do
210
- let(:request) { {method: http_method, path: '/', body: {some: 'body'}} }
211
-
212
- it "returns false" do
213
- expect(subject).to be false
214
- end
215
- end
216
-
217
- describe "when the method is GET" do
218
- let(:http_method) { :get }
219
- include_examples 'does not modify resource'
220
- end
221
-
222
- describe "when the method is DELETE" do
223
- let(:http_method) { :delete }
224
- include_examples 'does not modify resource'
225
- end
226
-
227
- describe "when the method is HEAD" do
228
- let(:http_method) { :head }
229
- include_examples 'does not modify resource'
230
- end
231
- end
232
-
233
- end
234
- end
235
- end
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/text_differ'
3
-
4
- module Pact
5
- describe TextDiffer do
6
-
7
- describe ".call" do
8
-
9
- subject { TextDiffer.call expected, actual }
10
-
11
- let(:expected) { "This is the string you are looking for" }
12
-
13
- context "when the expected and actual are both strings" do
14
-
15
- context "when they equal each other" do
16
- let(:actual) { "This is the string you are looking for" }
17
-
18
- it "returns an empty diff" do
19
- expect(subject.any?).to be false
20
- end
21
- end
22
-
23
- context "when they don't equal each other" do
24
- let(:actual) { "This is not the string you are looking for" }
25
-
26
- it "returns the diff" do
27
- expect(subject).to eq Pact::Matchers::Difference.new(expected, actual)
28
- end
29
- end
30
- end
31
-
32
- context "when the actual is not a String" do
33
- let(:actual) { {some: 'hash'} }
34
- let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
35
- it "returns the diff" do
36
- expect(subject)
37
- end
38
- end
39
-
40
- context "when the expected and actual are both objects" do
41
- let(:actual) { {some: 'hash', blah: 'blah'} }
42
- let(:expected) { {some: 'hash'} }
43
- let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
44
-
45
- it "returns the diff using the JSON matching logic, allowing extra keys. But should it really if the expected Content-Type isn't actually JSON?" do
46
- expect(subject)
47
- end
48
-
49
- it "potentially should treat both expected and actual as Strings"
50
- end
51
-
52
- end
53
- end
54
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pact
4
- describe SomethingLike do
5
-
6
- describe 'json_create' do
7
- let(:json) do
8
- '
9
- {
10
- "json_class": "Pact::SomethingLike",
11
- "contents" : { "thing" : "blah" }
12
- }
13
- '
14
- end
15
-
16
- subject { SomethingLike.json_create(JSON.parse(json)) }
17
-
18
- it "creates a SomethingLike object from json" do
19
- expect(subject).to eq(SomethingLike.new({"thing" => "blah"}))
20
- end
21
- end
22
- end
23
- end
@@ -1,9 +0,0 @@
1
- require 'pact/support'
2
-
3
- describe Pact do
4
-
5
- it "includes the Pact::Helpers" do
6
- expect(Pact).to respond_to(:each_like)
7
- end
8
-
9
- end
@@ -1,15 +0,0 @@
1
- require 'pact/symbolize_keys'
2
-
3
- module Pact
4
- module SymbolizeKeys
5
- describe "#symbolize_keys" do
6
- context "when nil is provided" do
7
- include Pact::SymbolizeKeys
8
-
9
- it "returns nil" do
10
- expect(symbolize_keys(nil)).to be nil
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pact
4
- describe Term do
5
-
6
- describe 'initialize' do
7
- let(:matcher) { /e/ }
8
- let(:generate) { 'apple'}
9
- subject { Term.new(generate: generate, matcher: matcher) }
10
- context "when a matcher and generate are specified" do
11
- context "when the matcher matches the generated value" do
12
- it 'does not raise an exception' do
13
- subject
14
- end
15
- end
16
-
17
- context "when the matcher does not match the generated value" do
18
- let(:generate) { 'banana' }
19
- it 'raises an exception' do
20
- expect { subject }.to raise_error /does not match/
21
- end
22
- end
23
- end
24
- context 'when a matcher is not specified' do
25
- let(:matcher) { nil }
26
- it 'raises an exception' do
27
- expect { subject }.to raise_error /Please specify a matcher/
28
- end
29
- end
30
- context 'when a generate is not specified' do
31
- let(:generate) { nil }
32
- it 'raises an exception' do
33
- expect { subject }.to raise_error /Please specify a value/
34
- end
35
- end
36
- end
37
-
38
- describe "equality" do
39
- context "when the matcher and generate attrs are the same" do
40
- let(:this) { Term.new(generate: 'A', matcher: /A/) }
41
- let(:that) { Term.new(generate: 'A', matcher: /A/) }
42
-
43
- it "is equal" do
44
- expect(this).to eq that
45
- end
46
- end
47
-
48
- context "when the generate attrs are different" do
49
- let(:this) { Term.new(generate: 'A', matcher: /.*/) }
50
- let(:that) { Term.new(generate: 'B', matcher: /.*/) }
51
-
52
- it "is not equal" do
53
- expect(this).to_not eq that
54
- end
55
- end
56
-
57
- context "when the matcher attrs are different" do
58
- let(:this) { Term.new(matcher: /A/, generate: 'AB') }
59
- let(:that) { Term.new(matcher: /B/, generate: 'AB') }
60
-
61
- it "is not equal" do
62
- expect(this).to_not eq that
63
- end
64
- end
65
- end
66
-
67
- describe 'empty?' do
68
-
69
- subject { Term.new(generate: 'some', matcher: /some/) }
70
-
71
- it 'should return false' do
72
- expect(subject).to_not be_empty
73
- end
74
-
75
- end
76
-
77
- describe 'unpack_regexps' do
78
- let(:term) { Term.new(generate: 'some', matcher: /s/) }
79
- let(:body) { [{a: [{b: term}], c:term, d: 1, e: 'blah'}] }
80
- let(:expected) { [{:a=>[{:b=>/s/}], :c=>/s/, :d=>1, :e=>"blah"}] }
81
-
82
- it "returns a structure with the Pact::Terms replaced by their regexps" do
83
- expect(Term.unpack_regexps(body)).to eq expected
84
- end
85
-
86
- end
87
-
88
- end
89
- end