pact 1.4.0.rc4 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/CHANGELOG.md +13 -0
  2. data/lib/pact/consumer/configuration/mock_service.rb +2 -1
  3. data/lib/pact/consumer/consumer_contract_builder.rb +2 -1
  4. data/lib/pact/version.rb +1 -1
  5. data/pact.gemspec +4 -3
  6. metadata +32 -205
  7. data/.gitignore +0 -29
  8. data/.rspec +0 -2
  9. data/.travis.yml +0 -8
  10. data/Gemfile +0 -9
  11. data/Gemfile.lock +0 -108
  12. data/README.md +0 -314
  13. data/Rakefile +0 -9
  14. data/config.ru +0 -3
  15. data/documentation/README.md +0 -13
  16. data/documentation/configuration.md +0 -166
  17. data/documentation/diff_formatter_embedded.png +0 -0
  18. data/documentation/diff_formatter_list.png +0 -0
  19. data/documentation/diff_formatter_unix.png +0 -0
  20. data/example/animal-service/Gemfile +0 -14
  21. data/example/animal-service/Gemfile.lock +0 -69
  22. data/example/animal-service/Rakefile +0 -5
  23. data/example/animal-service/config.ru +0 -3
  24. data/example/animal-service/db/animal_db.sqlite3 +0 -0
  25. data/example/animal-service/lib/animal_service/animal_repository.rb +0 -12
  26. data/example/animal-service/lib/animal_service/api.rb +0 -29
  27. data/example/animal-service/lib/animal_service/db.rb +0 -5
  28. data/example/animal-service/spec/service_consumers/pact_helper.rb +0 -11
  29. data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +0 -26
  30. data/example/zoo-app/Gemfile +0 -12
  31. data/example/zoo-app/Gemfile.lock +0 -63
  32. data/example/zoo-app/Rakefile +0 -5
  33. data/example/zoo-app/doc/pacts/markdown/README.md +0 -3
  34. data/example/zoo-app/doc/pacts/markdown/Zoo App - Animal Service.md +0 -75
  35. data/example/zoo-app/lib/zoo_app/animal_service_client.rb +0 -31
  36. data/example/zoo-app/lib/zoo_app/models/alligator.rb +0 -17
  37. data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +0 -67
  38. data/example/zoo-app/spec/service_providers/animal_service_client_spec.rb +0 -71
  39. data/example/zoo-app/spec/service_providers/pact_helper.rb +0 -15
  40. data/example/zoo-app/spec/spec_helper.rb +0 -6
  41. data/scratchpad.rb +0 -52
  42. data/spec/features/consumption_spec.rb +0 -114
  43. data/spec/features/production_spec.rb +0 -155
  44. data/spec/features/provider_states/zebras.rb +0 -28
  45. data/spec/integration/consumer_async_request_spec.rb +0 -46
  46. data/spec/integration/consumer_more_than_one_matching_interaction_spec.rb +0 -49
  47. data/spec/integration/consumer_no_matching_interaction_spec.rb +0 -53
  48. data/spec/integration/consumer_with_a_provider_state_spec.rb +0 -44
  49. data/spec/integration/consumer_with_form_hash_spec.rb +0 -62
  50. data/spec/integration/consumer_with_form_spec.rb +0 -50
  51. data/spec/integration/consumer_with_params_hash_spec.rb +0 -122
  52. data/spec/integration/pact/consumer_configuration_spec.rb +0 -66
  53. data/spec/integration/pact/provider_configuration_spec.rb +0 -25
  54. data/spec/lib/pact/cli_spec.rb +0 -47
  55. data/spec/lib/pact/configuration_spec.rb +0 -297
  56. data/spec/lib/pact/consumer/app_manager_spec.rb +0 -41
  57. data/spec/lib/pact/consumer/configuration_spec.rb +0 -57
  58. data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +0 -69
  59. data/spec/lib/pact/consumer/interaction_builder_spec.rb +0 -87
  60. data/spec/lib/pact/consumer/interactions_spec.rb +0 -64
  61. data/spec/lib/pact/consumer/mock_service/app_spec.rb +0 -52
  62. data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +0 -78
  63. data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +0 -70
  64. data/spec/lib/pact/consumer/mock_service/interaction_replay_spec.rb +0 -12
  65. data/spec/lib/pact/consumer/mock_service/rack_request_helper_spec.rb +0 -88
  66. data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +0 -142
  67. data/spec/lib/pact/consumer/service_consumer_spec.rb +0 -11
  68. data/spec/lib/pact/doc/generator_spec.rb +0 -84
  69. data/spec/lib/pact/doc/interaction_view_model_spec.rb +0 -132
  70. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +0 -29
  71. data/spec/lib/pact/doc/markdown/index_renderer_spec.rb +0 -29
  72. data/spec/lib/pact/provider/configuration/configuration_extension_spec.rb +0 -17
  73. data/spec/lib/pact/provider/configuration/pact_verification_spec.rb +0 -43
  74. data/spec/lib/pact/provider/configuration/service_provider_config_spec.rb +0 -21
  75. data/spec/lib/pact/provider/configuration/service_provider_dsl_spec.rb +0 -108
  76. data/spec/lib/pact/provider/configuration_spec.rb +0 -50
  77. data/spec/lib/pact/provider/matchers/messages_spec.rb +0 -116
  78. data/spec/lib/pact/provider/pact_helper_locator_spec.rb +0 -54
  79. data/spec/lib/pact/provider/print_missing_provider_states_spec.rb +0 -19
  80. data/spec/lib/pact/provider/request_spec.rb +0 -78
  81. data/spec/lib/pact/provider/rspec/formatter_rspec_2_spec.rb +0 -68
  82. data/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb +0 -72
  83. data/spec/lib/pact/provider/rspec_spec.rb +0 -55
  84. data/spec/lib/pact/provider/state/provider_state_manager_spec.rb +0 -89
  85. data/spec/lib/pact/provider/state/provider_state_proxy_spec.rb +0 -80
  86. data/spec/lib/pact/provider/state/provider_state_spec.rb +0 -213
  87. data/spec/lib/pact/provider/world_spec.rb +0 -41
  88. data/spec/lib/pact/tasks/task_helper_spec.rb +0 -74
  89. data/spec/lib/pact/tasks/verification_task_spec.rb +0 -75
  90. data/spec/pact_specification/compliance-1.0.0.rb +0 -47
  91. data/spec/spec_helper.rb +0 -22
  92. data/spec/standalone/consumer_fail_test.rb +0 -55
  93. data/spec/standalone/consumer_pass_test.rb +0 -51
  94. data/spec/support/a_consumer-a_producer.json +0 -32
  95. data/spec/support/a_consumer-a_provider.json +0 -32
  96. data/spec/support/active_support_if_configured.rb +0 -6
  97. data/spec/support/app_for_config_ru.rb +0 -4
  98. data/spec/support/case-insensitive-response-header-matching.json +0 -21
  99. data/spec/support/case-insensitive-response-header-matching.rb +0 -15
  100. data/spec/support/consumer_contract_template.json +0 -24
  101. data/spec/support/factories.rb +0 -82
  102. data/spec/support/generated_index.md +0 -4
  103. data/spec/support/generated_markdown.md +0 -55
  104. data/spec/support/interaction_view_model.json +0 -63
  105. data/spec/support/interaction_view_model_with_terms.json +0 -50
  106. data/spec/support/markdown_pact.json +0 -48
  107. data/spec/support/missing_provider_states_output.txt +0 -25
  108. data/spec/support/options.json +0 -21
  109. data/spec/support/options_app.rb +0 -15
  110. data/spec/support/pact_helper.rb +0 -57
  111. data/spec/support/shared_examples_for_request.rb +0 -94
  112. data/spec/support/spec_support.rb +0 -20
  113. data/spec/support/stubbing.json +0 -22
  114. data/spec/support/stubbing_using_allow.rb +0 -29
  115. data/spec/support/term.json +0 -48
  116. data/spec/support/test_app_fail.json +0 -61
  117. data/spec/support/test_app_pass.json +0 -38
  118. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  119. data/tasks/pact-test.rake +0 -114
  120. data/tasks/spec.rake +0 -8
@@ -1,57 +0,0 @@
1
- # This is the pact_helper for rake pact:tests
2
- require 'json'
3
- require 'pact/provider/rspec'
4
- require './spec/support/active_support_if_configured'
5
-
6
- module Pact
7
- module Test
8
- class TestApp
9
- def call env
10
- if env['PATH_INFO'] == '/weather'
11
- [200, {'Content-Type' => 'application/json'}, [{message: WEATHER[:current_state], :array => [{"foo"=> "blah"}]}.to_json]]
12
- elsif env['PATH_INFO'] == '/sometext'
13
- [200, {'Content-Type' => 'text/plain'}, ['some text']]
14
- elsif env['PATH_INFO'] == '/content_type_is_important'
15
- [200, {'Content-Type' => 'application/json'}, [{message: "A message", note: "This will cause verify to fail if it using the wrong content type differ."}.to_json]]
16
- else
17
- raise "unexpected path #{env['PATH_INFO']}!!!"
18
- end
19
- end
20
- end
21
-
22
- Pact.configure do | config |
23
- config.logger.level = Logger::DEBUG
24
- config.diff_formatter = :unix
25
- end
26
-
27
- Pact.service_provider "Some Provider" do
28
- app { TestApp.new }
29
-
30
- honours_pact_with 'some-test-consumer' do
31
- pact_uri './spec/support/test_app_pass.json'
32
- end
33
- end
34
-
35
- Pact.set_up do
36
- WEATHER ||= {}
37
- end
38
-
39
- #one with a top level consumer
40
- Pact.provider_states_for 'some-test-consumer' do
41
-
42
- provider_state "the weather is sunny" do
43
- set_up do
44
-
45
- WEATHER[:current_state] = 'sunny'
46
- end
47
- end
48
- end
49
-
50
- #one without a top level consumer
51
- Pact.provider_state "the weather is cloudy" do
52
- set_up do
53
- WEATHER[:current_state] = 'cloudy'
54
- end
55
- end
56
- end
57
- end
@@ -1,94 +0,0 @@
1
- shared_examples "a request" do
2
-
3
- describe 'matching' do
4
- let(:expected) do
5
- Pact::Request::Expected.from_hash(
6
- {'method' => 'get', 'path' => 'path', 'query' => /b/}
7
- )
8
- end
9
-
10
- let(:actual) do
11
- Pact::Consumer::Request::Actual.from_hash({'method' => 'get', 'path' => 'path', 'query' => 'blah', 'headers' => {}, 'body' => ''})
12
- end
13
-
14
- it "should match" do
15
- expect(expected.difference(actual)).to eq({})
16
- end
17
- end
18
-
19
- describe 'full_path' do
20
- context "with empty path" do
21
- subject { described_class.from_hash({:path => '', :method => 'get', :query => '', :headers => {}}) }
22
- it "returns the full path"do
23
- expect(subject.full_path).to eq "/"
24
- end
25
- end
26
- context "with a path" do
27
- subject { described_class.from_hash({:path => '/path', :method => 'get', :query => '', :headers => {}}) }
28
- it "returns the full path"do
29
- expect(subject.full_path).to eq "/path"
30
- end
31
- end
32
- context "with a path and query" do
33
- subject { described_class.from_hash({:path => '/path', :method => 'get', :query => "something", :headers => {}}) }
34
- it "returns the full path"do
35
- expect(subject.full_path).to eq "/path?something"
36
- end
37
- end
38
- context "with a path and a query that is a Term" do
39
- subject { described_class.from_hash({:path => '/path', :method => 'get', :headers => {}, :query => Pact::Term.new(generate: 'a', matcher: /a/)}) }
40
- it "returns the full path with reified path" do
41
- expect(subject.full_path).to eq "/path?a"
42
- end
43
- end
44
- end
45
-
46
- describe "building from a hash" do
47
-
48
- let(:raw_request) do
49
- {
50
- 'method' => 'get',
51
- 'path' => '/mallory',
52
- 'query' => 'query',
53
- 'headers' => {
54
- 'Content-Type' => 'application/json'
55
- },
56
- 'body' => 'hello mallory'
57
- }
58
- end
59
-
60
- subject { described_class.from_hash(raw_request) }
61
-
62
- it "extracts the method" do
63
- expect(subject.method).to eq 'get'
64
- end
65
-
66
- it "extracts the path" do
67
- expect(subject.path).to eq '/mallory'
68
- end
69
-
70
- it "extracts the body" do
71
- expect(subject.body).to eq 'hello mallory'
72
- end
73
-
74
- it "extracts the query" do
75
- expect(subject.query).to eq 'query'
76
- end
77
-
78
- it "blows up if method is absent" do
79
- raw_request.delete 'method'
80
- expect { described_class.from_hash(raw_request) }.to raise_error
81
- end
82
-
83
- it "blows up if path is absent" do
84
- raw_request.delete 'path'
85
- expect { described_class.from_hash(raw_request) }.to raise_error
86
- end
87
-
88
- it "does not blow up if body is missing" do
89
- raw_request.delete 'body'
90
- expect { described_class.from_hash(raw_request) }.to_not raise_error
91
- end
92
-
93
- end
94
- end
@@ -1,20 +0,0 @@
1
- require 'pact/rspec'
2
-
3
- module Pact
4
- module SpecSupport
5
-
6
- extend self
7
-
8
- def remove_ansicolor string
9
- string.gsub(/\e\[(\d+)m/, '')
10
- end
11
-
12
- Pact::RSpec.with_rspec_2 do
13
-
14
- def instance_double *args
15
- double(*args)
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,22 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "Consumer"
4
- },
5
- "provider": {
6
- "name": "Provider"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request",
11
- "request": {
12
- "method": "get",
13
- "path": "/"
14
- },
15
- "response": {
16
- "status": 200,
17
- "body": "stubbing works"
18
- },
19
- "provider_state": "something is stubbed"
20
- }
21
- ]
22
- }
@@ -1,29 +0,0 @@
1
- require 'pact/provider/rspec'
2
- require 'rspec/mocks'
3
- require './spec/support/active_support_if_configured'
4
-
5
- class StubbedThing
6
- def self.stub_me
7
- end
8
- end
9
-
10
- class App
11
- def self.call env
12
- [200, {}, [StubbedThing.stub_me]]
13
- end
14
- end
15
-
16
- Pact.provider_states_for 'Consumer' do
17
- provider_state 'something is stubbed' do
18
- set_up do
19
- allow(StubbedThing).to receive(:stub_me).and_return("stubbing works")
20
- end
21
- end
22
- end
23
-
24
- # Include the ExampleMethods module after the provider states are declared
25
- # to ensure the ordering doesn't matter
26
-
27
- Pact.service_provider 'Provider' do
28
- app { App }
29
- end
@@ -1,48 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "some-test-consumer"
4
- },
5
- "provider": {
6
- "name": "an unknown provider"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request",
11
- "request": {
12
- "method": "get",
13
- "path": "/weather",
14
- "query": ""
15
- },
16
- "response": {
17
- "status": 200,
18
- "headers" : {
19
- "Content-type": {
20
- "json_class": "Pact::Term",
21
- "data": {
22
- "generate": "text/plain",
23
- "matcher": {
24
- "json_class": "Regexp",
25
- "o": 0,
26
- "s": "text"
27
- }
28
- }
29
- }
30
- },
31
- "body": {
32
- "message" : {
33
- "json_class": "Pact::Term",
34
- "data": {
35
- "generate": "rainy",
36
- "matcher": {
37
- "json_class": "Regexp",
38
- "o": 0,
39
- "s": "rain"
40
- }
41
- }
42
- }
43
- }
44
- },
45
- "provider_state": "the weather is sunny"
46
- }
47
- ]
48
- }
@@ -1,61 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "an unknown consumer"
4
- },
5
- "provider": {
6
- "name": "an unknown provider"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request",
11
- "request": {
12
- "method": "get",
13
- "path": "/weather",
14
- "query": ""
15
- },
16
- "response": {
17
- "status": 200,
18
- "headers" : {"Content-type": "application/json"},
19
- "body": {"message" : "this is not the weather you are looking for", "array": [{"foo": "bar"}], "somethingElse" : {"blah" : {"nested" : "that is missing"} }}
20
-
21
- },
22
- "provider_state": "the weather is cloudy"
23
- },{
24
- "description": "another test request",
25
- "request": {
26
- "method": "get",
27
- "path": "/weather",
28
- "query": ""
29
- },
30
- "response": {
31
- "status": 200,
32
- "headers" : {
33
- "Content-type": {
34
- "json_class": "Pact::Term",
35
- "data": {
36
- "generate": "application/hal+json",
37
- "matcher": {"json_class":"Regexp","o":0,"s":"hal"}
38
- }
39
- },
40
- "X-Special-Header": "something"
41
- },
42
- "body": {"message" : "this is not the weather you are looking for"}
43
-
44
- }
45
- },{
46
- "description": "another test request",
47
- "provider_state": "a missing provider state",
48
- "request": {
49
- "method": "get",
50
- "path": "/weather",
51
- "query": ""
52
- },
53
- "response": {
54
- "status": 200,
55
- "headers" : {"Content-type": "application/json"},
56
- "body": {"message" : "this is not the weather you are looking for"}
57
-
58
- }
59
- }
60
- ]
61
- }
@@ -1,38 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "some-test-consumer"
4
- },
5
- "provider": {
6
- "name": "an unknown provider"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request",
11
- "request": {
12
- "method": "get",
13
- "path": "/weather",
14
- "query": ""
15
- },
16
- "response": {
17
- "status": 200,
18
- "headers" : {"Content-type": "application/json"},
19
- "body": {"message" : "sunny"}
20
- },
21
- "provider_state": "the weather is sunny"
22
- },
23
- {
24
- "description": "a test request for text",
25
- "request": {
26
- "method": "get",
27
- "path": "/sometext",
28
- "query": "",
29
- "body" : "some request text"
30
- },
31
- "response": {
32
- "status": 200,
33
- "headers" : {"Content-type": "text/plain"},
34
- "body": "some text"
35
- }
36
- }
37
- ]
38
- }
@@ -1,23 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "some-test-consumer"
4
- },
5
- "provider": {
6
- "name": "the test app in the pact_helper file"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request expecting an application/json response",
11
- "request": {
12
- "method": "get",
13
- "path": "/content_type_is_important",
14
- "query": ""
15
- },
16
- "response": {
17
- "status": 200,
18
- "headers" : {"Content-type": "application/json"},
19
- "body": {"message" : "A message"}
20
- }
21
- }
22
- ]
23
- }
data/tasks/pact-test.rake DELETED
@@ -1,114 +0,0 @@
1
- require 'pact/tasks/verification_task'
2
- require 'open3'
3
-
4
- Pact::VerificationTask.new(:stubbing) do | pact |
5
- pact.uri './spec/support/stubbing.json', :pact_helper => './spec/support/stubbing_using_allow.rb'
6
- end
7
-
8
- Pact::VerificationTask.new(:options) do | pact |
9
- pact.uri './spec/support/options.json', :pact_helper => './spec/support/options_app.rb'
10
- end
11
-
12
- Pact::VerificationTask.new(:pass) do | pact |
13
- pact.uri './spec/support/test_app_pass.json'
14
- end
15
-
16
- Pact::VerificationTask.new(:fail) do | pact |
17
- pact.uri './spec/support/test_app_pass.json'
18
- pact.uri './spec/support/test_app_fail.json'
19
- end
20
-
21
- Pact::VerificationTask.new(:term) do | pact |
22
- pact.uri './spec/support/term.json'
23
- end
24
-
25
- Pact::VerificationTask.new(:case_insensitive_response_header_matching) do | pact |
26
- pact.uri './spec/support/case-insensitive-response-header-matching.json', :pact_helper => './spec/support/case-insensitive-response-header-matching.rb'
27
- end
28
-
29
- RSpec::Core::RakeTask.new('spec:standalone:fail') do | task |
30
- task.pattern = FileList["spec/standalone/**/*_fail_test.rb"]
31
- end
32
-
33
- RSpec::Core::RakeTask.new('spec:standalone:pass') do | task |
34
- task.pattern = FileList["spec/standalone/**/*_pass_test.rb"]
35
- end
36
-
37
- Pact::VerificationTask.new('test_app:pass') do | pact |
38
- pact.uri './spec/support/test_app_pass.json'
39
- end
40
-
41
- Pact::VerificationTask.new('test_app:content_type') do | pact |
42
- pact.uri './spec/support/test_app_with_right_content_type_differ.json'
43
- end
44
-
45
- Pact::VerificationTask.new('test_app:fail') do | pact |
46
- pact.uri './spec/support/test_app_fail.json', pact_helper: './spec/support/pact_helper.rb'
47
- end
48
-
49
- task :bethtest => ['pact:tests:all','pact:tests:all:with_active_support']
50
-
51
- namespace :pact do
52
-
53
- desc "All the verification tests"
54
- task "tests:all" do
55
- Rake::Task['pact:verify:stubbing'].execute
56
- Rake::Task['spec:standalone:pass'].execute
57
- Rake::Task['pact:verify'].execute
58
- Rake::Task['pact:verify:test_app:pass'].execute
59
- Rake::Task['pact:test:fail'].execute
60
- Rake::Task['pact:test:pactfile'].execute
61
- Rake::Task['pact:verify:test_app:content_type'].execute
62
- Rake::Task['pact:verify:case_insensitive_response_header_matching'].execute
63
- end
64
-
65
- desc "All the verification tests with active support loaded"
66
- task 'tests:all:with_active_support' => :set_active_support_on do
67
- Rake::Task['pact:tests:all'].execute
68
- end
69
-
70
- desc "Ensure pact file is written"
71
- task 'test:pactfile' do
72
- pact_path = './spec/pacts/standalone_consumer-standalone_provider.json'
73
- FileUtils.rm_rf pact_path
74
- Rake::Task['spec:standalone:pass'].execute
75
- fail "Did not find expected pact file at #{pact_path}" unless File.exist?(pact_path)
76
- end
77
-
78
- desc 'Runs pact tests against a sample application, testing failure and success.'
79
- task 'test:fail' do
80
-
81
- require 'open3'
82
-
83
- silent = true
84
- # Run these specs silently, otherwise expected failures will be written to stdout and look like unexpected failures.
85
- #Pact.configuration.output_stream = StringIO.new if silent
86
-
87
- expect_to_fail "bundle exec rake pact:verify:test_app:fail", with: [/Could not find one or more provider states/]
88
- expect_to_fail "bundle exec rake spec:standalone:fail", with: [/Actual interactions do not match expected interactions/]
89
- expect_to_fail "bundle exec rake pact:verify:term", with: [%r{"Content-type" with value /text/}]
90
- end
91
-
92
- def expect_to_fail command, options = {}
93
- success = execute_command command, options
94
- fail "Expected '#{command}' to fail" if success
95
- end
96
-
97
- def execute_command command, options
98
- result = nil
99
- Open3.popen3(command) {|stdin, stdout, stderr, wait_thr|
100
- result = wait_thr.value
101
- ensure_patterns_present(command, options, stdout, stderr) if options[:with]
102
- }
103
- result.success?
104
- end
105
-
106
- def ensure_patterns_present command, options, stdout, stderr
107
- require 'term/ansicolor'
108
- output = stdout.read + stderr.read
109
- options[:with].each do | pattern |
110
- raise (::Term::ANSIColor.red("Could not find #{pattern.inspect} in output of #{command}") + "\n\n#{output}") unless output =~ pattern
111
- end
112
- end
113
-
114
- end