summaryrefslogtreecommitdiff
path: root/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb')
-rw-r--r--spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb b/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb
index 8bb3b577135..39537aa153d 100644
--- a/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb
+++ b/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb
@@ -11,21 +11,26 @@ RSpec.describe Provider::ContractSourceHelper, feature_category: :not_owned do
describe '#contract_location' do
it 'raises an error when an invalid requester is given' do
- expect { subject.contract_location(:foo, pact_helper_path) }
+ expect { subject.contract_location(requester: :foo, file_path: pact_helper_path) }
.to raise_error(ArgumentError, 'requester must be :rake or :spec')
end
+ it 'raises an error when an invalid edition is given' do
+ expect { subject.contract_location(requester: :spec, file_path: pact_helper_path, edition: :zz) }
+ .to raise_error(ArgumentError, 'edition must be :ce or :ee')
+ end
+
context 'when the PACT_BROKER environment variable is not set' do
it 'extracts the relevant path from the pact_helper path' do
- expect(subject).to receive(:local_contract_location).with(:rake, split_pact_helper_path)
+ expect(subject).to receive(:local_contract_location).with(:rake, split_pact_helper_path, :ce)
- subject.contract_location(:rake, pact_helper_path)
+ subject.contract_location(requester: :rake, file_path: pact_helper_path)
end
it 'does not construct the pact broker url' do
expect(subject).not_to receive(:pact_broker_url)
- subject.contract_location(:rake, pact_helper_path)
+ subject.contract_location(requester: :rake, file_path: pact_helper_path)
end
end
@@ -37,13 +42,13 @@ RSpec.describe Provider::ContractSourceHelper, feature_category: :not_owned do
it 'extracts the relevant path from the pact_helper path' do
expect(subject).to receive(:pact_broker_url).with(split_pact_helper_path)
- subject.contract_location(:spec, pact_helper_path)
+ subject.contract_location(requester: :spec, file_path: pact_helper_path)
end
it 'does not construct the pact broker url' do
expect(subject).not_to receive(:local_contract_location)
- subject.contract_location(:spec, pact_helper_path)
+ subject.contract_location(requester: :spec, file_path: pact_helper_path)
end
end
end
@@ -51,7 +56,7 @@ RSpec.describe Provider::ContractSourceHelper, feature_category: :not_owned do
describe '#pact_broker_url' do
it 'returns the full url to the contract that the provider test is verifying' do
contract_url_path = "http://localhost:9292/pacts/provider/" \
- "#{provider_url_path}/consumer/#{consumer_url_path}/latest"
+ "#{provider_url_path}/consumer/#{consumer_url_path}/latest"
expect(subject.pact_broker_url(split_pact_helper_path)).to eq(contract_url_path)
end
@@ -73,7 +78,7 @@ RSpec.describe Provider::ContractSourceHelper, feature_category: :not_owned do
it 'returns the contract file path with the prefix path for a rake task' do
rake_task_relative_path = '/spec/contracts/contracts/project'
- rake_task_path = subject.local_contract_location(:rake, split_pact_helper_path)
+ rake_task_path = subject.local_contract_location(:rake, split_pact_helper_path, :ce)
expect(rake_task_path).to include(rake_task_relative_path)
expect(rake_task_path).not_to include('../')
@@ -82,7 +87,7 @@ RSpec.describe Provider::ContractSourceHelper, feature_category: :not_owned do
it 'returns the contract file path with the prefix path for a spec' do
spec_relative_path = '../contracts/project'
- expect(subject.local_contract_location(:spec, split_pact_helper_path)).to include(spec_relative_path)
+ expect(subject.local_contract_location(:spec, split_pact_helper_path, :ce)).to include(spec_relative_path)
end
end