pact 1.0.30 → 1.0.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +2 -2
  3. data/Gemfile.lock +0 -7
  4. data/README.md +50 -53
  5. data/Rakefile +1 -25
  6. data/documentation/Testing with pact.png +0 -0
  7. data/documentation/faq.md +45 -0
  8. data/documentation/raq.md +39 -0
  9. data/documentation/terminology.md +25 -0
  10. data/example/animal-service/Gemfile +4 -4
  11. data/example/animal-service/Gemfile.lock +20 -15
  12. data/example/animal-service/Rakefile +1 -1
  13. data/example/animal-service/config.ru +3 -0
  14. data/example/animal-service/db/animal_db.sqlite3 +0 -0
  15. data/example/animal-service/db/animals_db.sqlite3 +0 -0
  16. data/example/animal-service/lib/animal_service/animal_repository.rb +16 -0
  17. data/example/animal-service/lib/animal_service/api.rb +28 -0
  18. data/example/animal-service/lib/animal_service/db.rb +5 -0
  19. data/example/animal-service/spec/service_consumers/pact_helper.rb +10 -16
  20. data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +13 -3
  21. data/example/zoo-app/Gemfile +0 -2
  22. data/example/zoo-app/Gemfile.lock +7 -8
  23. data/example/zoo-app/lib/zoo_app/animal_service_client.rb +8 -4
  24. data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +18 -64
  25. data/example/zoo-app/spec/service_providers/animal_service_client_spec.rb +76 -0
  26. data/example/zoo-app/spec/service_providers/pact_helper.rb +1 -1
  27. data/example/zoo-app/spec/spec_helper.rb +0 -2
  28. data/lib/pact/app.rb +4 -2
  29. data/lib/pact/consumer/configuration.rb +2 -2
  30. data/lib/pact/consumer/consumer_contract_builder.rb +2 -1
  31. data/lib/pact/consumer/interactions_filter.rb +7 -0
  32. data/lib/pact/consumer/mock_service/app.rb +7 -2
  33. data/lib/pact/consumer/mock_service/interaction_mismatch.rb +6 -1
  34. data/lib/pact/consumer/mock_service/interaction_post.rb +1 -1
  35. data/lib/pact/consumer/mock_service/rack_request_helper.rb +1 -1
  36. data/lib/pact/consumer/rspec.rb +9 -15
  37. data/lib/pact/consumer/rspec/full_example_description.rb +28 -0
  38. data/lib/pact/consumer/spec_hooks.rb +31 -0
  39. data/lib/pact/consumer_contract/consumer_contract.rb +2 -31
  40. data/lib/pact/consumer_contract/file_name.rb +13 -0
  41. data/lib/pact/consumer_contract/pact_file.rb +24 -0
  42. data/lib/pact/provider/matchers.rb +3 -1
  43. data/lib/pact/provider/provider_state.rb +43 -20
  44. data/lib/pact/version.rb +1 -1
  45. data/pact.gemspec +0 -1
  46. data/spec/features/consumption_spec.rb +5 -0
  47. data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +162 -147
  48. data/spec/lib/pact/consumer/mock_service/app_spec.rb +52 -0
  49. data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +3 -3
  50. metadata +19 -25
  51. 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