Skip to content

Commit

Permalink
feat(run single interaction): allow env vars to be set to run a singl…
Browse files Browse the repository at this point in the history
…e interaction

Set PACT_DESCRIPTION and PACT_PROVIDER_STATE to run a specific interaction instead of the full pact
  • Loading branch information
bethesque committed Aug 11, 2017
1 parent 66c67fd commit 3e39517
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/pact/provider_verifier/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def verify_pact pact_url
:pact_broker_username => @options.broker_username,
:pact_broker_password => @options.broker_password
}
options[:description] = ENV['PACT_DESCRIPTION'] if ENV['PACT_DESCRIPTION']
options[:provider_state] = ENV['PACT_PROVIDER_STATE'] if ENV['PACT_PROVIDER_STATE']

Cli::RunPactVerification.call(options)
rescue SystemExit => e
puts ""
Expand Down
16 changes: 15 additions & 1 deletion spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
end
end

context "with two passing pacts" do
context "with two passing interactions" do

subject { `bundle exec bin/pact-provider-verifier -a 1.0.100 --provider-base-url http://localhost:4567 --pact-urls ./test/me-they.json,./test/another-they.json --provider_states_setup_url http://localhost:4567/provider-state -v` }
it "exits with a 0 exit code" do
Expand Down Expand Up @@ -58,6 +58,20 @@
end
end

context "running verification with filtered interactions" do

subject { `PACT_DESCRIPTION="Provider state success" PACT_PROVIDER_STATE="There is a greeting" bundle exec bin/pact-provider-verifier -a 1.0.100 --provider-base-url http://localhost:4567 --pact-urls ./test/me-they.json --provider_states_setup_url http://localhost:4567/provider-state -v` }

it "exits with a 0 exit code" do
subject
expect($?).to eq 0
end

it "the output contains a message indicating that the interactions have been filtered" do
expect(subject).to match /Filtering interactions by.*Provider state success.*There is a greeting/
end
end


after(:all) do
Process.kill 'KILL', @pipe.pid
Expand Down

0 comments on commit 3e39517

Please sign in to comment.