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,54 +0,0 @@
1
- require 'pact/consumer_contract/interaction_v2_parser'
2
-
3
- module Pact
4
- describe InteractionV2Parser do
5
- describe ".call" do
6
- let(:interaction_hash) do
7
- {
8
- "description" => "description",
9
- "request" => { "method" => "GET", "path" => "/" },
10
- "response" => { "status" => 200 },
11
- "providerState" => "foo"
12
- }
13
- end
14
-
15
- let(:options) do
16
- {
17
- pact_specification_version: Pact::SpecificationVersion.new("3.0")
18
- }
19
- end
20
-
21
- subject { InteractionV2Parser.call(interaction_hash, options) }
22
-
23
- describe "provider_states" do
24
- it "returns an array of provider states with size 1" do
25
- expect(subject.provider_states.size).to eq 1
26
- end
27
-
28
- it "sets the name of the provider state to the string provided" do
29
- expect(subject.provider_states.first.name)
30
- end
31
-
32
- it "sets the params to an empty hash" do
33
- expect(subject.provider_states.first.params).to eq({})
34
- end
35
-
36
- context "when the providerState is nil" do
37
- before do
38
- interaction_hash["providerState"] = nil
39
- end
40
-
41
- it "returns an empty list" do
42
- expect(subject.provider_states).to be_empty
43
- end
44
- end
45
- end
46
-
47
- describe "provider_state" do
48
- it "sets the name from the hash" do
49
- expect(subject.provider_state).to eq "foo"
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,48 +0,0 @@
1
- require 'pact/consumer_contract/interaction_v3_parser'
2
-
3
- module Pact
4
- describe InteractionV3Parser do
5
- describe ".call" do
6
-
7
- let(:interaction_hash) do
8
- {
9
- "description" => "description",
10
- "request" => { "method" => "GET", "path" => "/" },
11
- "response" => { "status" => 200 },
12
- "providerStates" => [{
13
- "name" => "foo",
14
- "params" => {"a" => "b"}
15
- }]
16
- }
17
- end
18
-
19
- let(:options) do
20
- {
21
- pact_specification_version: Pact::SpecificationVersion.new("3.0")
22
- }
23
- end
24
-
25
- subject { InteractionV3Parser.call(interaction_hash, options) }
26
-
27
- describe "provider_states" do
28
- it "parses the array of provider states" do
29
- expect(subject.provider_states.size).to eq 1
30
- end
31
-
32
- it "parses the name of each" do
33
- expect(subject.provider_states.first.name)
34
- end
35
-
36
- it "parses the params of each" do
37
- expect(subject.provider_states.first.params).to eq "a" => "b"
38
- end
39
- end
40
-
41
- describe "provider_state" do
42
- it "sets the provider_state string to the name of the first providerState for backwards compatibility while we implement v3" do
43
- expect(subject.provider_state).to eq "foo"
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,204 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
- require 'pact/consumer_contract/pact_file'
4
- require 'base64' # XXX: https://github.com/bblimke/webmock/pull/611
5
-
6
- module Pact
7
- describe PactFile do
8
- describe 'render_pact' do
9
- let(:uri_without_userinfo) { 'http://pactbroker.com'}
10
- let(:pact_content) { 'api contract'}
11
-
12
- describe 'from a local file URI' do
13
- let(:temp_file) { Tempfile.new('local-pact-file') }
14
- let(:file_uri) { temp_file.path }
15
- let(:local_pact_content) { 'local pact content' }
16
- before do
17
- File.write file_uri, local_pact_content
18
- end
19
- after do
20
- temp_file.unlink
21
- end
22
-
23
- it 'reads from the local file system' do
24
- expect(PactFile.render_pact(file_uri, {})).to eq(local_pact_content)
25
- end
26
- end
27
-
28
- describe 'with backslashes to a local path' do
29
- let(:windows_path) { 'spec\support\a_consumer-a_provider.json' }
30
- let(:unix_path) { 'spec/support/a_consumer-a_provider.json' }
31
-
32
- it 'transforms them to forward slashes' do
33
- expect(PactFile.read(windows_path)).to eq PactFile.read(unix_path)
34
- end
35
- end
36
-
37
- context 'without basic authentication' do
38
- before do
39
- stub_request(:get, uri_without_userinfo).to_return(body: pact_content)
40
- end
41
-
42
- it 'should open uri to get pact file content' do
43
- expect(PactFile.render_pact(uri_without_userinfo, {})).to eq(pact_content)
44
- end
45
- end
46
-
47
- context 'basic authentication' do
48
- let(:username) { 'brokeruser'}
49
- let(:password) { 'brokerpassword'}
50
- let(:options) do
51
- { username: username, password: password }
52
- end
53
- before do
54
- stub_request(:get, uri_without_userinfo).with(basic_auth: [username, password]).to_return(body: pact_content)
55
- end
56
-
57
- context 'when userinfo is specified in the option' do
58
- it 'should open uri to get pact file content with userinfo in the options' do
59
- expect(PactFile.render_pact(uri_without_userinfo, options)).to eq(pact_content)
60
- end
61
-
62
- let(:uri_with_userinfo) { 'http://dummyuser:dummyps@pactbroker.com'}
63
-
64
- it 'should use userinfo in options which overwrites userinfo in url' do
65
- expect(PactFile.render_pact(uri_with_userinfo, options)).to eq(pact_content)
66
- end
67
- end
68
-
69
- context 'when user info is specified in url' do
70
- let(:uri_with_userinfo) { "http://#{username}:#{password}@pactbroker.com"}
71
-
72
- it 'should open uri to get pact file content with userinfo in the uri' do
73
- expect(PactFile.render_pact(uri_with_userinfo, {})).to eq(pact_content)
74
- end
75
- end
76
- end
77
-
78
- context 'with a token' do
79
- let(:token) { 'askfjlksjf'}
80
- let(:options) { { token: token } }
81
-
82
- let!(:request) do
83
- stub_request(:get, uri_without_userinfo).with(headers: {'Authorization' => 'Bearer askfjlksjf'}).to_return(body: pact_content)
84
- end
85
-
86
- it 'sets the Bearer Authorization header' do
87
- PactFile.render_pact(uri_without_userinfo, options)
88
- expect(request).to have_been_made
89
- end
90
-
91
- end
92
-
93
- describe 'retry feature' do
94
- before { allow(PactFile).to receive(:delay_retry).with(kind_of(Integer)) }
95
-
96
- def render_pact(options = {})
97
- PactFile.render_pact(uri_without_userinfo, options)
98
- end
99
-
100
- context 'with client error' do
101
- before { stub_request(:get, uri_without_userinfo).to_return(status: 400) }
102
-
103
- it 'raises client error without retrying' do
104
- expect(PactFile).not_to receive(:delay_retry)
105
- expect { render_pact }.to raise_error(PactFile::HttpError, /status=400/)
106
- end
107
- end
108
-
109
- context 'with single server error' do
110
- before do
111
- stub_request(:get, uri_without_userinfo).to_return(status: 500).
112
- then.to_return(status: 200, body: pact_content)
113
- end
114
-
115
- it 'retries and succeeds' do
116
- expect(render_pact).to eq(pact_content)
117
- end
118
- end
119
-
120
- context 'with continuous server errors' do
121
- before { stub_request(:get, uri_without_userinfo).to_return(status: 500) }
122
-
123
- it 'retries but failed by retry limit' do
124
- expect { render_pact }.to raise_error(PactFile::HttpError, /status=500/)
125
- end
126
- end
127
-
128
- context 'with single open timeout' do
129
- before do
130
- stub_request(:get, uri_without_userinfo).to_raise(Net::OpenTimeout).
131
- then.to_return(status: 200, body: pact_content)
132
- end
133
-
134
- it 'retries and succeeds' do
135
- expect(render_pact).to eq(pact_content)
136
- end
137
- end
138
-
139
- context 'with continuous open timeouts' do
140
- before { stub_request(:get, uri_without_userinfo).to_raise(Net::OpenTimeout) }
141
-
142
- it 'retries but failed by retry limit' do
143
- expect { render_pact }.to raise_error(Net::OpenTimeout)
144
- end
145
- end
146
-
147
- context 'with single read timeout' do
148
- before do
149
- stub_request(:get, uri_without_userinfo).to_raise(Net::ReadTimeout).
150
- then.to_return(status: 200, body: pact_content)
151
- end
152
-
153
- it 'retries and succeeds' do
154
- expect(render_pact).to eq(pact_content)
155
- end
156
- end
157
-
158
- context 'with continuous read timeout' do
159
- before { stub_request(:get, uri_without_userinfo).to_raise(Net::ReadTimeout) }
160
-
161
- it 'retries but failed by retry limit' do
162
- expect { render_pact }.to raise_error(Net::ReadTimeout)
163
- end
164
- end
165
-
166
- context 'with retry_limit option and server error' do
167
- before do
168
- stub_request(:get, uri_without_userinfo).to_return(status: 500).
169
- then.to_return(status: 200, body: pact_content)
170
- end
171
-
172
- it 'retries and succeeds' do
173
- expect { render_pact(retry_limit: 0) }.to raise_error(PactFile::HttpError, /status=500/)
174
- end
175
- end
176
-
177
- context 'with retry_limit option and open timeout error' do
178
- before do
179
- stub_request(:get, uri_without_userinfo).to_raise(Net::OpenTimeout).
180
- then.to_return(status: 200, body: pact_content)
181
- end
182
-
183
- it 'retries and succeeds' do
184
- expect { render_pact(retry_limit: 0) }.to raise_error(Net::OpenTimeout)
185
- end
186
- end
187
-
188
- context 'with retry_limit option which is greater than default retry limit' do
189
- before do
190
- stub_request(:get, uri_without_userinfo).to_return(status: 500).
191
- then.to_return(status: 500).
192
- then.to_return(status: 500).
193
- then.to_return(status: 500).
194
- then.to_return(status: 200, body: pact_content)
195
- end
196
-
197
- it 'retries and succeeds' do
198
- expect(render_pact(retry_limit: 4)).to eq(pact_content)
199
- end
200
- end
201
- end
202
- end
203
- end
204
- end
@@ -1,154 +0,0 @@
1
- require 'pact/consumer_contract/query_hash'
2
- require 'pact/consumer_contract/query_string'
3
-
4
- module Pact
5
- describe QueryHash do
6
-
7
- subject { QueryHash.new(query) }
8
-
9
- let(:query) { { param: 'thing' } }
10
- let(:query_with_array) { { param: ['thing'] } }
11
-
12
- describe "difference" do
13
- context "when the other is the same" do
14
-
15
- let(:other) { QueryString.new('param=thing') }
16
-
17
- it 'returns an empty diff' do
18
- expect(subject.difference(other)).to be_empty
19
- end
20
- end
21
-
22
- context "when the other is different" do
23
- let(:other) { QueryString.new('param=thing1') }
24
-
25
- it 'returns the diff' do
26
- expect(subject.difference(other)).to_not be_empty
27
- end
28
- end
29
-
30
- context "when the other has an extra param" do
31
- let(:other) { QueryString.new('param=thing&param2=blah') }
32
-
33
- it 'returns the diff' do
34
- expect(subject.difference(other)).to_not be_empty
35
- end
36
- end
37
-
38
- context "with nested query" do
39
- let(:query) { { param: { a: { aa: '11', bb: '22' }, b: '2' } } }
40
-
41
- context "when the other is same" do
42
- let(:other) { QueryString.new('param[b]=2&param[a][aa]=11&param[a][bb]=22') }
43
-
44
- it 'returns an empty diff' do
45
- expect(subject.difference(other)).to be_empty
46
- end
47
- end
48
-
49
- context "when the other has extra param" do
50
- let(:other) { QueryString.new('param[b]=2&param[c]=1') }
51
-
52
- it 'returns the diff' do
53
- expect(subject.difference(other)).not_to be_empty
54
- expect(subject.difference(other).keys).to contain_exactly(:"param[a][aa]", :"param[a][bb]", :"param[c]")
55
- end
56
- end
57
-
58
- context "when the other has different value with value difference" do
59
- let(:other) { QueryString.new('param[b]=2&param[a][aa]=00&param[a][bb]=22') }
60
-
61
- it 'returns the diff' do
62
- expect(subject.difference(other)).not_to be_empty
63
- expect(subject.difference(other).keys).to contain_exactly(:"param[a][aa]")
64
- end
65
- end
66
-
67
- context "when the other has different value without structural difference" do
68
- let(:other) { QueryString.new('param[b]=2&param[a]=11') }
69
-
70
- it 'returns the diff' do
71
- expect(subject.difference(other)).not_to be_empty
72
- expect(subject.difference(other).keys).to contain_exactly(:"param[a]", :"param[a][aa]", :"param[a][bb]")
73
- end
74
- end
75
-
76
- context "when there is an ArrayLike" do
77
- let(:query) { { param: Pact.each_like("1") } }
78
- let(:other) { QueryString.new('param=1&param=2') }
79
-
80
- it 'returns an empty diff' do
81
- expect(subject.difference(other)).to be_empty
82
- end
83
- end
84
- end
85
- end
86
-
87
- describe "#as_json" do
88
- it "returns the query as a Hash" do
89
- expect(subject.as_json).to eq query_with_array
90
- end
91
- end
92
-
93
- describe "#to_json" do
94
- context "when the query contains an ArrayLike" do
95
- let(:query) { { foo: Pact.each_like("1"), bar: "2" } }
96
- let(:expected_json) do
97
- {
98
- foo: Pact.each_like("1"),
99
- bar: ["2"]
100
- }.to_json
101
- end
102
-
103
- it "serialises the ArrayLike without wrapping an array around it" do
104
- expect(subject.to_json).to eq expected_json
105
- end
106
- end
107
-
108
- context "when the query contains a Pact::Term" do
109
- let(:term) { Pact::Term.new(generate: "thing", matcher: /th/) }
110
- let(:query) { { param: term } }
111
- let(:query_with_array) { { param: [term] } }
112
-
113
- it "serialises the Pact::Term as Ruby specific JSON" do
114
- expect(subject.to_json).to eq query_with_array.to_json
115
- end
116
- end
117
- end
118
-
119
- describe "#==" do
120
- context "when the query is not an identical match" do
121
- let(:other) { QueryHash.new(param: 'other thing')}
122
- it "returns false" do
123
- expect(subject == other).to be false
124
- end
125
- end
126
-
127
- context "when the query is an identical match" do
128
- let(:other) { QueryHash.new(query) }
129
- it "returns true" do
130
- expect(subject == other).to be true
131
- end
132
- end
133
- end
134
-
135
- describe "#to_s" do
136
- it "returns the query Hash as a string" do
137
- expect(subject.to_s).to eq query_with_array.to_s
138
- end
139
- end
140
-
141
- describe "#as_json" do
142
- it "returns the query Hash" do
143
- expect(subject.as_json).to eq query_with_array
144
- end
145
- end
146
-
147
- describe "#to_json" do
148
- it "returns the query Hash as JSON" do
149
- expect(subject.to_json).to eq query_with_array.to_json
150
- end
151
- end
152
-
153
- end
154
- end