From dd353661c80fc568eac1aeb847e9bcd73a41ec32 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Sat, 12 Sep 2020 11:48:16 +1000 Subject: [PATCH] feat: allow include_wip_pacts_since to use a Date, DateTime or Time --- .../pact_verification_from_broker.rb | 6 ++++- .../pact_verification_from_broker_spec.rb | 25 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/pact/provider/configuration/pact_verification_from_broker.rb b/lib/pact/provider/configuration/pact_verification_from_broker.rb index 6275ec89..d60317b2 100644 --- a/lib/pact/provider/configuration/pact_verification_from_broker.rb +++ b/lib/pact/provider/configuration/pact_verification_from_broker.rb @@ -40,7 +40,11 @@ def enable_pending enable_pending end def include_wip_pacts_since since - self._include_wip_pacts_since = since + self._include_wip_pacts_since = if since.respond_to?(:xmlschema) + since.xmlschema + else + since + end end def verbose verbose diff --git a/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb b/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb index 1500332b..70eb5b65 100644 --- a/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb +++ b/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb @@ -8,6 +8,7 @@ module Configuration let(:provider_name) {'provider-name'} let(:provider_version_tags) { ['master'] } let(:base_url) { "http://broker.org" } + let(:since) { "2020-01-01" } let(:basic_auth_options) do { username: 'pact_broker_username', @@ -27,7 +28,7 @@ module Configuration pact_broker_base_url base_url, basic_auth_options consumer_version_tags tags enable_pending true - include_wip_pacts_since "2020-01-01" + include_wip_pacts_since since verbose true end end @@ -44,7 +45,8 @@ module Configuration provider_version_tags, base_url, basic_auth_opts, - options) + options + ) subject end @@ -52,6 +54,25 @@ module Configuration expect(Pact.provider_world).to receive(:add_pact_uri_source).with(fetch_pacts) subject end + + context "when since is a Date" do + let(:since) { Date.new(2020, 1, 1) } + + it "converts it to a string" do + expect(Pact::PactBroker::FetchPactURIsForVerification).to receive(:new).with( + anything, + anything, + anything, + anything, + anything, + { + include_pending_status: true, + include_wip_pacts_since: since.xmlschema + } + ) + subject + end + end end context "with a missing base url" do