class PactExpectations

Constants

VERSION
VerifyError

Public Class Methods

add_response_body_for(key, expectation = {}) click to toggle source
# File lib/pact_expectations.rb, line 51
def add_response_body_for(key, expectation = {})
  raise DuplicatedKey if expectations.include?(key)
  expectations[key] = expectation
end
reified_body_for(key) click to toggle source
# File lib/pact_expectations.rb, line 62
def reified_body_for(key)
  raise NotFound unless expectations.include?(key)
  reificated_call << key
  Pact::Reification.from_term(expectations[key])
end
reset!() click to toggle source
# File lib/pact_expectations.rb, line 77
def reset!
  @expectations = nil
  @response_call = nil
  @reificated_call = nil
end
response_body_for(key) click to toggle source
# File lib/pact_expectations.rb, line 56
def response_body_for(key)
  raise NotFound unless expectations.include?(key)
  response_call << key
  expectations[key]
end
verify() click to toggle source
# File lib/pact_expectations.rb, line 68
def verify
  not_call_responses = response_call ^ expectations.keys
  not_call_reificated = reificated_call ^ expectations.keys

  if !not_call_responses.empty? || !not_call_reificated.empty?
    raise ExpectationNotCalled.new(not_call_responses, not_call_reificated)
  end
end

Private Class Methods

expectations() click to toggle source
# File lib/pact_expectations.rb, line 85
def expectations
  @expectations ||= {}
end
reificated_call() click to toggle source
# File lib/pact_expectations.rb, line 93
def reificated_call
  @reificated_call ||= Set.new
end
response_call() click to toggle source
# File lib/pact_expectations.rb, line 89
def response_call
  @response_call ||= Set.new
end