Skip to content

Commit

Permalink
fix: always execute global and base states
Browse files Browse the repository at this point in the history
Ensure that global and base states are executed regardless of
whether interaction defines a provider state, as described in
the docs.

Fixes pact-foundation#180
  • Loading branch information
abhitrivedi committed Oct 23, 2018
1 parent 08bb2ab commit 8317fe3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/pact/provider/test_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/pact/version.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8317fe3

Please sign in to comment.