pact 0.1.28 → 1.3.3
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 +2 -1
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +374 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +58 -55
- data/README.md +214 -139
- data/Rakefile +4 -28
- data/bin/pact +2 -2
- data/config.ru +3 -0
- data/documentation/README.md +13 -0
- data/documentation/configuration.md +166 -0
- 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 +14 -0
- data/example/animal-service/Gemfile.lock +69 -0
- data/example/animal-service/Rakefile +5 -0
- data/example/animal-service/config.ru +3 -0
- data/example/animal-service/db/animal_db.sqlite3 +0 -0
- data/example/animal-service/lib/animal_service/animal_repository.rb +12 -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 +11 -0
- data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +26 -0
- data/example/zoo-app/Gemfile +12 -0
- data/example/zoo-app/Gemfile.lock +63 -0
- data/example/zoo-app/Rakefile +5 -0
- data/example/zoo-app/doc/pacts/markdown/README.md +3 -0
- data/example/zoo-app/doc/pacts/markdown/Zoo App - Animal Service.md +75 -0
- data/example/zoo-app/lib/zoo_app/animal_service_client.rb +40 -0
- data/example/zoo-app/lib/zoo_app/models/alligator.rb +15 -0
- data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +67 -0
- data/example/zoo-app/spec/service_providers/animal_service_client_spec.rb +71 -0
- data/example/zoo-app/spec/service_providers/pact_helper.rb +15 -0
- data/example/zoo-app/spec/spec_helper.rb +6 -0
- data/lib/pact/cli.rb +138 -0
- data/lib/pact/configuration.rb +169 -28
- data/lib/pact/consumer/app_manager.rb +10 -29
- data/lib/pact/consumer/configuration/configuration_extensions.rb +15 -0
- data/lib/pact/consumer/configuration/dsl.rb +12 -0
- data/lib/pact/consumer/configuration/mock_service.rb +91 -0
- data/lib/pact/consumer/configuration/service_consumer.rb +51 -0
- data/lib/pact/consumer/configuration/service_provider.rb +40 -0
- data/lib/pact/consumer/configuration.rb +11 -0
- data/lib/pact/consumer/consumer_contract_builder.rb +44 -47
- data/lib/pact/consumer/interaction_builder.rb +41 -0
- data/lib/pact/consumer/interactions_filter.rb +48 -0
- data/lib/pact/consumer/mock_service/app.rb +82 -0
- data/lib/pact/consumer/mock_service/interaction_delete.rb +33 -0
- data/lib/pact/consumer/mock_service/interaction_list.rb +76 -0
- data/lib/pact/consumer/mock_service/interaction_mismatch.rb +73 -0
- data/lib/pact/consumer/mock_service/interaction_post.rb +31 -0
- data/lib/pact/consumer/mock_service/interaction_replay.rb +139 -0
- data/lib/pact/consumer/mock_service/log_get.rb +28 -0
- data/lib/pact/consumer/mock_service/missing_interactions_get.rb +30 -0
- data/lib/pact/consumer/mock_service/mock_service_administration_endpoint.rb +31 -0
- data/lib/pact/consumer/mock_service/pact_post.rb +33 -0
- data/lib/pact/consumer/mock_service/rack_request_helper.rb +51 -0
- data/lib/pact/consumer/mock_service/verification_get.rb +68 -0
- data/lib/pact/consumer/mock_service.rb +1 -339
- data/lib/pact/consumer/mock_service_client.rb +65 -0
- data/lib/pact/consumer/mock_service_interaction_expectation.rb +37 -0
- data/lib/pact/consumer/request.rb +27 -0
- data/lib/pact/consumer/rspec.rb +9 -19
- data/lib/pact/consumer/server.rb +90 -0
- data/lib/pact/consumer/spec_hooks.rb +38 -0
- data/lib/pact/consumer/world.rb +37 -0
- data/lib/pact/consumer.rb +10 -7
- data/lib/pact/consumer_contract/consumer_contract.rb +115 -0
- data/lib/pact/consumer_contract/consumer_contract_writer.rb +84 -0
- data/lib/pact/consumer_contract/file_name.rb +19 -0
- data/lib/pact/consumer_contract/headers.rb +51 -0
- data/lib/pact/consumer_contract/interaction.rb +67 -0
- data/lib/pact/consumer_contract/pact_file.rb +24 -0
- data/lib/pact/consumer_contract/request.rb +73 -0
- data/lib/pact/consumer_contract/service_consumer.rb +28 -0
- data/lib/pact/consumer_contract/service_provider.rb +28 -0
- data/lib/pact/consumer_contract.rb +1 -110
- data/lib/pact/doc/doc_file.rb +40 -0
- data/lib/pact/doc/generate.rb +11 -0
- data/lib/pact/doc/generator.rb +82 -0
- data/lib/pact/doc/interaction_view_model.rb +114 -0
- data/lib/pact/doc/markdown/consumer_contract_renderer.rb +56 -0
- data/lib/pact/doc/markdown/generator.rb +26 -0
- data/lib/pact/doc/markdown/index_renderer.rb +41 -0
- data/lib/pact/doc/markdown/interaction.erb +14 -0
- data/lib/pact/doc/markdown/interaction_renderer.rb +38 -0
- data/lib/pact/doc/sort_interactions.rb +17 -0
- data/lib/pact/matchers/actual_type.rb +16 -0
- data/lib/pact/matchers/base_difference.rb +37 -0
- data/lib/pact/matchers/differ.rb +153 -0
- data/lib/pact/matchers/difference.rb +13 -0
- data/lib/pact/matchers/difference_indicator.rb +26 -0
- data/lib/pact/matchers/embedded_diff_formatter.rb +62 -0
- data/lib/pact/matchers/expected_type.rb +35 -0
- data/lib/pact/matchers/index_not_found.rb +15 -0
- data/lib/pact/matchers/list_diff_formatter.rb +101 -0
- data/lib/pact/matchers/matchers.rb +91 -37
- data/lib/pact/matchers/no_diff_indicator.rb +18 -0
- data/lib/pact/matchers/regexp_difference.rb +13 -0
- data/lib/pact/matchers/type_difference.rb +16 -0
- data/lib/pact/matchers/unexpected_index.rb +11 -0
- data/lib/pact/matchers/unexpected_key.rb +11 -0
- data/lib/pact/matchers/unix_diff_formatter.rb +114 -0
- data/lib/pact/project_root.rb +7 -0
- data/lib/pact/provider/configuration/configuration_extension.rb +58 -0
- data/lib/pact/provider/configuration/dsl.rb +13 -0
- data/lib/pact/provider/configuration/pact_verification.rb +46 -0
- data/lib/pact/provider/configuration/service_provider_config.rb +16 -0
- data/lib/pact/provider/configuration/service_provider_dsl.rb +59 -0
- data/lib/pact/provider/configuration.rb +7 -0
- data/lib/pact/provider/context.rb +0 -0
- data/lib/pact/provider/matchers/messages.rb +45 -0
- data/lib/pact/provider/pact_helper_locator.rb +22 -0
- data/lib/pact/provider/pact_spec_runner.rb +123 -0
- data/lib/pact/provider/pact_verification.rb +17 -0
- data/lib/pact/provider/print_missing_provider_states.rb +30 -0
- data/lib/pact/provider/request.rb +70 -0
- data/lib/pact/provider/rspec/backtrace_formatter.rb +43 -0
- data/lib/pact/provider/rspec/custom_options_file +0 -0
- data/lib/pact/provider/rspec/formatter_rspec_2.rb +65 -0
- data/lib/pact/provider/rspec/formatter_rspec_3.rb +96 -0
- data/lib/pact/provider/rspec/matchers.rb +97 -0
- data/lib/pact/provider/rspec.rb +181 -0
- data/lib/pact/provider/state/provider_state.rb +181 -0
- data/lib/pact/provider/state/provider_state_configured_modules.rb +13 -0
- data/lib/pact/provider/state/provider_state_manager.rb +42 -0
- data/lib/pact/provider/state/provider_state_proxy.rb +39 -0
- data/lib/pact/provider/test_methods.rb +47 -0
- data/lib/pact/provider/verification_report.rb +36 -0
- data/lib/pact/provider/world.rb +23 -0
- data/lib/pact/provider.rb +3 -0
- data/lib/pact/reification.rb +6 -4
- data/lib/pact/rspec.rb +53 -0
- data/lib/pact/shared/active_support_support.rb +51 -0
- data/lib/pact/shared/dsl.rb +76 -0
- data/lib/pact/shared/jruby_support.rb +18 -0
- data/lib/pact/shared/json_differ.rb +15 -0
- data/lib/pact/shared/key_not_found.rb +15 -0
- data/lib/pact/shared/null_expectation.rb +31 -0
- data/lib/pact/shared/request.rb +80 -0
- data/lib/pact/shared/text_differ.rb +14 -0
- data/lib/pact/something_like.rb +49 -0
- data/lib/pact/symbolize_keys.rb +12 -0
- data/lib/pact/tasks/task_helper.rb +36 -0
- data/lib/pact/tasks/verification_task.rb +87 -0
- data/lib/pact/tasks.rb +2 -0
- data/lib/pact/templates/provider_state.erb +14 -0
- data/lib/pact/term.rb +47 -2
- data/lib/pact/version.rb +1 -1
- data/lib/pact.rb +1 -1
- data/lib/tasks/pact.rake +25 -2
- data/pact.gemspec +13 -11
- data/{scratchpad.txt → scratchpad.rb} +18 -2
- data/spec/features/consumption_spec.rb +24 -56
- data/spec/features/production_spec.rb +19 -24
- data/spec/features/{producer_states → provider_states}/zebras.rb +3 -3
- data/spec/integration/consumer_spec.rb +212 -0
- data/spec/integration/pact/consumer_configuration_spec.rb +66 -0
- data/spec/integration/pact/provider_configuration_spec.rb +25 -0
- data/spec/lib/pact/cli_spec.rb +47 -0
- data/spec/lib/pact/configuration_spec.rb +269 -7
- data/spec/lib/pact/consumer/app_manager_spec.rb +3 -3
- data/spec/lib/pact/consumer/configuration_spec.rb +57 -0
- data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +52 -70
- data/spec/lib/pact/consumer/interaction_builder_spec.rb +91 -0
- data/spec/lib/pact/consumer/interactions_spec.rb +64 -0
- data/spec/lib/pact/consumer/mock_service/app_spec.rb +52 -0
- data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +78 -0
- data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +70 -0
- data/spec/lib/pact/consumer/mock_service/interaction_replay_spec.rb +12 -0
- data/spec/lib/pact/consumer/mock_service/rack_request_helper_spec.rb +88 -0
- data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +142 -0
- data/spec/lib/pact/consumer/mock_service_client_spec.rb +88 -0
- data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +54 -0
- data/spec/lib/pact/consumer/request_spec.rb +24 -0
- data/spec/lib/pact/consumer/service_consumer_spec.rb +1 -1
- data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +58 -0
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +180 -0
- data/spec/lib/pact/consumer_contract/consumer_contract_writer_spec.rb +111 -0
- data/spec/lib/pact/consumer_contract/headers_spec.rb +107 -0
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +107 -0
- data/spec/lib/pact/{request_spec.rb → consumer_contract/request_spec.rb} +80 -67
- data/spec/lib/pact/doc/generator_spec.rb +84 -0
- data/spec/lib/pact/doc/interaction_view_model_spec.rb +132 -0
- data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +29 -0
- data/spec/lib/pact/doc/markdown/index_renderer_spec.rb +29 -0
- data/spec/lib/pact/matchers/differ_spec.rb +214 -0
- data/spec/lib/pact/matchers/difference_spec.rb +22 -0
- data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +90 -0
- data/spec/lib/pact/matchers/index_not_found_spec.rb +21 -0
- data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +114 -0
- data/spec/lib/pact/matchers/matchers_spec.rb +400 -254
- data/spec/lib/pact/matchers/regexp_difference_spec.rb +20 -0
- data/spec/lib/pact/matchers/type_difference_spec.rb +34 -0
- data/spec/lib/pact/matchers/unexpected_index_spec.rb +20 -0
- data/spec/lib/pact/matchers/unexpected_key_spec.rb +20 -0
- data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +216 -0
- data/spec/lib/pact/provider/configuration/configuration_extension_spec.rb +30 -0
- data/spec/lib/pact/provider/configuration/pact_verification_spec.rb +43 -0
- data/spec/lib/pact/provider/configuration/service_provider_config_spec.rb +21 -0
- data/spec/lib/pact/provider/configuration/service_provider_dsl_spec.rb +108 -0
- data/spec/lib/pact/provider/configuration_spec.rb +50 -0
- data/spec/lib/pact/provider/matchers/messages_spec.rb +116 -0
- data/spec/lib/pact/provider/pact_helper_locator_spec.rb +54 -0
- data/spec/lib/pact/provider/print_missing_provider_states_spec.rb +19 -0
- data/spec/lib/pact/provider/request_spec.rb +78 -0
- data/spec/lib/pact/provider/rspec/formatter_rspec_2_spec.rb +68 -0
- data/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb +72 -0
- data/spec/lib/pact/provider/rspec_spec.rb +55 -0
- data/spec/lib/pact/provider/state/provider_state_manager_spec.rb +89 -0
- data/spec/lib/pact/provider/state/provider_state_proxy_spec.rb +80 -0
- data/spec/lib/pact/provider/state/provider_state_spec.rb +213 -0
- data/spec/lib/pact/provider/world_spec.rb +41 -0
- data/spec/lib/pact/reification_spec.rb +24 -0
- data/spec/lib/pact/shared/dsl_spec.rb +86 -0
- data/spec/lib/pact/shared/json_differ_spec.rb +36 -0
- data/spec/lib/pact/shared/key_not_found_spec.rb +20 -0
- data/spec/lib/pact/shared/request_spec.rb +111 -0
- data/spec/lib/pact/shared/text_differ_spec.rb +54 -0
- data/spec/lib/pact/something_like_spec.rb +21 -0
- data/spec/lib/pact/tasks/task_helper_spec.rb +74 -0
- data/spec/lib/pact/tasks/verification_task_spec.rb +75 -0
- data/spec/lib/pact/term_spec.rb +57 -4
- data/spec/pact_specification/compliance-1.0.0.rb +47 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/standalone/consumer_fail_test.rb +55 -0
- data/spec/standalone/consumer_pass_test.rb +51 -0
- data/spec/support/a_consumer-a_producer.json +2 -4
- data/spec/support/a_consumer-a_provider.json +32 -0
- data/spec/support/active_support_if_configured.rb +6 -0
- data/spec/support/app_for_config_ru.rb +4 -0
- data/spec/support/consumer_contract_template.json +24 -0
- data/spec/support/dsl_spec_support.rb +7 -0
- data/spec/support/factories.rb +82 -0
- data/spec/support/generated_index.md +4 -0
- data/spec/support/generated_markdown.md +55 -0
- data/spec/support/interaction_view_model.json +63 -0
- data/spec/support/interaction_view_model_with_terms.json +50 -0
- data/spec/support/markdown_pact.json +48 -0
- data/spec/support/missing_provider_states_output.txt +25 -0
- data/spec/support/options.json +21 -0
- data/spec/support/options_app.rb +15 -0
- data/spec/support/pact_helper.rb +57 -0
- data/spec/support/shared_examples_for_request.rb +94 -0
- data/spec/support/spec_support.rb +20 -0
- data/spec/support/stubbing.json +22 -0
- data/spec/support/stubbing_using_allow.rb +29 -0
- data/spec/support/term.json +48 -0
- data/spec/support/test_app_fail.json +41 -2
- data/spec/support/test_app_pass.json +19 -2
- data/spec/support/test_app_with_right_content_type_differ.json +23 -0
- data/tasks/pact-test.rake +98 -8
- data/tasks/spec.rake +8 -0
- metadata +393 -95
- data/lib/pact/app.rb +0 -32
- data/lib/pact/consumer/configuration_dsl.rb +0 -71
- data/lib/pact/consumer/dsl.rb +0 -98
- data/lib/pact/consumer/interaction.rb +0 -70
- data/lib/pact/consumer/run_condor.rb +0 -4
- data/lib/pact/consumer/run_mock_contract_service.rb +0 -13
- data/lib/pact/consumer/service_consumer.rb +0 -22
- data/lib/pact/consumer/service_producer.rb +0 -23
- data/lib/pact/json_warning.rb +0 -23
- data/lib/pact/producer/configuration_dsl.rb +0 -62
- data/lib/pact/producer/matchers.rb +0 -22
- data/lib/pact/producer/pact_spec_runner.rb +0 -57
- data/lib/pact/producer/producer_state.rb +0 -81
- data/lib/pact/producer/rspec.rb +0 -127
- data/lib/pact/producer/test_methods.rb +0 -89
- data/lib/pact/producer.rb +0 -1
- data/lib/pact/rake_task.rb +0 -64
- data/lib/pact/request.rb +0 -109
- data/lib/pact/verification_task.rb +0 -57
- data/spec/integration/pact/configuration_spec.rb +0 -65
- data/spec/lib/pact/consumer/dsl_spec.rb +0 -52
- data/spec/lib/pact/consumer/interaction_spec.rb +0 -108
- data/spec/lib/pact/consumer/mock_service_spec.rb +0 -147
- data/spec/lib/pact/consumer_contract_spec.rb +0 -125
- data/spec/lib/pact/producer/configuration_dsl_spec.rb +0 -101
- data/spec/lib/pact/producer/producer_state_spec.rb +0 -103
- data/spec/lib/pact/producer/rspec_spec.rb +0 -48
- data/spec/lib/pact/verification_task_spec.rb +0 -64
- data/spec/support/pact_rake_support.rb +0 -41
|
@@ -0,0 +1,213 @@
|
|
|
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
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
|
@@ -39,5 +39,29 @@ module Pact
|
|
|
39
39
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
context "when reifying a Request" do
|
|
43
|
+
|
|
44
|
+
let(:request){ Pact::Request::Expected.from_hash(method: 'get', path: '/', body: Pact::Term.new(generate: "sunny", matcher: /sun/))}
|
|
45
|
+
|
|
46
|
+
subject { Reification.from_term(request) }
|
|
47
|
+
|
|
48
|
+
it "turns it into a hash before reifying it" do
|
|
49
|
+
expect(subject[:body]).to eq("sunny")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "when SomethingLike" do
|
|
55
|
+
|
|
56
|
+
let(:request) { Pact::SomethingLike.new({a: 'String'})}
|
|
57
|
+
|
|
58
|
+
subject { Reification.from_term(request)}
|
|
59
|
+
|
|
60
|
+
it "returns the contents of the SomethingLike" do
|
|
61
|
+
expect(subject).to eq({a: 'String'})
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
42
66
|
end
|
|
43
67
|
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'pact/shared/dsl'
|
|
3
|
+
require 'support/dsl_spec_support'
|
|
4
|
+
|
|
5
|
+
module Pact
|
|
6
|
+
describe DSL do
|
|
7
|
+
|
|
8
|
+
class TestDSL
|
|
9
|
+
extend DSL
|
|
10
|
+
attr_accessor :thing, :blah, :global, :the_block, :another_block, :finalized
|
|
11
|
+
|
|
12
|
+
dsl do
|
|
13
|
+
def with_thing thing
|
|
14
|
+
self.thing = thing
|
|
15
|
+
end
|
|
16
|
+
def with_blah blah
|
|
17
|
+
self.blah = blah
|
|
18
|
+
end
|
|
19
|
+
def with_global global
|
|
20
|
+
self.global = global
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def with_block &the_block
|
|
24
|
+
self.the_block = the_block
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def with_another_block &the_block
|
|
28
|
+
self.another_block = the_block
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def finalize
|
|
34
|
+
@finalized = true
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "build" do
|
|
39
|
+
before do
|
|
40
|
+
def my_local_method
|
|
41
|
+
'LA LA LA'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
my_local_var = 123
|
|
45
|
+
|
|
46
|
+
local_app = "I'm a local app"
|
|
47
|
+
|
|
48
|
+
@test = TestDSL.build do
|
|
49
|
+
with_thing my_local_method
|
|
50
|
+
with_blah my_local_var
|
|
51
|
+
with_global global_method
|
|
52
|
+
with_block do
|
|
53
|
+
global_app
|
|
54
|
+
end
|
|
55
|
+
with_another_block do
|
|
56
|
+
local_app
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "supports using a local variable" do
|
|
62
|
+
expect(@test.blah).to eq 123
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "supports using a local method" do
|
|
66
|
+
expect(@test.thing).to eq 'LA LA LA'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "supports using global methods from other files" do
|
|
70
|
+
expect(@test.global).to eq "I'm global"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "supports using a local method to provide the app" do
|
|
74
|
+
expect(@test.another_block.call).to eq("I'm a local app")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should support using a global method to provide the app but it doesn't" do
|
|
78
|
+
expect(@test.the_block.call).to eq("I'm a global app")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "calls finalize" do
|
|
82
|
+
expect(@test.finalized).to be true
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'pact/shared/json_differ'
|
|
3
|
+
|
|
4
|
+
module Pact
|
|
5
|
+
describe JsonDiffer do
|
|
6
|
+
|
|
7
|
+
describe ".call" do
|
|
8
|
+
|
|
9
|
+
let(:expected) { {'a' => 'b'} }
|
|
10
|
+
|
|
11
|
+
subject { JsonDiffer.call(expected, actual) }
|
|
12
|
+
|
|
13
|
+
context "when the actual is valid JSON" do
|
|
14
|
+
|
|
15
|
+
let(:actual) { {'a' => 'c'} }
|
|
16
|
+
let(:difference) { {'a' => Pact::Matchers::Difference.new('b', 'c')} }
|
|
17
|
+
|
|
18
|
+
context "when the actual does not equal the expected" do
|
|
19
|
+
it "parses the JSON and returns a diff" do
|
|
20
|
+
expect(subject).to eq(difference)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "when the actual equals the expected" do
|
|
25
|
+
let(:actual) { expected }
|
|
26
|
+
it "parses the JSON and returns an empty diff" do
|
|
27
|
+
expect(subject.any?).to be false
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'pact/shared/key_not_found'
|
|
3
|
+
|
|
4
|
+
module Pact
|
|
5
|
+
describe KeyNotFound do
|
|
6
|
+
|
|
7
|
+
describe "#as_json" do
|
|
8
|
+
it "returns a string representation of the object" do
|
|
9
|
+
expect(subject.as_json).to eq subject.to_s
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#to_json" do
|
|
14
|
+
it "serialises the object to JSON" do
|
|
15
|
+
expect(subject.to_json).to eq "\"#{subject.to_s}\""
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'pact/shared/request'
|
|
3
|
+
require 'pact/shared/key_not_found'
|
|
4
|
+
|
|
5
|
+
module Pact
|
|
6
|
+
|
|
7
|
+
module Request
|
|
8
|
+
|
|
9
|
+
describe Base do
|
|
10
|
+
|
|
11
|
+
class TestRequest < Base
|
|
12
|
+
|
|
13
|
+
def self.key_not_found
|
|
14
|
+
Pact::KeyNotFound.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
subject { TestRequest.new("get", "/", {some: "things"}, {some: "things"} , "some=things") }
|
|
20
|
+
|
|
21
|
+
describe "#to_json" do
|
|
22
|
+
it "renders the keys in a sensible order" do
|
|
23
|
+
expect(subject.to_json).to match(/method.*path.*query.*headers.*body/)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "#full_path" do
|
|
28
|
+
|
|
29
|
+
subject { TestRequest.new("get", "/something", {}, {some: "things"} , query).full_path }
|
|
30
|
+
|
|
31
|
+
context "with a query that is a Pact::Term" do
|
|
32
|
+
let(:query) { Pact::Term.new(generate: "some=things", matcher: /some/) }
|
|
33
|
+
it "reifies and appends the query" do
|
|
34
|
+
expect(subject).to eq("/something?some=things")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "with a query that is a string" do
|
|
39
|
+
let(:query) { "some=things" }
|
|
40
|
+
it "appends the query" do
|
|
41
|
+
expect(subject).to eq("/something?some=things")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "with an empty query" do
|
|
46
|
+
let(:query) { "" }
|
|
47
|
+
it "does include a query" do
|
|
48
|
+
expect(subject).to eq("/something")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "with a nil query" do
|
|
53
|
+
let(:query) { nil }
|
|
54
|
+
it "does not include a query" do
|
|
55
|
+
expect(subject).to eq("/something")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "#method_and_path" do
|
|
61
|
+
context "with an empty path" do
|
|
62
|
+
subject { TestRequest.new("get", "", {}, {} , "").method_and_path }
|
|
63
|
+
|
|
64
|
+
it "includes a slash" do
|
|
65
|
+
expect(subject).to eq("GET /")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context "with a path" do
|
|
70
|
+
subject { TestRequest.new("get", "/something", {}, {} , "").method_and_path }
|
|
71
|
+
|
|
72
|
+
it "includes the path" do
|
|
73
|
+
expect(subject).to eq("GET /something")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context "with a query" do
|
|
78
|
+
subject { TestRequest.new("get", "/something", {}, {} , "test=query").method_and_path }
|
|
79
|
+
|
|
80
|
+
it "includes the query" do
|
|
81
|
+
expect(subject).to eq("GET /something?test=query")
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "#content_type" do
|
|
87
|
+
|
|
88
|
+
subject { TestRequest.new("get", "/something", headers, {} , "") }
|
|
89
|
+
context "when there are no expected headers" do
|
|
90
|
+
let(:headers) { Pact::KeyNotFound.new }
|
|
91
|
+
it "returns nil" do
|
|
92
|
+
expect(subject.send(:content_type)).to be nil
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
context "when there is no Content-Type header" do
|
|
96
|
+
let(:headers) { {} }
|
|
97
|
+
it "returns the content-type" do
|
|
98
|
+
expect(subject.send(:content_type)).to be nil
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
context "when there is a content-type header (" do
|
|
102
|
+
let(:headers) { {'content-type' => 'blah'} }
|
|
103
|
+
it "returns the content-type" do
|
|
104
|
+
expect(subject.send(:content_type)).to eq 'blah'
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'pact/shared/text_differ'
|
|
3
|
+
|
|
4
|
+
module Pact
|
|
5
|
+
describe TextDiffer do
|
|
6
|
+
|
|
7
|
+
describe ".call" do
|
|
8
|
+
|
|
9
|
+
subject { TextDiffer.call expected, actual }
|
|
10
|
+
|
|
11
|
+
let(:expected) { "This is the string you are looking for" }
|
|
12
|
+
|
|
13
|
+
context "when the expected and actual are both strings" do
|
|
14
|
+
|
|
15
|
+
context "when they equal each other" do
|
|
16
|
+
let(:actual) { "This is the string you are looking for" }
|
|
17
|
+
|
|
18
|
+
it "returns an empty diff" do
|
|
19
|
+
expect(subject.any?).to be false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "when they don't equal each other" do
|
|
24
|
+
let(:actual) { "This is not the string you are looking for" }
|
|
25
|
+
|
|
26
|
+
it "returns the diff" do
|
|
27
|
+
expect(subject).to eq Pact::Matchers::Difference.new(expected, actual)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "when the actual is not a String" do
|
|
33
|
+
let(:actual) { {some: 'hash'} }
|
|
34
|
+
let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
|
|
35
|
+
it "returns the diff" do
|
|
36
|
+
expect(subject)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "when the expected and actual are both objects" do
|
|
41
|
+
let(:actual) { {some: 'hash', blah: 'blah'} }
|
|
42
|
+
let(:expected) { {some: 'hash'} }
|
|
43
|
+
let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
|
|
44
|
+
|
|
45
|
+
it "returns the diff using the JSON matching logic, allowing extra keys. But should it really if the expected Content-Type isn't actually JSON?" do
|
|
46
|
+
expect(subject)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "potentially should treat both expected and actual as Strings"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Pact
|
|
4
|
+
describe SomethingLike do
|
|
5
|
+
describe 'json_create' do
|
|
6
|
+
let(:json) do
|
|
7
|
+
'
|
|
8
|
+
{
|
|
9
|
+
"json_class": "Pact::SomethingLike",
|
|
10
|
+
"contents" : { "thing" : "blah" }
|
|
11
|
+
}
|
|
12
|
+
'
|
|
13
|
+
end
|
|
14
|
+
subject { SomethingLike.json_create(JSON.parse(json)) }
|
|
15
|
+
it "creates a SomethingLike object from json" do
|
|
16
|
+
expect(subject).to eq(SomethingLike.new({"thing" => "blah"}))
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|