Skip to content

Commit

Permalink
test: update rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Nov 13, 2017
1 parent 4416d04 commit bf5e753
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion spec/support/bar_fail_pact_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Pact
module Test
class BarApp
def call env
[200, {'Content-Type' => 'application/json'}, [].to_json]
[200, {'Content-Type' => 'application/json'}, [{}].to_json]
end
end

Expand Down
11 changes: 7 additions & 4 deletions tasks/foo-bar.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ require 'pact/tasks/verification_task'
# Use for end to end manual debugging of issues.

BROKER_BASE_URL = 'http://localhost:9292'
#BROKER_BASE_URL = 'https://test.pact.dius.com.au'
BROKER_USERNAME = ENV['PACT_BROKER_USERNAME']
BROKER_PASSWORD = ENV['PACT_BROKER_PASSWORD']

RSpec::Core::RakeTask.new('pact:foobar:create') do | task |
task.pattern = "spec/features/foo_bar_spec.rb"
Expand All @@ -14,11 +17,11 @@ task 'pact:foobar:publish' do
put_request = Net::HTTP::Put.new(uri.path)
put_request['Content-Type'] = "application/json"
put_request.body = File.read("spec/pacts/foo-bar.json")
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
put_request.basic_auth(BROKER_USERNAME, BROKER_PASSWORD) if BROKER_USERNAME
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: BROKER_BASE_URL.start_with?('https')) do |http|
http.request put_request
end
puts response.code unless response.code == '200'
puts response.body
end

Pact::VerificationTask.new('foobar') do | pact |
Expand All @@ -27,11 +30,11 @@ end


Pact::VerificationTask.new(:foobar_using_broker) do | pact |
pact.uri "#{BROKER_BASE_URL}/pacts/provider/Bar/consumer/Foo/version/1.0.0", :pact_helper => './spec/support/bar_pact_helper.rb'
pact.uri "#{BROKER_BASE_URL}/pacts/provider/Bar/consumer/Foo/version/1.0.0", :pact_helper => './spec/support/bar_pact_helper.rb', username: BROKER_USERNAME, password: BROKER_PASSWORD
end

Pact::VerificationTask.new('foobar_using_broker:fail') do | pact |
pact.uri "#{BROKER_BASE_URL}/pacts/provider/Bar/consumer/Foo/version/1.0.0", :pact_helper => './spec/support/bar_fail_pact_helper.rb'
pact.uri "#{BROKER_BASE_URL}/pacts/provider/Bar/consumer/Foo/version/1.0.0", :pact_helper => './spec/support/bar_fail_pact_helper.rb', username: BROKER_USERNAME, password: BROKER_PASSWORD
end

task 'pact:verify:foobar' => ['pact:foobar:create']
Expand Down

0 comments on commit bf5e753

Please sign in to comment.