From 8317fe317d724fbce752d48af073ccd98acc77d2 Mon Sep 17 00:00:00 2001 From: Abhi Trivedi Date: Mon, 22 Oct 2018 22:27:18 -0700 Subject: [PATCH] fix: always execute global and base states Ensure that global and base states are executed regardless of whether interaction defines a provider state, as described in the docs. Fixes #180 --- lib/pact/provider/test_methods.rb | 4 ++++ lib/pact/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pact/provider/test_methods.rb b/lib/pact/provider/test_methods.rb index 1780256e..470b2157 100644 --- a/lib/pact/provider/test_methods.rb +++ b/lib/pact/provider/test_methods.rb @@ -36,12 +36,16 @@ def parse_body_from_response rack_response end def set_up_provider_states provider_states, consumer, options = {} + # If there are no provider state, execute with an nil state to ensure global and base states are executed + Pact.configuration.provider_state_set_up.call(nil, consumer, options) if provider_states.nil? || provider_states.empty? provider_states.each do | provider_state | Pact.configuration.provider_state_set_up.call(provider_state.name, consumer, options.merge(params: provider_state.params)) end end def tear_down_provider_states provider_states, consumer, options = {} + # If there are no provider state, execute with an nil state to ensure global and base states are executed + Pact.configuration.provider_state_tear_down.call(nil, consumer, options) if provider_states.nil? || provider_states.empty? provider_states.reverse.each do | provider_state | Pact.configuration.provider_state_tear_down.call(provider_state.name, consumer, options.merge(params: provider_state.params)) end diff --git a/lib/pact/version.rb b/lib/pact/version.rb index f451b517..7dc33ee3 100644 --- a/lib/pact/version.rb +++ b/lib/pact/version.rb @@ -1,4 +1,4 @@ # Remember to bump pact-provider-proxy when this changes major version module Pact - VERSION = "1.36.0" + VERSION = "1.36.1" end