Class: PactExpectations
- Inherits:
-
Object
show all
- Defined in:
- lib/pact_expectations.rb,
lib/pact_expectations/version.rb
Defined Under Namespace
Classes: DuplicatedKey, NotFound, VerifyError
Constant Summary
collapse
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
.add_response_body_for(key, expectation = {}) ⇒ Object
7
8
9
10
|
# File 'lib/pact_expectations.rb', line 7
def add_response_body_for(key, expectation = {})
raise DuplicatedKey if expectations.include?(key)
expectations[key] = expectation
end
|
.reified_body_for(key) ⇒ Object
18
19
20
21
22
|
# File 'lib/pact_expectations.rb', line 18
def reified_body_for(key)
raise NotFound unless expectations.include?(key)
reificated_call << key
Pact::Reification.from_term(expectations[key])
end
|
.reset! ⇒ Object
33
34
35
36
37
|
# File 'lib/pact_expectations.rb', line 33
def reset!
@expectations = nil
@response_call = nil
@reificated_call = nil
end
|
.response_body_for(key) ⇒ Object
12
13
14
15
16
|
# File 'lib/pact_expectations.rb', line 12
def response_body_for(key)
raise NotFound unless expectations.include?(key)
response_call << key
expectations[key]
end
|
.verify ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/pact_expectations.rb', line 24
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 VerifyError.new(not_call_responses, not_call_reificated)
end
end
|