pact 1.0.30 → 1.0.31
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.
- data/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/Gemfile.lock +0 -7
- data/README.md +50 -53
- data/Rakefile +1 -25
- data/documentation/Testing with pact.png +0 -0
- data/documentation/faq.md +45 -0
- data/documentation/raq.md +39 -0
- data/documentation/terminology.md +25 -0
- data/example/animal-service/Gemfile +4 -4
- data/example/animal-service/Gemfile.lock +20 -15
- data/example/animal-service/Rakefile +1 -1
- data/example/animal-service/config.ru +3 -0
- data/example/animal-service/db/animal_db.sqlite3 +0 -0
- data/example/animal-service/db/animals_db.sqlite3 +0 -0
- data/example/animal-service/lib/animal_service/animal_repository.rb +16 -0
- data/example/animal-service/lib/animal_service/api.rb +28 -0
- data/example/animal-service/lib/animal_service/db.rb +5 -0
- data/example/animal-service/spec/service_consumers/pact_helper.rb +10 -16
- data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +13 -3
- data/example/zoo-app/Gemfile +0 -2
- data/example/zoo-app/Gemfile.lock +7 -8
- data/example/zoo-app/lib/zoo_app/animal_service_client.rb +8 -4
- data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +18 -64
- data/example/zoo-app/spec/service_providers/animal_service_client_spec.rb +76 -0
- data/example/zoo-app/spec/service_providers/pact_helper.rb +1 -1
- data/example/zoo-app/spec/spec_helper.rb +0 -2
- data/lib/pact/app.rb +4 -2
- data/lib/pact/consumer/configuration.rb +2 -2
- data/lib/pact/consumer/consumer_contract_builder.rb +2 -1
- data/lib/pact/consumer/interactions_filter.rb +7 -0
- data/lib/pact/consumer/mock_service/app.rb +7 -2
- data/lib/pact/consumer/mock_service/interaction_mismatch.rb +6 -1
- data/lib/pact/consumer/mock_service/interaction_post.rb +1 -1
- data/lib/pact/consumer/mock_service/rack_request_helper.rb +1 -1
- data/lib/pact/consumer/rspec.rb +9 -15
- data/lib/pact/consumer/rspec/full_example_description.rb +28 -0
- data/lib/pact/consumer/spec_hooks.rb +31 -0
- data/lib/pact/consumer_contract/consumer_contract.rb +2 -31
- data/lib/pact/consumer_contract/file_name.rb +13 -0
- data/lib/pact/consumer_contract/pact_file.rb +24 -0
- data/lib/pact/provider/matchers.rb +3 -1
- data/lib/pact/provider/provider_state.rb +43 -20
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +0 -1
- data/spec/features/consumption_spec.rb +5 -0
- data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +162 -147
- data/spec/lib/pact/consumer/mock_service/app_spec.rb +52 -0
- data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +3 -3
- metadata +19 -25
- data/example/zoo-app/spec/service_providers/animal_service_spec.rb +0 -92
@@ -1,92 +0,0 @@
|
|
1
|
-
require_relative 'pact_helper'
|
2
|
-
|
3
|
-
module ZooApp
|
4
|
-
describe "A pact with Animal Service", :pact => true do
|
5
|
-
|
6
|
-
before do
|
7
|
-
AnimalServiceClient.base_uri 'localhost:1234'
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "a call to get alligators" do
|
11
|
-
|
12
|
-
context "when valid response is received" do
|
13
|
-
before do
|
14
|
-
animal_service.
|
15
|
-
given("there are alligators").
|
16
|
-
upon_receiving("a request for alligators").
|
17
|
-
with({ method: :get, path: '/alligators', :headers => {'Accept' => 'application/json'} }).
|
18
|
-
will_respond_with({
|
19
|
-
status: 200,
|
20
|
-
headers: { 'Content-Type' => 'application/json' },
|
21
|
-
body: [{:name => 'Bob'}]
|
22
|
-
})
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns a list of alligators" do
|
26
|
-
expect(AnimalServiceClient.find_alligators).to eq [ZooApp::Animals::Alligator.new(:name => 'Bob')]
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when an error response is returned" do
|
32
|
-
before do
|
33
|
-
animal_service.
|
34
|
-
given("an error has occurred").
|
35
|
-
upon_receiving("a request for alligators").
|
36
|
-
with({ method: :get, path: '/alligators', :headers => {'Accept' => 'application/json'} }).
|
37
|
-
will_respond_with({
|
38
|
-
status: 500,
|
39
|
-
headers: { 'Content-Type' => 'application/json' },
|
40
|
-
body: {:error => 'Argh!!!'}
|
41
|
-
})
|
42
|
-
end
|
43
|
-
|
44
|
-
it "raises an error" do
|
45
|
-
expect{ AnimalServiceClient.find_alligators }.to raise_error /Argh/
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "a call to get an alligator by name" do
|
52
|
-
context "when an alligator by the given name exists" do
|
53
|
-
|
54
|
-
before do
|
55
|
-
animal_service.
|
56
|
-
given("there is an alligator named Mary").
|
57
|
-
upon_receiving("a request for alligator Mary").
|
58
|
-
with({ method: :get, path: '/alligators/Mary', :headers => {'Accept' => 'application/json'} }).
|
59
|
-
will_respond_with({
|
60
|
-
status: 200,
|
61
|
-
headers: { 'Content-Type' => 'application/json' },
|
62
|
-
body: {:name => 'Mary'}
|
63
|
-
})
|
64
|
-
end
|
65
|
-
|
66
|
-
it "returns the alligator" do
|
67
|
-
expect(AnimalServiceClient.find_alligator_by_name("Mary")).to eq ZooApp::Animals::Alligator.new(:name => 'Mary')
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
context "when an alligator by the given name does not exist" do
|
73
|
-
|
74
|
-
before do
|
75
|
-
animal_service.
|
76
|
-
given("there is not an alligator named Mary").
|
77
|
-
upon_receiving("a request for alligator Mary").
|
78
|
-
with({ method: :get, path: '/alligators/Mary', :headers => {'Accept' => 'application/json'} }).
|
79
|
-
will_respond_with({
|
80
|
-
status: 404,
|
81
|
-
headers: { 'Content-Type' => 'application/json' }
|
82
|
-
})
|
83
|
-
end
|
84
|
-
|
85
|
-
it "returns nil" do
|
86
|
-
expect(AnimalServiceClient.find_alligator_by_name("Mary")).to be_nil
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|