pact 1.3.3 → 1.4.0
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/CHANGELOG.md +37 -1
- data/lib/pact/cli.rb +0 -26
- data/lib/pact/consumer/configuration/configuration_extensions.rb +51 -0
- data/lib/pact/consumer/configuration/mock_service.rb +2 -1
- data/lib/pact/consumer/configuration.rb +0 -1
- data/lib/pact/consumer/consumer_contract_builder.rb +3 -3
- data/lib/pact/consumer/interaction_builder.rb +3 -5
- data/lib/pact/doc/interaction_view_model.rb +9 -6
- data/lib/pact/doc/sort_interactions.rb +1 -1
- data/lib/pact/provider/configuration/configuration_extension.rb +0 -9
- data/lib/pact/provider/rspec.rb +11 -9
- data/lib/pact/version.rb +1 -1
- data/lib/pact.rb +6 -5
- data/pact.gemspec +6 -2
- metadata +57 -304
- data/.gitignore +0 -29
- data/.rspec +0 -2
- data/.ruby-version +0 -1
- data/.travis.yml +0 -8
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -86
- data/README.md +0 -313
- data/Rakefile +0 -9
- data/config.ru +0 -3
- data/documentation/README.md +0 -13
- data/documentation/configuration.md +0 -166
- data/documentation/diff_formatter_embedded.png +0 -0
- data/documentation/diff_formatter_list.png +0 -0
- data/documentation/diff_formatter_unix.png +0 -0
- data/example/animal-service/Gemfile +0 -14
- data/example/animal-service/Gemfile.lock +0 -69
- data/example/animal-service/Rakefile +0 -5
- data/example/animal-service/config.ru +0 -3
- data/example/animal-service/db/animal_db.sqlite3 +0 -0
- data/example/animal-service/lib/animal_service/animal_repository.rb +0 -12
- data/example/animal-service/lib/animal_service/api.rb +0 -28
- data/example/animal-service/lib/animal_service/db.rb +0 -5
- data/example/animal-service/spec/service_consumers/pact_helper.rb +0 -11
- data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +0 -26
- data/example/zoo-app/Gemfile +0 -12
- data/example/zoo-app/Gemfile.lock +0 -63
- data/example/zoo-app/Rakefile +0 -5
- data/example/zoo-app/doc/pacts/markdown/README.md +0 -3
- data/example/zoo-app/doc/pacts/markdown/Zoo App - Animal Service.md +0 -75
- data/example/zoo-app/lib/zoo_app/animal_service_client.rb +0 -40
- data/example/zoo-app/lib/zoo_app/models/alligator.rb +0 -15
- data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +0 -67
- data/example/zoo-app/spec/service_providers/animal_service_client_spec.rb +0 -71
- data/example/zoo-app/spec/service_providers/pact_helper.rb +0 -15
- data/example/zoo-app/spec/spec_helper.rb +0 -6
- data/lib/pact/configuration.rb +0 -195
- data/lib/pact/consumer/app_manager.rb +0 -158
- data/lib/pact/consumer/interactions_filter.rb +0 -48
- data/lib/pact/consumer/mock_service/app.rb +0 -82
- data/lib/pact/consumer/mock_service/interaction_delete.rb +0 -33
- data/lib/pact/consumer/mock_service/interaction_list.rb +0 -76
- data/lib/pact/consumer/mock_service/interaction_mismatch.rb +0 -73
- data/lib/pact/consumer/mock_service/interaction_post.rb +0 -31
- data/lib/pact/consumer/mock_service/interaction_replay.rb +0 -139
- data/lib/pact/consumer/mock_service/log_get.rb +0 -28
- data/lib/pact/consumer/mock_service/missing_interactions_get.rb +0 -30
- data/lib/pact/consumer/mock_service/mock_service_administration_endpoint.rb +0 -31
- data/lib/pact/consumer/mock_service/pact_post.rb +0 -33
- data/lib/pact/consumer/mock_service/rack_request_helper.rb +0 -51
- data/lib/pact/consumer/mock_service/verification_get.rb +0 -68
- data/lib/pact/consumer/mock_service.rb +0 -2
- data/lib/pact/consumer/mock_service_client.rb +0 -65
- data/lib/pact/consumer/mock_service_interaction_expectation.rb +0 -37
- data/lib/pact/consumer/request.rb +0 -27
- data/lib/pact/consumer/server.rb +0 -90
- data/lib/pact/consumer_contract/consumer_contract.rb +0 -115
- data/lib/pact/consumer_contract/consumer_contract_writer.rb +0 -84
- data/lib/pact/consumer_contract/file_name.rb +0 -19
- data/lib/pact/consumer_contract/headers.rb +0 -51
- data/lib/pact/consumer_contract/interaction.rb +0 -67
- data/lib/pact/consumer_contract/pact_file.rb +0 -24
- data/lib/pact/consumer_contract/request.rb +0 -73
- data/lib/pact/consumer_contract/service_consumer.rb +0 -28
- data/lib/pact/consumer_contract/service_provider.rb +0 -28
- data/lib/pact/consumer_contract.rb +0 -1
- data/lib/pact/logging.rb +0 -14
- data/lib/pact/matchers/actual_type.rb +0 -16
- data/lib/pact/matchers/base_difference.rb +0 -37
- data/lib/pact/matchers/differ.rb +0 -153
- data/lib/pact/matchers/difference.rb +0 -13
- data/lib/pact/matchers/difference_indicator.rb +0 -26
- data/lib/pact/matchers/embedded_diff_formatter.rb +0 -62
- data/lib/pact/matchers/expected_type.rb +0 -35
- data/lib/pact/matchers/index_not_found.rb +0 -15
- data/lib/pact/matchers/list_diff_formatter.rb +0 -101
- data/lib/pact/matchers/matchers.rb +0 -139
- data/lib/pact/matchers/no_diff_indicator.rb +0 -18
- data/lib/pact/matchers/regexp_difference.rb +0 -13
- data/lib/pact/matchers/type_difference.rb +0 -16
- data/lib/pact/matchers/unexpected_index.rb +0 -11
- data/lib/pact/matchers/unexpected_key.rb +0 -11
- data/lib/pact/matchers/unix_diff_formatter.rb +0 -114
- data/lib/pact/matchers.rb +0 -1
- data/lib/pact/reification.rb +0 -28
- data/lib/pact/rspec.rb +0 -53
- data/lib/pact/shared/active_support_support.rb +0 -51
- data/lib/pact/shared/dsl.rb +0 -76
- data/lib/pact/shared/jruby_support.rb +0 -18
- data/lib/pact/shared/json_differ.rb +0 -15
- data/lib/pact/shared/key_not_found.rb +0 -15
- data/lib/pact/shared/null_expectation.rb +0 -31
- data/lib/pact/shared/request.rb +0 -80
- data/lib/pact/shared/text_differ.rb +0 -14
- data/lib/pact/something_like.rb +0 -49
- data/lib/pact/symbolize_keys.rb +0 -12
- data/lib/pact/term.rb +0 -85
- data/scratchpad.rb +0 -52
- data/spec/features/consumption_spec.rb +0 -114
- data/spec/features/production_spec.rb +0 -155
- data/spec/features/provider_states/zebras.rb +0 -28
- data/spec/integration/consumer_spec.rb +0 -212
- data/spec/integration/pact/consumer_configuration_spec.rb +0 -66
- data/spec/integration/pact/provider_configuration_spec.rb +0 -25
- data/spec/lib/pact/cli_spec.rb +0 -47
- data/spec/lib/pact/configuration_spec.rb +0 -297
- data/spec/lib/pact/consumer/app_manager_spec.rb +0 -41
- data/spec/lib/pact/consumer/configuration_spec.rb +0 -57
- data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +0 -69
- data/spec/lib/pact/consumer/interaction_builder_spec.rb +0 -91
- data/spec/lib/pact/consumer/interactions_spec.rb +0 -64
- data/spec/lib/pact/consumer/mock_service/app_spec.rb +0 -52
- data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +0 -78
- data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +0 -70
- data/spec/lib/pact/consumer/mock_service/interaction_replay_spec.rb +0 -12
- data/spec/lib/pact/consumer/mock_service/rack_request_helper_spec.rb +0 -88
- data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +0 -142
- data/spec/lib/pact/consumer/mock_service_client_spec.rb +0 -88
- data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +0 -54
- data/spec/lib/pact/consumer/request_spec.rb +0 -24
- data/spec/lib/pact/consumer/service_consumer_spec.rb +0 -11
- data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -180
- data/spec/lib/pact/consumer_contract/consumer_contract_writer_spec.rb +0 -111
- data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -107
- data/spec/lib/pact/consumer_contract/request_spec.rb +0 -329
- data/spec/lib/pact/doc/generator_spec.rb +0 -84
- data/spec/lib/pact/doc/interaction_view_model_spec.rb +0 -132
- data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +0 -29
- data/spec/lib/pact/doc/markdown/index_renderer_spec.rb +0 -29
- data/spec/lib/pact/matchers/differ_spec.rb +0 -214
- data/spec/lib/pact/matchers/difference_spec.rb +0 -22
- data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
- data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
- data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -114
- data/spec/lib/pact/matchers/matchers_spec.rb +0 -500
- data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
- data/spec/lib/pact/matchers/type_difference_spec.rb +0 -34
- data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
- data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
- data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -216
- data/spec/lib/pact/provider/configuration/configuration_extension_spec.rb +0 -30
- data/spec/lib/pact/provider/configuration/pact_verification_spec.rb +0 -43
- data/spec/lib/pact/provider/configuration/service_provider_config_spec.rb +0 -21
- data/spec/lib/pact/provider/configuration/service_provider_dsl_spec.rb +0 -108
- data/spec/lib/pact/provider/configuration_spec.rb +0 -50
- data/spec/lib/pact/provider/matchers/messages_spec.rb +0 -116
- data/spec/lib/pact/provider/pact_helper_locator_spec.rb +0 -54
- data/spec/lib/pact/provider/print_missing_provider_states_spec.rb +0 -19
- data/spec/lib/pact/provider/request_spec.rb +0 -78
- data/spec/lib/pact/provider/rspec/formatter_rspec_2_spec.rb +0 -68
- data/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb +0 -72
- data/spec/lib/pact/provider/rspec_spec.rb +0 -55
- data/spec/lib/pact/provider/state/provider_state_manager_spec.rb +0 -89
- data/spec/lib/pact/provider/state/provider_state_proxy_spec.rb +0 -80
- data/spec/lib/pact/provider/state/provider_state_spec.rb +0 -213
- data/spec/lib/pact/provider/world_spec.rb +0 -41
- data/spec/lib/pact/reification_spec.rb +0 -67
- data/spec/lib/pact/shared/dsl_spec.rb +0 -86
- data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
- data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
- data/spec/lib/pact/shared/request_spec.rb +0 -111
- data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
- data/spec/lib/pact/something_like_spec.rb +0 -21
- data/spec/lib/pact/tasks/task_helper_spec.rb +0 -74
- data/spec/lib/pact/tasks/verification_task_spec.rb +0 -75
- data/spec/lib/pact/term_spec.rb +0 -89
- data/spec/pact_specification/compliance-1.0.0.rb +0 -47
- data/spec/spec_helper.rb +0 -22
- data/spec/standalone/consumer_fail_test.rb +0 -55
- data/spec/standalone/consumer_pass_test.rb +0 -51
- data/spec/support/a_consumer-a_producer.json +0 -32
- data/spec/support/a_consumer-a_provider.json +0 -32
- data/spec/support/active_support_if_configured.rb +0 -6
- data/spec/support/app_for_config_ru.rb +0 -4
- data/spec/support/consumer_contract_template.json +0 -24
- data/spec/support/dsl_spec_support.rb +0 -7
- data/spec/support/factories.rb +0 -82
- data/spec/support/generated_index.md +0 -4
- data/spec/support/generated_markdown.md +0 -55
- data/spec/support/interaction_view_model.json +0 -63
- data/spec/support/interaction_view_model_with_terms.json +0 -50
- data/spec/support/markdown_pact.json +0 -48
- data/spec/support/missing_provider_states_output.txt +0 -25
- data/spec/support/options.json +0 -21
- data/spec/support/options_app.rb +0 -15
- data/spec/support/pact_helper.rb +0 -57
- data/spec/support/shared_examples_for_request.rb +0 -94
- data/spec/support/spec_support.rb +0 -20
- data/spec/support/stubbing.json +0 -22
- data/spec/support/stubbing_using_allow.rb +0 -29
- data/spec/support/term.json +0 -48
- data/spec/support/test_app_fail.json +0 -61
- data/spec/support/test_app_pass.json +0 -38
- data/spec/support/test_app_with_right_content_type_differ.json +0 -23
- data/tasks/pact-test.rake +0 -109
- data/tasks/spec.rake +0 -8
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/request'
|
|
3
|
-
|
|
4
|
-
describe Pact::Provider::Request::Replayable do
|
|
5
|
-
|
|
6
|
-
let(:path) { '/path?something' }
|
|
7
|
-
let(:body) { {a: 'body'} }
|
|
8
|
-
let(:headers) { {} }
|
|
9
|
-
let(:expected_request) do
|
|
10
|
-
instance_double('Pact::Request::Expected',
|
|
11
|
-
:method => 'post',
|
|
12
|
-
:full_path => path,
|
|
13
|
-
:body => body,
|
|
14
|
-
:headers => headers)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
subject { described_class.new(expected_request)}
|
|
18
|
-
|
|
19
|
-
describe "method" do
|
|
20
|
-
it 'returns the method' do
|
|
21
|
-
expect(subject.method).to eq 'post'
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
describe "path" do
|
|
25
|
-
it "returns the full path" do
|
|
26
|
-
expect(subject.path).to eq(path)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe "body" do
|
|
31
|
-
context "when body is a NullExpectation" do
|
|
32
|
-
let(:body) { Pact::NullExpectation.new }
|
|
33
|
-
it "returns an empty string, not sure if it should do this or return nil???" do
|
|
34
|
-
expect(subject.body).to eq ""
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
context "when body is an empty string" do
|
|
38
|
-
let(:body) { '' }
|
|
39
|
-
it "returns an empty string" do
|
|
40
|
-
expect(subject.body).to eq ""
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
context "when body is a string" do
|
|
44
|
-
let(:body) { 'a string'}
|
|
45
|
-
it "returns the string" do
|
|
46
|
-
expect(subject.body).to eq body
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
context "when body is a Term" do
|
|
50
|
-
let(:body) { Pact::Term.new(generate: 'a', matcher: /a/) }
|
|
51
|
-
it "returns the generated value" do
|
|
52
|
-
expect(subject.body).to eq "a"
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
context "when body is not a string" do
|
|
56
|
-
let(:body) { {a: 'body'} }
|
|
57
|
-
it "returns the object as a json string" do
|
|
58
|
-
expect(subject.body).to eq body.to_json
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe "headers" do
|
|
64
|
-
context "when headers are expected" do
|
|
65
|
-
let(:headers) { {"Content-Type" => "text/plain", "Content-Length" => "123", "X-Content-Type" => "special", "Access-Control-Request-Method" => "POST"} }
|
|
66
|
-
let(:expected_headers) { {"CONTENT_TYPE" => "text/plain", "CONTENT_LENGTH" => "123", "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "POST", "HTTP_X_CONTENT_TYPE" => "special"} }
|
|
67
|
-
it "transforms the headers into Rack format" do
|
|
68
|
-
expect(subject.headers).to eq( expected_headers )
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
context "when headers are not specified" do
|
|
72
|
-
let(:headers) { Pact::NullExpectation.new }
|
|
73
|
-
it "returns an empty hash" do
|
|
74
|
-
expect(subject.headers).to eq({})
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/rspec/formatter_rspec_2'
|
|
3
|
-
require './spec/support/factories'
|
|
4
|
-
require './spec/support/spec_support'
|
|
5
|
-
|
|
6
|
-
module Pact
|
|
7
|
-
module Provider
|
|
8
|
-
module RSpec
|
|
9
|
-
describe Formatter2 do
|
|
10
|
-
|
|
11
|
-
Pact::RSpec.with_rspec_3 do
|
|
12
|
-
|
|
13
|
-
# These methods don't exist in RSpec3
|
|
14
|
-
class Formatter2
|
|
15
|
-
def failure_color arg ; arg; end
|
|
16
|
-
def detail_color arg ; arg; end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
let(:interaction) { InteractionFactory.create 'provider_state' => 'a state', 'description' => 'a description'}
|
|
22
|
-
let(:pactfile_uri) { 'pact_file_uri' }
|
|
23
|
-
let(:description) { 'an interaction' }
|
|
24
|
-
let(:metadata) { {pact_interaction: interaction, pactfile_uri: pactfile_uri, pact_interaction_example_description: description}}
|
|
25
|
-
let(:example) { double("Example", metadata: metadata) }
|
|
26
|
-
let(:failed_examples) { [example, example] }
|
|
27
|
-
let(:output) { StringIO.new }
|
|
28
|
-
let(:rerun_command) { "rake pact:verify:at[pact_file_uri] PACT_DESCRIPTION=\"a description\" PACT_PROVIDER_STATE=\"a state\" # an interaction" }
|
|
29
|
-
let(:missing_provider_states) { 'missing_provider_states'}
|
|
30
|
-
|
|
31
|
-
subject { Formatter2.new output }
|
|
32
|
-
|
|
33
|
-
let(:output_result) { Pact::SpecSupport.remove_ansicolor output.string }
|
|
34
|
-
|
|
35
|
-
before do
|
|
36
|
-
allow(PrintMissingProviderStates).to receive(:call)
|
|
37
|
-
allow(subject).to receive(:failed_examples).and_return(failed_examples)
|
|
38
|
-
allow(Pact.provider_world.provider_states).to receive(:missing_provider_states).and_return(missing_provider_states)
|
|
39
|
-
subject.dump_commands_to_rerun_failed_examples
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe "#dump_commands_to_rerun_failed_examples" do
|
|
43
|
-
it "prints a list of rerun commands" do
|
|
44
|
-
expect(output_result).to include(rerun_command)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "only prints unique commands" do
|
|
48
|
-
expect(output_result.scan(rerun_command).size).to eq 1
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "prints a message about the logs" do
|
|
52
|
-
expect(output_result).to include("For assistance debugging failures")
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "prints missing provider states" do
|
|
56
|
-
expect(PrintMissingProviderStates).to receive(:call).with(missing_provider_states, output)
|
|
57
|
-
subject.dump_commands_to_rerun_failed_examples
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/rspec/formatter_rspec_3'
|
|
3
|
-
require './spec/support/factories'
|
|
4
|
-
require './spec/support/spec_support'
|
|
5
|
-
|
|
6
|
-
Pact::RSpec.with_rspec_3 do
|
|
7
|
-
module Pact
|
|
8
|
-
module Provider
|
|
9
|
-
module RSpec
|
|
10
|
-
describe Formatter do
|
|
11
|
-
|
|
12
|
-
let(:interaction) { InteractionFactory.create 'provider_state' => 'a state', 'description' => 'a description'}
|
|
13
|
-
let(:pactfile_uri) { 'pact_file_uri' }
|
|
14
|
-
let(:description) { 'an interaction' }
|
|
15
|
-
let(:metadata) { {pact_interaction: interaction, pactfile_uri: pactfile_uri, pact_interaction_example_description: description}}
|
|
16
|
-
let(:metadata_2) { metadata.merge(pact_interaction_example_description: 'another interaction')}
|
|
17
|
-
let(:example) { double("Example", metadata: metadata) }
|
|
18
|
-
let(:example_2) { double("Example", metadata: metadata_2) }
|
|
19
|
-
let(:failed_examples) { [example, example] }
|
|
20
|
-
let(:examples) { [example, example, example_2]}
|
|
21
|
-
let(:output) { StringIO.new }
|
|
22
|
-
let(:rerun_command) { "rake pact:verify:at[pact_file_uri] PACT_DESCRIPTION=\"a description\" PACT_PROVIDER_STATE=\"a state\" # an interaction" }
|
|
23
|
-
let(:missing_provider_states) { 'missing_provider_states'}
|
|
24
|
-
let(:summary) { double("summary", failure_count: 1, failed_examples: failed_examples, examples: examples)}
|
|
25
|
-
|
|
26
|
-
subject { Formatter.new output }
|
|
27
|
-
|
|
28
|
-
let(:output_result) { Pact::SpecSupport.remove_ansicolor output.string }
|
|
29
|
-
|
|
30
|
-
before do
|
|
31
|
-
allow(PrintMissingProviderStates).to receive(:call)
|
|
32
|
-
allow(subject).to receive(:failed_examples).and_return(failed_examples)
|
|
33
|
-
allow(Pact.provider_world.provider_states).to receive(:missing_provider_states).and_return(missing_provider_states)
|
|
34
|
-
subject.dump_summary summary
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe "#dump_summary" do
|
|
38
|
-
it "prints a list of rerun commands" do
|
|
39
|
-
expect(output_result).to include(rerun_command)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "only prints unique commands" do
|
|
43
|
-
expect(output_result.scan(rerun_command).size).to eq 1
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "prints a message about the logs" do
|
|
47
|
-
expect(output_result).to include("For assistance debugging failures")
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "prints the number of interactions" do
|
|
51
|
-
expect(output_result).to include("2 interactions")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "prints the number of failures" do
|
|
55
|
-
expect(output_result).to include("1 failure")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "prints missing provider states" do
|
|
59
|
-
expect(PrintMissingProviderStates).to receive(:call).with(missing_provider_states, output)
|
|
60
|
-
subject.dump_summary summary
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require 'pact/provider/rspec/matchers'
|
|
2
|
-
require 'pact/shared/json_differ'
|
|
3
|
-
require 'pact/matchers/unix_diff_formatter'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe "the match_term matcher" do
|
|
7
|
-
|
|
8
|
-
include Pact::RSpec::Matchers
|
|
9
|
-
|
|
10
|
-
let(:diff_formatter) { Pact::Matchers::UnixDiffFormatter }
|
|
11
|
-
|
|
12
|
-
it 'does not match a hash to an array' do
|
|
13
|
-
expect({}).to_not match_term([], with: Pact::JsonDiffer, diff_formatter: diff_formatter)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'does not match an array to a hash' do
|
|
17
|
-
expect([]).to_not match_term({}, with: Pact::JsonDiffer, diff_formatter: diff_formatter)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'matches regular expressions' do
|
|
21
|
-
expect('blah').to match_term(/[a-z]*/, with: Pact::JsonDiffer, diff_formatter: diff_formatter)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'matches pact terms' do
|
|
25
|
-
expect('wootle').to match_term Pact::Term.new(generate:'wootle', matcher:/woot../), with: Pact::JsonDiffer, diff_formatter: diff_formatter
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'matches all elements of arrays' do
|
|
29
|
-
expect(['one', 'two', ['three']]).to match_term [/one/, 'two', [Pact::Term.new(generate:'three', matcher:/thr../)]], with: Pact::JsonDiffer, diff_formatter: diff_formatter
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'matches all values of hashes' do
|
|
33
|
-
expect({1 => 'one', 2 => 2, 3 => 'three'}).to match_term({1 => /one/, 2 => 2, 3 => Pact::Term.new(generate:'three', matcher:/thr../)}, with: Pact::JsonDiffer, diff_formatter: diff_formatter)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'matches all other objects using ==' do
|
|
37
|
-
expect('wootle').to match_term 'wootle', with: Pact::JsonDiffer, diff_formatter: diff_formatter
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Note: because a consumer specifies only the keys it cares about, the pact ignores keys that are returned
|
|
41
|
-
# by the provider, but not are not specified in the pact. This means that any hash will match an
|
|
42
|
-
# expected empty hash, because there is currently no way for a consumer to expect an absence of keys.
|
|
43
|
-
it 'is confused by an empty hash' do
|
|
44
|
-
expect({:hello => 'everyone'}).to match_term({}, with: Pact::JsonDiffer, diff_formatter: diff_formatter)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'should not be confused by an empty array' do
|
|
48
|
-
expect(['blah']).to_not match_term([], with: Pact::JsonDiffer, diff_formatter: diff_formatter)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should allow matches on an array where each item in the array only contains a subset of the actual" do
|
|
52
|
-
expect([{name: 'Fred', age: 12}, {name: 'John', age: 13}]).to match_term([{name: 'Fred'}, {name: 'John'}], with: Pact::JsonDiffer, diff_formatter: diff_formatter)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
end
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/state/provider_state_manager'
|
|
3
|
-
|
|
4
|
-
module Pact::Provider::State
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
describe ProviderStateManager do
|
|
8
|
-
|
|
9
|
-
PROVIDER_STATE_MESSAGES = []
|
|
10
|
-
|
|
11
|
-
before do
|
|
12
|
-
PROVIDER_STATE_MESSAGES.clear
|
|
13
|
-
Pact.clear_provider_world
|
|
14
|
-
|
|
15
|
-
Pact.set_up do
|
|
16
|
-
PROVIDER_STATE_MESSAGES << :global_base_set_up
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
Pact.tear_down do
|
|
20
|
-
PROVIDER_STATE_MESSAGES << :global_base_tear_down
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
Pact.provider_states_for "a consumer with provider states" do
|
|
24
|
-
set_up do
|
|
25
|
-
PROVIDER_STATE_MESSAGES << :consumer_base_set_up
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
tear_down do
|
|
29
|
-
PROVIDER_STATE_MESSAGES << :consumer_base_tear_down
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
provider_state "a custom state" do
|
|
33
|
-
set_up do
|
|
34
|
-
PROVIDER_STATE_MESSAGES << :custom_consumer_state_set_up
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
tear_down do
|
|
38
|
-
PROVIDER_STATE_MESSAGES << :custom_consumer_state_tear_down
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
let(:provider_state_manager) { ProviderStateManager.new("a custom state", "a consumer with provider states") }
|
|
46
|
-
|
|
47
|
-
describe "set_up_provider_state" do
|
|
48
|
-
|
|
49
|
-
subject { provider_state_manager.set_up_provider_state }
|
|
50
|
-
|
|
51
|
-
it "sets up the global base state" do
|
|
52
|
-
subject
|
|
53
|
-
expect(PROVIDER_STATE_MESSAGES[0]).to eq :global_base_set_up
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "sets up the consumer base state" do
|
|
57
|
-
subject
|
|
58
|
-
expect(PROVIDER_STATE_MESSAGES[1]).to eq :consumer_base_set_up
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "sets up the consumer custom state" do
|
|
62
|
-
subject
|
|
63
|
-
expect(PROVIDER_STATE_MESSAGES[2]).to eq :custom_consumer_state_set_up
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe "tear_down_provider_state" do
|
|
68
|
-
|
|
69
|
-
subject { provider_state_manager.tear_down_provider_state }
|
|
70
|
-
|
|
71
|
-
it "tears down the consumer custom state" do
|
|
72
|
-
subject
|
|
73
|
-
expect(PROVIDER_STATE_MESSAGES[0]).to eq :custom_consumer_state_tear_down
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "tears down the consumer base state" do
|
|
77
|
-
subject
|
|
78
|
-
expect(PROVIDER_STATE_MESSAGES[1]).to eq :consumer_base_tear_down
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "tears down the global base state" do
|
|
82
|
-
subject
|
|
83
|
-
expect(PROVIDER_STATE_MESSAGES[2]).to eq :global_base_tear_down
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/state/provider_state_proxy'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
module Provider::State
|
|
6
|
-
describe ProviderStateProxy do
|
|
7
|
-
|
|
8
|
-
let(:provider_state_proxy) { ProviderStateProxy.new }
|
|
9
|
-
|
|
10
|
-
let(:options) { { :for => 'some consumer'} }
|
|
11
|
-
let(:provider_state) { double("provider_state")}
|
|
12
|
-
|
|
13
|
-
describe "get" do
|
|
14
|
-
let(:name) { "some state" }
|
|
15
|
-
|
|
16
|
-
subject { provider_state_proxy.get name, options }
|
|
17
|
-
|
|
18
|
-
before do
|
|
19
|
-
allow(ProviderStates).to receive(:get).and_return(provider_state)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context "when the provider state exists" do
|
|
23
|
-
|
|
24
|
-
it "retrieves the provider state from ProviderState" do
|
|
25
|
-
expect(ProviderStates).to receive(:get).with(name, options).and_return(provider_state)
|
|
26
|
-
subject
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "returns the state" do
|
|
30
|
-
expect(subject).to eq provider_state
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "when the state does not exist" do
|
|
36
|
-
|
|
37
|
-
let(:provider_state) { nil }
|
|
38
|
-
let(:expected_missing_provider_states) { {"some consumer" => ["some state"]} }
|
|
39
|
-
|
|
40
|
-
it "raises an error" do
|
|
41
|
-
expect { subject }.to raise_error /Could not find.*some state.*consumer.*/
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "records the provider state as missing" do
|
|
45
|
-
subject rescue nil
|
|
46
|
-
expect(provider_state_proxy.missing_provider_states).to eq expected_missing_provider_states
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "when the same missing provider state is requested" do
|
|
50
|
-
it "ensures the list only contains unique entries" do
|
|
51
|
-
subject rescue nil
|
|
52
|
-
subject rescue nil
|
|
53
|
-
expect(provider_state_proxy.missing_provider_states['some consumer'].size).to eq 1
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "get_base" do
|
|
62
|
-
|
|
63
|
-
before do
|
|
64
|
-
allow(ProviderStates).to receive(:get_base).and_return(provider_state)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
subject { provider_state_proxy.get_base options }
|
|
68
|
-
|
|
69
|
-
it "calls through to ProviderStates" do
|
|
70
|
-
expect(ProviderStates).to receive(:get_base).with(options)
|
|
71
|
-
subject
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "returns the state" do
|
|
75
|
-
expect(subject).to eq provider_state
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/state/provider_state'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
module Provider::State
|
|
6
|
-
|
|
7
|
-
describe ProviderStates do
|
|
8
|
-
MESSAGES = []
|
|
9
|
-
|
|
10
|
-
before do
|
|
11
|
-
MESSAGES.clear
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe 'global ProviderState' do
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Pact.provider_state :no_alligators do
|
|
18
|
-
set_up do
|
|
19
|
-
MESSAGES << 'set_up'
|
|
20
|
-
end
|
|
21
|
-
tear_down do
|
|
22
|
-
MESSAGES << 'tear_down'
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
Pact.provider_state 'some alligators' do
|
|
27
|
-
no_op
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
subject { ProviderStates.get('no_alligators') }
|
|
32
|
-
|
|
33
|
-
describe 'set_up' do
|
|
34
|
-
it 'should call the block passed to set_up' do
|
|
35
|
-
subject.set_up
|
|
36
|
-
expect(MESSAGES).to eq ['set_up']
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe 'tear_down' do
|
|
41
|
-
it 'should call the block passed to set_up' do
|
|
42
|
-
subject.tear_down
|
|
43
|
-
expect(MESSAGES).to eq ['tear_down']
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe '.get' do
|
|
48
|
-
context 'when the name is a matching symbol' do
|
|
49
|
-
it 'will return the ProviderState' do
|
|
50
|
-
expect(ProviderStates.get('no_alligators')).to_not be_nil
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
context 'when the name is a matching string' do
|
|
54
|
-
it 'will return the ProviderState' do
|
|
55
|
-
expect(ProviderStates.get('some alligators')).to_not be_nil
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe 'no_op' do
|
|
62
|
-
context "when a no_op is defined instead of a set_up or tear_down" do
|
|
63
|
-
it "treats set_up and tear_down as empty blocks" do
|
|
64
|
-
Pact.provider_state 'with_no_op' do
|
|
65
|
-
no_op
|
|
66
|
-
end
|
|
67
|
-
ProviderStates.get('with_no_op').set_up
|
|
68
|
-
ProviderStates.get('with_no_op').tear_down
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
context "when a no_op is defined with a set_up" do
|
|
72
|
-
it "raises an error" do
|
|
73
|
-
expect do
|
|
74
|
-
Pact.provider_state 'with_no_op_and_set_up' do
|
|
75
|
-
no_op
|
|
76
|
-
set_up do
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
end.to raise_error(/Provider state \"with_no_op_and_set_up\" has been defined as a no_op but it also has a set_up block. Please remove one or the other./)
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
context "when a no_op is defined with a tear_down" do
|
|
84
|
-
it "raises an error" do
|
|
85
|
-
expect do
|
|
86
|
-
Pact.provider_state 'with_no_op_and_set_up' do
|
|
87
|
-
no_op
|
|
88
|
-
tear_down do
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
end.to raise_error(/Provider state \"with_no_op_and_set_up\" has been defined as a no_op but it also has a tear_down block. Please remove one or the other./)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
describe 'namespaced ProviderStates' do
|
|
100
|
-
|
|
101
|
-
NAMESPACED_MESSAGES = []
|
|
102
|
-
|
|
103
|
-
Pact.provider_states_for 'a consumer' do
|
|
104
|
-
provider_state 'the weather is sunny' do
|
|
105
|
-
set_up do
|
|
106
|
-
NAMESPACED_MESSAGES << 'sunny!'
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
Pact.provider_state 'the weather is cloudy' do
|
|
112
|
-
set_up do
|
|
113
|
-
NAMESPACED_MESSAGES << 'cloudy :('
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
before do
|
|
118
|
-
NAMESPACED_MESSAGES.clear
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
describe '.get' do
|
|
122
|
-
context 'for a consumer' do
|
|
123
|
-
it 'has a namespaced name' do
|
|
124
|
-
expect(ProviderStates.get('the weather is sunny', :for => 'a consumer')).to_not be_nil
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it 'falls back to a global state of the same name if one is not found for the specified consumer' do
|
|
128
|
-
expect(ProviderStates.get('the weather is cloudy', :for => 'a consumer')).to_not be_nil
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
describe 'set_up' do
|
|
135
|
-
context 'for a consumer' do
|
|
136
|
-
it 'runs its own setup' do
|
|
137
|
-
ProviderStates.get('the weather is sunny', :for => 'a consumer').set_up
|
|
138
|
-
expect(NAMESPACED_MESSAGES).to eq ['sunny!']
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
describe "base_provider_state" do
|
|
145
|
-
Pact.provider_states_for "a consumer with base state" do
|
|
146
|
-
set_up do
|
|
147
|
-
MESSAGES << "setting up base provider state"
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
context "when the base state has been declared" do
|
|
152
|
-
it "creates a base state for the provider" do
|
|
153
|
-
ProviderStates.get_base(:for => "a consumer with base state").set_up
|
|
154
|
-
expect(MESSAGES).to eq ["setting up base provider state"]
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
context "when a base state has not been declared" do
|
|
160
|
-
it "returns a no op state" do
|
|
161
|
-
ProviderStates.get_base(:for => "a consumer that does not exist").set_up
|
|
162
|
-
ProviderStates.get_base(:for => "a consumer that does not exist").tear_down
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
describe "global base_provider_state" do
|
|
169
|
-
|
|
170
|
-
before(:all) do
|
|
171
|
-
Pact.set_up do
|
|
172
|
-
MESSAGES << "setting up global base provider state"
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
context "when the base state has been declared" do
|
|
177
|
-
it "creates a base state for the provider" do
|
|
178
|
-
ProviderStates.get_base.set_up
|
|
179
|
-
expect(MESSAGES).to eq ["setting up global base provider state"]
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context "when a base state has not been declared" do
|
|
185
|
-
it "returns a no op state" do
|
|
186
|
-
ProviderStates.get_base.set_up
|
|
187
|
-
ProviderStates.get_base.tear_down
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
describe "invalid provider state" do
|
|
193
|
-
context "when no set_up or tear_down is provided" do
|
|
194
|
-
it "raises an error to prevent someone forgetting about the set_up and putting the set_up code directly in the provider_state block and wasting 20 minutes trying to work out why their provider states aren't working properly" do
|
|
195
|
-
expect do
|
|
196
|
-
Pact.provider_state 'invalid' do
|
|
197
|
-
end
|
|
198
|
-
end.to raise_error(/Please provide a set_up or tear_down block for provider state \"invalid\"/)
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
context "when a no_op is defined" do
|
|
202
|
-
it "does not raise an error" do
|
|
203
|
-
expect do
|
|
204
|
-
Pact.provider_state 'valid' do
|
|
205
|
-
no_op
|
|
206
|
-
end
|
|
207
|
-
end.not_to raise_error
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
end
|
|
@@ -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
|