@@ -6,6 +6,7 @@ module VerificationResults
6
6
describe Publish do
7
7
describe "call" do
8
8
let ( :publish_verification_url ) { nil }
9
+ let ( :stubbed_publish_verification_url ) { 'http://broker/something/provider/Bar/verifications' }
9
10
let ( :tag_version_url ) { 'http://tag-me/{tag}' }
10
11
let ( :pact_source ) { instance_double ( "Pact::Provider::PactSource" , pact_hash : pact_hash , uri : pact_url ) }
11
12
let ( :pact_url ) { instance_double ( "Pact::Provider::PactURI" , basic_auth? : basic_auth , username : 'username' , password : 'password' ) }
@@ -18,8 +19,7 @@ module VerificationResults
18
19
'_links' => {
19
20
'pb:publish-verification-results' => {
20
21
'href' => publish_verification_url
21
- } ,
22
- 'pb:tag-version' => { 'href' => tag_version_url }
22
+ }
23
23
}
24
24
}
25
25
end
@@ -46,30 +46,30 @@ module VerificationResults
46
46
end
47
47
48
48
let ( :provider_configuration ) do
49
- double ( 'provider config' , publish_verification_results? : publish_verification_results , tags : tags )
49
+ double ( 'provider config' , publish_verification_results? : publish_verification_results , tags : tags , application_version : '1.2.3' )
50
50
end
51
51
52
52
before do
53
53
allow ( $stdout) . to receive ( :puts )
54
54
allow ( Pact . configuration ) . to receive ( :provider ) . and_return ( provider_configuration )
55
- stub_request ( :post , 'http://broker/verifications' ) . to_return ( status : 200 , body : created_verification_body )
56
- stub_request ( :put , /tag-me/ )
55
+ stub_request ( :post , stubbed_publish_verification_url ) . to_return ( status : 200 , body : created_verification_body )
56
+ stub_request ( :put , 'http://broker/pacticipants/Bar/versions/1.2.3/tags/foo' )
57
57
end
58
58
59
59
subject { Publish . call ( pact_source , verification ) }
60
60
61
61
context "when publish_verification_results is false" do
62
62
it "does not publish the verification" do
63
63
subject
64
- expect ( WebMock ) . to_not have_requested ( :post , 'http://broker/verifications' )
64
+ expect ( WebMock ) . to_not have_requested ( :post , 'http://broker/something/provider/Bar/ verifications' )
65
65
end
66
66
end
67
67
68
68
context "when publish_verification_results is true" do
69
69
let ( :publish_verification_results ) { true }
70
70
71
71
context "when the publish-verification link is present" do
72
- let ( :publish_verification_url ) { 'http://broker/verifications' }
72
+ let ( :publish_verification_url ) { stubbed_publish_verification_url }
73
73
74
74
it "publishes the verification" do
75
75
subject
@@ -81,7 +81,7 @@ module VerificationResults
81
81
82
82
it "does not publish the verification" do
83
83
subject
84
- expect ( WebMock ) . to_not have_requested ( :post , 'http://broker/verifications' )
84
+ expect ( WebMock ) . to_not have_requested ( :post , stubbed_publish_verification_url )
85
85
end
86
86
end
87
87
@@ -90,17 +90,17 @@ module VerificationResults
90
90
91
91
it "tags the provider version" do
92
92
subject
93
- expect ( WebMock ) . to have_requested ( :put , 'http://tag-me /foo' ) . with ( headers : { 'Content-Type' => 'application/json' } )
93
+ expect ( WebMock ) . to have_requested ( :put , 'http://broker/pacticipants/Bar/versions/1.2.3/tags /foo' ) . with ( headers : { 'Content-Type' => 'application/json' } )
94
94
end
95
95
96
- context "when there is no pb:tag-version link" do
96
+ context "when there is no pb:publish-verification-results link" do
97
97
before do
98
- pact_hash [ '_links' ] . delete ( 'pb:tag-version ' )
98
+ pact_hash [ '_links' ] . delete ( 'pb:publish-verification-results ' )
99
99
end
100
100
101
- it "prints a warning" do
102
- expect ( $stderr) . to receive ( :puts ) . with /WARN: Cannot tag provider version/
101
+ it "does not tag the version" do
103
102
subject
103
+ expect ( WebMock ) . to_not have_requested ( :put , /.*/ )
104
104
end
105
105
end
106
106
end
@@ -127,7 +127,7 @@ module VerificationResults
127
127
128
128
context "when an HTTP error is returned" do
129
129
it "raises a PublicationError" do
130
- stub_request ( :post , 'http://broker/verifications' ) . to_return ( status : 500 , body : 'some error' )
130
+ stub_request ( :post , stubbed_publish_verification_url ) . to_return ( status : 500 , body : 'some error' )
131
131
expect { subject } . to raise_error ( PublicationError , /Error returned/ )
132
132
end
133
133
end
@@ -143,7 +143,7 @@ module VerificationResults
143
143
before do
144
144
stub_request ( :post , publish_verification_url ) . to_return ( status : 200 , body : created_verification_body )
145
145
end
146
- let ( :publish_verification_url ) { ' https://broker/verifications' }
146
+ let ( :publish_verification_url ) { stubbed_publish_verification_url . gsub ( 'http' , ' https' ) }
147
147
148
148
it "uses ssl" do
149
149
subject
0 commit comments