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,41 +0,0 @@
1
- require 'spec_helper'
2
- load 'pact/provider/world.rb'
3
-
4
- describe Pact do
5
- describe ".provider_world" do
6
- it "returns a world" do
7
- expect(Pact.provider_world).to be_instance_of Pact::Provider::World
8
- end
9
- it "returns the same world each time" do
10
- expect(Pact.provider_world).to be Pact.provider_world
11
- end
12
- end
13
-
14
- describe ".clear_provider_world" do
15
- it "clears the world" do
16
- original_world = Pact.provider_world
17
- Pact.clear_provider_world
18
- expect(original_world).to_not be Pact.provider_world
19
- end
20
- end
21
-
22
- end
23
-
24
- module Pact
25
- module Provider
26
- describe World do
27
-
28
- subject { World.new }
29
- describe "provider_states" do
30
- it "returns a provider state proxy" do
31
- expect(subject.provider_states).to be_instance_of State::ProviderStateProxy
32
- end
33
- it "returns the same object each time" do
34
- expect(subject.provider_states).to be subject.provider_states
35
- end
36
-
37
- end
38
-
39
- end
40
- end
41
- end
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/tasks/task_helper'
3
- require 'rake/file_utils'
4
-
5
- module Pact
6
- describe TaskHelper do
7
-
8
-
9
- describe ".execute_pact_verify" do
10
- let(:ruby_path) { "/path/to/ruby" }
11
- let(:pact_uri) { "/pact/uri" }
12
- let(:default_pact_helper_path) { "/pact/helper/path.rb" }
13
-
14
- before do
15
- stub_const("FileUtils::RUBY", ruby_path)
16
- allow(Pact::Provider::PactHelperLocater).to receive(:pact_helper_path).and_return(default_pact_helper_path)
17
- end
18
-
19
- context "with no pact_helper or pact URI" do
20
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{default_pact_helper_path}" }
21
- it "executes the command" do
22
- expect(TaskHelper).to receive(:execute_cmd).with(command)
23
- TaskHelper.execute_pact_verify
24
- end
25
- end
26
-
27
- context "with a pact URI" do
28
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{default_pact_helper_path} -p #{pact_uri}" }
29
- it "executes the command" do
30
- expect(TaskHelper).to receive(:execute_cmd).with(command)
31
- TaskHelper.execute_pact_verify(pact_uri)
32
- end
33
- end
34
-
35
- context "with a pact URI and a pact_helper" do
36
- let(:custom_pact_helper_path) { '/custom/pact_helper.rb' }
37
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{custom_pact_helper_path} -p #{pact_uri}" }
38
- it "executes the command" do
39
- expect(TaskHelper).to receive(:execute_cmd).with(command)
40
- TaskHelper.execute_pact_verify(pact_uri, custom_pact_helper_path)
41
- end
42
- end
43
-
44
- context "with a pact_helper with no .rb on the end" do
45
- let(:custom_pact_helper_path) { '/custom/pact_helper' }
46
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{custom_pact_helper_path}.rb -p #{pact_uri}" }
47
- it "executes the command" do
48
- expect(TaskHelper).to receive(:execute_cmd).with(command)
49
- TaskHelper.execute_pact_verify(pact_uri, custom_pact_helper_path)
50
- end
51
- end
52
-
53
- context "with a pact URI and a nil pact_helper" do
54
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{default_pact_helper_path} -p #{pact_uri}" }
55
- it "executes the command" do
56
- expect(TaskHelper).to receive(:execute_cmd).with(command)
57
- TaskHelper.execute_pact_verify(pact_uri, nil)
58
- end
59
- end
60
-
61
- context "with rspec_opts" do
62
- it "includes the rspec_opts as SPEC_OPTS in the command" do
63
- expect(TaskHelper).to receive(:execute_cmd) do | command |
64
- expect(command).to start_with("SPEC_OPTS=--reporter\\ SomeReporter #{ruby_path}")
65
- end
66
- TaskHelper.execute_pact_verify(pact_uri, nil, "--reporter SomeReporter")
67
- end
68
- end
69
-
70
- end
71
-
72
-
73
- end
74
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/tasks/verification_task'
3
-
4
- module Pact
5
- describe VerificationTask do
6
- before :all do
7
- @pact_helper = '/custom/path/pact_helper .rb'
8
- @pact_uri = 'http://example.org/pact.json'
9
- @task_name = 'pact:verify:pact_rake_spec'
10
- @task_name_with_explict_pact_helper = 'pact:verify:pact_rake_spec_with_explict_pact_helper'
11
- @consumer = 'some-consumer'
12
- @criteria = {:description => /wiffle/}
13
-
14
- VerificationTask.new(:pact_rake_spec_with_explict_pact_helper) do | pact |
15
- pact.uri @pact_uri, pact_helper: @pact_helper
16
- end
17
-
18
- VerificationTask.new(:pact_rake_spec) do | pact |
19
- pact.uri @pact_uri
20
- end
21
- end
22
-
23
- before do
24
- allow(Pact::TaskHelper).to receive(:execute_pact_verify).and_return(0)
25
- end
26
-
27
- let(:exit_code) {0}
28
-
29
-
30
- describe '.initialize' do
31
- context 'with an explict pact_helper' do
32
- it 'creates the tasks' do
33
- expect(Rake::Task.tasks).to include_task @task_name
34
- end
35
- end
36
- context 'with no explict pact_helper' do
37
- it 'creates the tasks' do
38
- expect(Rake::Task.tasks).to include_task @task_name_with_explict_pact_helper
39
- end
40
- end
41
- end
42
-
43
- describe 'execute' do
44
-
45
- context "with no explicit pact_helper" do
46
- it 'verifies the pacts using the TaskHelper' do
47
- expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, nil, nil)
48
- Rake::Task[@task_name].execute
49
- end
50
- end
51
-
52
- context "with an explict pact_helper" do
53
- let(:verification_config) { [ uri: @pact_uri, pact_helper: @pact_helper] }
54
- it 'verifies the pacts using the TaskHelper' do
55
- expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, @pact_helper, nil)
56
- Rake::Task[@task_name_with_explict_pact_helper].execute
57
- end
58
- end
59
-
60
- context 'when all specs pass' do
61
-
62
- it 'does not raise an exception' do
63
- Rake::Task[@task_name].execute
64
- end
65
- end
66
-
67
- end
68
- end
69
- end
70
-
71
- RSpec::Matchers.define :include_task do |expected|
72
- match do |actual|
73
- actual.any? { |task| task.name == expected }
74
- end
75
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/consumer/request'
3
- require 'pact/consumer_contract/request'
4
-
5
- PACT_SPEC_DIR = "../pact-specification/testcases"
6
- REQUEST_TEST_CASE_FOLDERS = Dir.glob("#{PACT_SPEC_DIR}/request/**")
7
- REQUEST_TEST_CASE_FILES = Dir.glob("#{PACT_SPEC_DIR}/request/**/*.json")
8
-
9
- TEST_DESCRIPTIONS = {true => "matches", false => "does not match"}
10
-
11
- describe "Pact gem complicance with Pact Specification 1.0.0" do
12
-
13
- directories = Dir.glob("#{PACT_SPEC_DIR}/*")
14
-
15
- directories.each do | dir_name |
16
-
17
- describe File.basename(dir_name) do
18
-
19
- sub_directories = Dir.glob("#{dir_name}/*")
20
-
21
- sub_directories.each do | sub_dir_name |
22
-
23
- context File.basename(sub_dir_name) do
24
- testcases = Dir.glob("#{sub_dir_name}/**/*.json")
25
-
26
- testcases.each do | file_name |
27
-
28
- context File.basename(file_name).chomp(".json") do
29
-
30
- file_content = JSON.parse(File.read(file_name))
31
- expected = Pact::Request::Expected.from_hash(file_content["expected"])
32
- actual = Pact::Consumer::Request::Actual.from_hash(file_content["actual"])
33
- expected_result = file_content.fetch("match")
34
- comment = file_content["comment"]
35
-
36
- it "#{TEST_DESCRIPTIONS[expected_result]} - #{comment}" do
37
- expect(expected.matches?(actual)).to eq expected_result
38
- end
39
-
40
- end
41
-
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'rspec'
2
- require 'fakefs/spec_helpers'
3
- require 'rspec'
4
- require 'pact'
5
- require 'webmock/rspec'
6
- require 'support/factories'
7
- require 'support/spec_support'
8
- require 'pact/provider/rspec'
9
-
10
- WebMock.disable_net_connect!(allow_localhost: true)
11
-
12
- require './spec/support/active_support_if_configured'
13
-
14
- RSpec.configure do | config |
15
- config.include(FakeFS::SpecHelpers, :fakefs => true)
16
-
17
- config.extend Pact::Provider::RSpec::ClassMethods
18
- config.include Pact::Provider::RSpec::InstanceMethods
19
- config.include Pact::Provider::TestMethods
20
- config.include Pact::SpecSupport
21
- end
22
-
@@ -1,55 +0,0 @@
1
- require 'pact/consumer/rspec'
2
- require './spec/support/active_support_if_configured'
3
-
4
- Pact.service_consumer "Standalone Consumer" do
5
- has_pact_with "Standalone Provider" do
6
- mock_service :standalone_service do
7
- port 1238
8
- end
9
- end
10
- end
11
-
12
- class StandaloneClient
13
-
14
- def initialize base_url
15
- @base_url = base_url
16
- end
17
-
18
- def call
19
- uri = URI("#{@base_url}/something")
20
- post_req = Net::HTTP::Post.new(uri.path)
21
- post_req['Content-Type'] = "application/json"
22
- post_req.body = {a: "not matching body"}.to_json
23
- response = Net::HTTP.start(uri.hostname, uri.port) do |http|
24
- http.request post_req
25
- end
26
- JSON.parse(response.body)
27
- end
28
-
29
- end
30
-
31
- describe StandaloneClient, pact: true do
32
-
33
- subject { StandaloneClient.new("http://localhost:1238") }
34
-
35
- describe "call" do
36
-
37
- let(:expected_body) { {a: "body"} }
38
- let(:expected_headers) { {'Content-Type' => "application/hal+json"} }
39
-
40
- before do
41
- standalone_service.
42
- upon_receiving("a request to create something").with(method: 'post', path: '/something', headers: expected_headers, body: expected_body).
43
- will_respond_with(status: 200, headers: {}, body: {a: 'response body'})
44
-
45
- standalone_service.
46
- upon_receiving("a request to create something else").with(method: 'post', path: '/something-else', headers: expected_headers, body: expected_body).
47
- will_respond_with(status: 200, headers: {}, body: {a: 'response body'})
48
- end
49
-
50
- it "will fail and display a helpful message" do
51
- subject.call
52
- end
53
- end
54
-
55
- end
@@ -1,51 +0,0 @@
1
- require 'pact/consumer/rspec'
2
- require './spec/support/active_support_if_configured'
3
-
4
- Pact.service_consumer "Standalone Consumer" do
5
- has_pact_with "Standalone Provider" do
6
- mock_service :standalone_service do
7
- port 1237
8
- end
9
- end
10
- end
11
-
12
- class StandaloneClient
13
-
14
- def initialize base_url
15
- @base_url = base_url
16
- end
17
-
18
- def call
19
- uri = URI("#{@base_url}/something")
20
- post_req = Net::HTTP::Post.new(uri.path)
21
- post_req['Content-Type'] = "application/json"
22
- post_req.body = {a: "body"}.to_json
23
- response = Net::HTTP.start(uri.hostname, uri.port) do |http|
24
- http.request post_req
25
- end
26
- response.body
27
- end
28
-
29
- end
30
-
31
- describe StandaloneClient, pact: true do
32
-
33
- subject { StandaloneClient.new("http://localhost:1237") }
34
-
35
- describe "call" do
36
-
37
- let(:expected_body) { {a: "body"} }
38
- let(:response_body) { {a: 'response body'} }
39
-
40
- before do
41
- standalone_service.
42
- upon_receiving("a request to create something").with(method: 'post', path: '/something', body: expected_body).
43
- will_respond_with(status: 200, headers: {}, body: response_body)
44
- end
45
-
46
- it "will pass" do
47
- expect(subject.call).to eq response_body.to_json
48
- end
49
- end
50
-
51
- end
@@ -1,32 +0,0 @@
1
- {
2
- "producer": {
3
- "name": "an old producer"
4
- },
5
- "consumer": {
6
- "name": "a consumer"
7
- },
8
- "interactions": [
9
- {
10
- "description": "request one",
11
- "request": {
12
- "method": "get",
13
- "path": "/path_one"
14
- },
15
- "response": {
16
- },
17
- "producer_state": "state one"
18
- },
19
- {
20
- "description": "request two",
21
- "request": {
22
- "method": "get",
23
- "path": "/path_two"
24
- },
25
- "response": {
26
- }
27
- }
28
- ],
29
- "metadata": {
30
- "pactSpecificationVersion": "1.0"
31
- }
32
- }
@@ -1,32 +0,0 @@
1
- {
2
- "provider": {
3
- "name": "a provider"
4
- },
5
- "consumer": {
6
- "name": "a consumer"
7
- },
8
- "interactions": [
9
- {
10
- "description": "request one",
11
- "request": {
12
- "method": "get",
13
- "path": "/path_one"
14
- },
15
- "response": {
16
- },
17
- "provider_state": "state one"
18
- },
19
- {
20
- "description": "request two",
21
- "request": {
22
- "method": "get",
23
- "path": "/path_two"
24
- },
25
- "response": {
26
- }
27
- }
28
- ],
29
- "metadata": {
30
- "pactSpecificationVersion": "1.0"
31
- }
32
- }
@@ -1,6 +0,0 @@
1
- if ENV['LOAD_ACTIVE_SUPPORT']
2
- puts 'LOADING ACTIVE SUPPORT!!!! Hopefully it all still works'
3
- require 'active_support/all'
4
- require 'active_support'
5
- require 'active_support/json'
6
- end