Skip to content

Commit 6a46ebb

Browse files
committed
feat: rename 'wip pacts' to 'pending pacts'
1 parent 8e2dffd commit 6a46ebb

File tree

6 files changed

+32
-29
lines changed

6 files changed

+32
-29
lines changed

lib/pact/hal/entity.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ def follow(key, http_method, *args)
3636
Link.new(@links[key].merge(method: http_method), @client).run(*args)
3737
end
3838

39-
def _link(key)
39+
def _link(key, fallback_key = nil)
4040
if @links[key]
4141
Link.new(@links[key], @client)
42+
elsif fallback_key && @links[fallback_key]
43+
Link.new(@links[fallback_key], @client)
4244
else
4345
nil
4446
end

lib/pact/pact_broker.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'pact/pact_broker/fetch_pacts'
2-
require 'pact/pact_broker/fetch_wip_pacts'
2+
require 'pact/pact_broker/fetch_pending_pacts'
33

44
#
55
# @public Use by Pact Provider Verifier
@@ -12,8 +12,8 @@ def fetch_pact_uris *args
1212
Pact::PactBroker::FetchPacts.call(*args).collect(&:uri)
1313
end
1414

15-
def fetch_wip_pact_uris *args
16-
Pact::PactBroker::FetchWipPacts.call(*args).collect(&:uri)
15+
def fetch_pending_pact_uris *args
16+
Pact::PactBroker::FetchPendingPacts.call(*args).collect(&:uri)
1717
end
1818
end
1919
end

lib/pact/pact_broker/fetch_wip_pacts.rb lib/pact/pact_broker/fetch_pending_pacts.rb

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
module Pact
66
module PactBroker
7-
class FetchWipPacts
7+
class FetchPendingPacts
88
attr_reader :provider, :tags, :broker_base_url, :http_client_options, :http_client, :index_entity
99

10-
WIP_PROVIDER_RELATION = 'beta:wip-provider-pacts'.freeze
10+
PENDING_PROVIDER_RELATION = 'beta:pending-provider-pacts'.freeze
11+
WIP_PROVIDER_RELATION = 'beta:wip-provider-pacts'.freeze # deprecated
1112
PACTS = 'pacts'.freeze
1213
PB_PACTS = 'pb:pacts'.freeze
1314
HREF = 'href'.freeze
@@ -25,7 +26,7 @@ def self.call(provider, broker_base_url, http_client_options)
2526

2627
def call
2728
if index.success?
28-
wip_pacts_for_provider
29+
pending_pacts_for_provider
2930
else
3031
raise Pact::Error.new("Error retrieving #{broker_base_url} status=#{index_entity.response.code} #{index_entity.response.raw_body}")
3132
end
@@ -37,8 +38,8 @@ def index
3738
@index_entity ||= Pact::Hal::Link.new({ "href" => broker_base_url }, http_client).get
3839
end
3940

40-
def wip_pacts_for_provider
41-
link = index_entity._link(WIP_PROVIDER_RELATION)
41+
def pending_pacts_for_provider
42+
link = index_entity._link(WIP_PROVIDER_RELATION, PENDING_PROVIDER_RELATION)
4243
if link
4344
get_pact_urls(link.expand(provider: provider).get)
4445
else

spec/lib/pact/pact_broker/fetch_wip_pacts_spec.rb spec/lib/pact/pact_broker/fetch_pending_pacts_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
require 'pact/pact_broker/fetch_wip_pacts'
1+
require 'pact/pact_broker/fetch_pending_pacts'
22

33
module Pact
44
module PactBroker
5-
describe FetchWipPacts do
5+
describe FetchPendingPacts do
66
describe "call" do
77
before do
88
allow(Pact.configuration).to receive(:output_stream).and_return(double('output stream').as_null_object)
@@ -11,7 +11,7 @@ module PactBroker
1111
let(:provider) { "Foo"}
1212
let(:broker_base_url) { "http://broker.org" }
1313
let(:http_client_options) { {} }
14-
subject { FetchWipPacts.call(provider, broker_base_url, http_client_options)}
14+
subject { FetchPendingPacts.call(provider, broker_base_url, http_client_options)}
1515

1616
context "when there is an error retrieving the index resource" do
1717
before do
@@ -32,7 +32,7 @@ module PactBroker
3232
end
3333
end
3434

35-
context "when the pb:wip-provider-pacts relation does not exist" do
35+
context "when the pb:pending-provider-pacts relation does not exist" do
3636
before do
3737
stub_request(:get, "http://broker.org/").to_return(status: 200, body: response_body, headers: response_headers)
3838
end

spec/lib/pact/pact_broker_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ module PactBroker
2222
end
2323
end
2424

25-
describe ".fetch_wip_pact_uris" do
25+
describe ".fetch_pending_pact_uris" do
2626
before do
27-
allow(Pact::PactBroker::FetchWipPacts).to receive(:call).and_return([pact_uri])
27+
allow(Pact::PactBroker::FetchPendingPacts).to receive(:call).and_return([pact_uri])
2828
end
2929

3030
let(:pact_uri) { Pact::Provider::PactURI.new("http://pact") }
3131

32-
subject { Pact::PactBroker.fetch_wip_pact_uris("foo") }
32+
subject { Pact::PactBroker.fetch_pending_pact_uris("foo") }
3333

34-
it "calls Pact::PactBroker::FetchWipPacts" do
35-
expect(Pact::PactBroker::FetchWipPacts).to receive(:call).with("foo")
34+
it "calls Pact::PactBroker::FetchPendingPacts" do
35+
expect(Pact::PactBroker::FetchPendingPacts).to receive(:call).with("foo")
3636
subject
3737
end
3838

spec/service_providers/pact_ruby_fetch_wip_pacts_test.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative 'helper'
2-
require 'pact/pact_broker/fetch_wip_pacts'
2+
require 'pact/pact_broker/fetch_pending_pacts'
33

4-
describe Pact::PactBroker::FetchWipPacts, pact: true do
4+
describe Pact::PactBroker::FetchPendingPacts, pact: true do
55
before do
66
allow($stdout).to receive(:puts)
77
end
@@ -15,7 +15,7 @@
1515

1616
before do
1717
pact_broker
18-
.given('the relation for retrieving WIP pacts exists in the index resource')
18+
.given('the relation for retrieving pending pacts exists in the index resource')
1919
.upon_receiving('a request for the index resource')
2020
.with(
2121
method: :get,
@@ -26,25 +26,25 @@
2626
status: 200,
2727
body: {
2828
_links: {
29-
'beta:wip-provider-pacts' => {
29+
'beta:pending-provider-pacts' => {
3030
href: Pact.term(
31-
generate: broker_base_url + 'pacts/provider/{provider}/wip',
32-
matcher: %r{/pacts/provider/{provider}/wip$}
31+
generate: broker_base_url + 'pacts/provider/{provider}/pending',
32+
matcher: %r{/pacts/provider/{provider}/pending$}
3333
)
3434
}
3535
}
3636
}
3737
)
3838
end
3939

40-
context 'retrieving WIP pacts by provider' do
40+
context 'retrieving pending pacts by provider' do
4141
before do
4242
pact_broker
43-
.given('consumer-1 has a WIP pact with provider provider-1')
44-
.upon_receiving('a request to retrieve the WIP pacts for provider')
43+
.given('consumer-1 has a pending pact with provider provider-1')
44+
.upon_receiving('a request to retrieve the pending pacts for provider')
4545
.with(
4646
method: :get,
47-
path: '/pacts/provider/provider-1/wip',
47+
path: '/pacts/provider/provider-1/pending',
4848
headers: get_headers
4949
)
5050
.will_respond_with(
@@ -62,7 +62,7 @@
6262
end
6363

6464
it 'returns the array of pact urls' do
65-
pacts = Pact::PactBroker::FetchWipPacts.call(provider, broker_base_url, basic_auth_options)
65+
pacts = Pact::PactBroker::FetchPendingPacts.call(provider, broker_base_url, basic_auth_options)
6666
expect(pacts).to eq(
6767
[
6868
Pact::Provider::PactURI.new('http://pact-broker-url-for-consumer-1', basic_auth_options)

0 commit comments

Comments
 (0)