Skip to content

Commit bf5e753

Browse files
committed
test: update rake task
1 parent 4416d04 commit bf5e753

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

spec/support/bar_fail_pact_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Pact
55
module Test
66
class BarApp
77
def call env
8-
[200, {'Content-Type' => 'application/json'}, [].to_json]
8+
[200, {'Content-Type' => 'application/json'}, [{}].to_json]
99
end
1010
end
1111

tasks/foo-bar.rake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ require 'pact/tasks/verification_task'
22
# Use for end to end manual debugging of issues.
33

44
BROKER_BASE_URL = 'http://localhost:9292'
5+
#BROKER_BASE_URL = 'https://test.pact.dius.com.au'
6+
BROKER_USERNAME = ENV['PACT_BROKER_USERNAME']
7+
BROKER_PASSWORD = ENV['PACT_BROKER_PASSWORD']
58

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

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

2831

2932
Pact::VerificationTask.new(:foobar_using_broker) do | pact |
30-
pact.uri "#{BROKER_BASE_URL}/pacts/provider/Bar/consumer/Foo/version/1.0.0", :pact_helper => './spec/support/bar_pact_helper.rb'
33+
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
3134
end
3235

3336
Pact::VerificationTask.new('foobar_using_broker:fail') do | pact |
34-
pact.uri "#{BROKER_BASE_URL}/pacts/provider/Bar/consumer/Foo/version/1.0.0", :pact_helper => './spec/support/bar_fail_pact_helper.rb'
37+
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
3538
end
3639

3740
task 'pact:verify:foobar' => ['pact:foobar:create']

0 commit comments

Comments
 (0)