pact 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +3 -3
- data/example/animal-service/Gemfile +14 -0
- data/example/animal-service/Gemfile.lock +67 -0
- data/example/animal-service/Rakefile +3 -0
- data/example/animal-service/spec/service_consumers/pact_helper.rb +24 -0
- data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +9 -0
- data/example/zoo-app/Gemfile.lock +2 -15
- data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +21 -6
- data/example/zoo-app/spec/service_providers/animal_service_spec.rb +1 -1
- data/lib/pact/consumer.rb +10 -11
- data/lib/pact/consumer/app_manager.rb +1 -0
- data/lib/pact/consumer/configuration.rb +179 -0
- data/lib/pact/consumer/interaction_builder.rb +1 -2
- data/lib/pact/consumer/mock_service.rb +1 -370
- data/lib/pact/consumer/mock_service/app.rb +70 -0
- data/lib/pact/consumer/mock_service/interaction_delete.rb +28 -0
- data/lib/pact/consumer/mock_service/interaction_list.rb +57 -0
- data/lib/pact/consumer/mock_service/interaction_post.rb +25 -0
- data/lib/pact/consumer/mock_service/interaction_replay.rb +126 -0
- data/lib/pact/consumer/mock_service/missing_interactions_get.rb +26 -0
- data/lib/pact/consumer/mock_service/rack_request_helper.rb +51 -0
- data/lib/pact/consumer/mock_service/startup_poll.rb +22 -0
- data/lib/pact/consumer/mock_service/verification_get.rb +35 -0
- data/lib/pact/consumer/mock_service_client.rb +3 -1
- data/lib/pact/consumer/mock_service_interaction_expectation.rb +33 -0
- data/lib/pact/consumer/request.rb +27 -0
- data/lib/pact/consumer/rspec.rb +1 -4
- data/lib/pact/consumer_contract/consumer_contract.rb +11 -8
- data/lib/pact/consumer_contract/interaction.rb +9 -22
- data/lib/pact/consumer_contract/request.rb +68 -0
- data/lib/pact/consumer_contract/service_consumer.rb +6 -2
- data/lib/pact/consumer_contract/service_provider.rb +6 -2
- data/lib/pact/matchers/index_not_found.rb +20 -0
- data/lib/pact/matchers/matchers.rb +14 -28
- data/lib/pact/matchers/unexpected_index.rb +17 -0
- data/lib/pact/matchers/unexpected_key.rb +17 -0
- data/lib/pact/provider.rb +1 -1
- data/lib/pact/provider/configuration.rb +129 -0
- data/lib/pact/provider/request.rb +59 -0
- data/lib/pact/provider/rspec.rb +4 -5
- data/lib/pact/provider/test_methods.rb +14 -52
- data/lib/pact/shared/dsl.rb +20 -0
- data/lib/pact/shared/key_not_found.rb +24 -0
- data/lib/pact/shared/null_expectation.rb +31 -0
- data/lib/pact/shared/request.rb +68 -0
- data/lib/pact/something_like.rb +7 -1
- data/lib/pact/symbolize_keys.rb +12 -0
- data/lib/pact/tasks.rb +1 -1
- data/lib/pact/tasks/task_helper.rb +23 -0
- data/lib/pact/{verification_task.rb → tasks/verification_task.rb} +4 -4
- data/lib/pact/version.rb +1 -1
- data/lib/tasks/pact.rake +5 -4
- data/pact.gemspec +1 -1
- data/spec/features/consumption_spec.rb +1 -73
- data/spec/features/production_spec.rb +3 -0
- data/spec/integration/consumer_spec.rb +170 -0
- data/spec/integration/pact/consumer_configuration_spec.rb +1 -1
- data/spec/lib/pact/consumer/{dsl_spec.rb → configuration_spec.rb} +10 -9
- data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +2 -2
- data/spec/lib/pact/consumer/interaction_builder_spec.rb +1 -1
- data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +66 -0
- data/spec/lib/pact/consumer/mock_service/rack_request_helper_spec.rb +82 -0
- data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +54 -0
- data/spec/lib/pact/consumer/request_spec.rb +24 -0
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +1 -1
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -34
- data/spec/lib/pact/{request_spec.rb → consumer_contract/request_spec.rb} +45 -121
- data/spec/lib/pact/matchers/matchers_spec.rb +29 -13
- data/spec/lib/pact/provider/configuration_spec.rb +163 -0
- data/spec/lib/pact/provider/request_spec.rb +78 -0
- data/spec/lib/pact/provider/test_methods_spec.rb +0 -30
- data/spec/lib/pact/verification_task_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- data/spec/support/factories.rb +5 -1
- data/spec/support/pact_helper.rb +6 -0
- data/spec/support/shared_examples_for_request.rb +83 -0
- data/spec/support/test_app_fail.json +3 -0
- data/spec/support/test_app_pass.json +18 -1
- metadata +68 -31
- data/lib/pact/consumer/dsl.rb +0 -157
- data/lib/pact/pact_task_helper.rb +0 -21
- data/lib/pact/provider/dsl.rb +0 -115
- data/lib/pact/request.rb +0 -167
- data/spec/lib/pact/consumer/mock_service_spec.rb +0 -143
- data/spec/lib/pact/provider/dsl_spec.rb +0 -179
@@ -1,179 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pact/provider/dsl'
|
3
|
-
|
4
|
-
module Pact::Provider
|
5
|
-
describe DSL do
|
6
|
-
|
7
|
-
class MockConfig
|
8
|
-
include Pact::Provider::DSL
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "service_provider" do
|
12
|
-
|
13
|
-
before do
|
14
|
-
Pact.clear_configuration
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:mock_config) { MockConfig.new }
|
18
|
-
context "when a provider is configured" do
|
19
|
-
before do
|
20
|
-
mock_config.service_provider "Fred" do
|
21
|
-
app { "An app" }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
it "should allow configuration of the name" do
|
25
|
-
expect(Pact.configuration.provider.name).to eql "Fred"
|
26
|
-
end
|
27
|
-
it "should allow configuration of the test app" do
|
28
|
-
expect(Pact.configuration.provider.app).to eql "An app"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
#Move this test to configuration
|
32
|
-
context "when a provider is not configured" do
|
33
|
-
it "raises an error" do
|
34
|
-
expect{ Pact.configuration.provider }.to raise_error(/Please configure your provider/)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
module DSL
|
41
|
-
|
42
|
-
describe VerificationDSL do
|
43
|
-
|
44
|
-
|
45
|
-
describe 'create_verification' do
|
46
|
-
let(:url) {'http://some/uri'}
|
47
|
-
let(:consumer_name) {'some consumer'}
|
48
|
-
let(:ref) {:prod}
|
49
|
-
let(:options) { {:ref => :prod} }
|
50
|
-
context "with valid values" do
|
51
|
-
subject do
|
52
|
-
uri = url
|
53
|
-
VerificationDSL.new(consumer_name, options) do
|
54
|
-
pact_uri uri
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it "creates a Verification" do
|
59
|
-
Pact::Provider::PactVerification.should_receive(:new).with(consumer_name, url, ref)
|
60
|
-
subject.create_verification
|
61
|
-
end
|
62
|
-
|
63
|
-
it "returns a Verification" do
|
64
|
-
Pact::Provider::PactVerification.should_receive(:new).and_return('a verification')
|
65
|
-
expect(subject.create_verification).to eq('a verification')
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with a nil uri" do
|
70
|
-
subject do
|
71
|
-
VerificationDSL.new(consumer_name, options) do
|
72
|
-
pact_uri nil
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
it "raises a validation error" do
|
77
|
-
expect{ subject.create_verification}.to raise_error /Please provide a pact_uri/
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe ServiceProviderDSL do
|
84
|
-
|
85
|
-
describe "initialize" do
|
86
|
-
|
87
|
-
context "with an object instead of a block" do
|
88
|
-
subject do
|
89
|
-
ServiceProviderDSL.new 'name' do
|
90
|
-
app 'blah'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
it "raises an error" do
|
94
|
-
expect{ subject }.to raise_error /wrong number of arguments/
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
describe "validate" do
|
100
|
-
context "when no name is provided" do
|
101
|
-
subject do
|
102
|
-
ServiceProviderDSL.new ' ' do
|
103
|
-
app { Object.new }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
it "raises an error" do
|
107
|
-
expect{ subject.validate}.to raise_error("Please provide a name for the Provider")
|
108
|
-
end
|
109
|
-
end
|
110
|
-
context "when nil name is provided" do
|
111
|
-
subject do
|
112
|
-
ServiceProviderDSL.new nil do
|
113
|
-
app { Object.new }
|
114
|
-
end
|
115
|
-
end
|
116
|
-
it "raises an error" do
|
117
|
-
expect{ subject.validate}.to raise_error("Please provide a name for the Provider")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
context "when no app is provided" do
|
121
|
-
subject do
|
122
|
-
ServiceProviderDSL.new 'Blah' do
|
123
|
-
end
|
124
|
-
end
|
125
|
-
it "raises an error" do
|
126
|
-
expect{ subject.validate }.to raise_error("Please configure an app for the Provider")
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe 'honours_pact_with' do
|
132
|
-
before do
|
133
|
-
Pact.clear_configuration
|
134
|
-
end
|
135
|
-
|
136
|
-
context "with no optional params" do
|
137
|
-
subject do
|
138
|
-
ServiceProviderDSL.new '' do
|
139
|
-
honours_pact_with 'some-consumer' do
|
140
|
-
pact_uri 'blah'
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
it 'adds a verification to the Pact.configuration' do
|
145
|
-
subject
|
146
|
-
expect(Pact.configuration.pact_verifications.first).to eq(Pact::Provider::PactVerification.new('some-consumer', 'blah', :head))
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "with all params specified" do
|
151
|
-
subject do
|
152
|
-
ServiceProviderDSL.new '' do
|
153
|
-
honours_pact_with 'some-consumer', :ref => :prod do
|
154
|
-
pact_uri 'blah'
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
it 'adds a verification to the Pact.configuration' do
|
159
|
-
subject
|
160
|
-
expect(Pact.configuration.pact_verifications.first).to eq(Pact::Provider::PactVerification.new('some-consumer', 'blah', :prod))
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe ServiceProviderConfig do
|
169
|
-
describe "app" do
|
170
|
-
subject { ServiceProviderConfig.new("blah") { Object.new } }
|
171
|
-
it "should execute the app_block each time" do
|
172
|
-
expect(subject.app.object_id).to_not equal(subject.app.object_id)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|