pact_expectations 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/.travis.yml +0 -1
- data/lib/pact_expectations.rb +47 -38
- data/lib/pact_expectations/version.rb +1 -1
- data/pact_expectations.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 071bad902fdf801ae94635a1b9e8fe64a09717e1
|
4
|
+
data.tar.gz: 669ec332f29bf14cca1fac0303e3870384740849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de3c70692164d7181c452ea1cf94b77bb992cc38df7c199453d15fa04c3bd81a5333250f2131efb083737095a79957584e806f66dd28ebdc1ea998c008d752f
|
7
|
+
data.tar.gz: 1d88431ffe1caabd2b9b66e6e0613e92b5be497dddd2b25c878d50753e8db52f4441c1dadf0f70268e20c87b2cfe70f2d978a01c749936d81ef1dd05aed46c02
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/lib/pact_expectations.rb
CHANGED
@@ -1,8 +1,52 @@
|
|
1
|
-
require "pact_expectations/version"
|
2
|
-
require "pact/support/version"
|
3
1
|
require "set"
|
2
|
+
require "pact/support"
|
3
|
+
|
4
|
+
require "pact_expectations/version"
|
4
5
|
|
5
6
|
class PactExpectations
|
7
|
+
class Error < ::StandardError
|
8
|
+
end
|
9
|
+
class NotFound < Error
|
10
|
+
end
|
11
|
+
|
12
|
+
class DuplicatedKey < Error
|
13
|
+
end
|
14
|
+
|
15
|
+
class ExpectationNotCalled < Error
|
16
|
+
def initialize(not_call_responses = [], not_call_reificated = [])
|
17
|
+
@not_call_responses = not_call_responses
|
18
|
+
@not_call_reificated = not_call_reificated
|
19
|
+
end
|
20
|
+
|
21
|
+
def message
|
22
|
+
message = String.new("\n")
|
23
|
+
unless @not_call_responses.empty?
|
24
|
+
message << create_not_call_message(
|
25
|
+
"Some expectations were defined but not used to construct the Contract",
|
26
|
+
@not_call_responses
|
27
|
+
)
|
28
|
+
end
|
29
|
+
unless @not_call_reificated.empty?
|
30
|
+
message << create_not_call_message(
|
31
|
+
"Some expectations were defined but not used to stub Remote Facade",
|
32
|
+
@not_call_reificated
|
33
|
+
)
|
34
|
+
end
|
35
|
+
message
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def create_not_call_message(title, list)
|
41
|
+
message = String.new("#{title}:\n")
|
42
|
+
list.each do |key|
|
43
|
+
message << "- #{key}\n"
|
44
|
+
end
|
45
|
+
message << "\n"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
VerifyError = ExpectationNotCalled # For backward-compatibility
|
49
|
+
|
6
50
|
class << self
|
7
51
|
def add_response_body_for(key, expectation = {})
|
8
52
|
raise DuplicatedKey if expectations.include?(key)
|
@@ -26,7 +70,7 @@ class PactExpectations
|
|
26
70
|
not_call_reificated = reificated_call ^ expectations.keys
|
27
71
|
|
28
72
|
if !not_call_responses.empty? || !not_call_reificated.empty?
|
29
|
-
raise
|
73
|
+
raise ExpectationNotCalled.new(not_call_responses, not_call_reificated)
|
30
74
|
end
|
31
75
|
end
|
32
76
|
|
@@ -51,38 +95,3 @@ class PactExpectations
|
|
51
95
|
end
|
52
96
|
end
|
53
97
|
end
|
54
|
-
class PactExpectations::NotFound < StandardError; end
|
55
|
-
class PactExpectations::DuplicatedKey < StandardError; end
|
56
|
-
class PactExpectations::VerifyError < StandardError
|
57
|
-
def initialize(not_call_responses = [], not_call_reificated = [])
|
58
|
-
@not_call_responses = not_call_responses
|
59
|
-
@not_call_reificated = not_call_reificated
|
60
|
-
end
|
61
|
-
|
62
|
-
def message
|
63
|
-
message = String.new("\n")
|
64
|
-
unless @not_call_responses.empty?
|
65
|
-
message << create_not_call_message(
|
66
|
-
"Some expectations were defined but not used to construct the Contract",
|
67
|
-
@not_call_responses
|
68
|
-
)
|
69
|
-
end
|
70
|
-
unless @not_call_reificated.empty?
|
71
|
-
message << create_not_call_message(
|
72
|
-
"Some expectations were defined but not used to stub Remote Facade",
|
73
|
-
@not_call_reificated
|
74
|
-
)
|
75
|
-
end
|
76
|
-
message
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def create_not_call_message(title, list)
|
82
|
-
message = String.new("#{title}:\n")
|
83
|
-
list.each do |key|
|
84
|
-
message << "- #{key}\n"
|
85
|
-
end
|
86
|
-
message << "\n"
|
87
|
-
end
|
88
|
-
end
|
data/pact_expectations.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Yoshiori SHOJI"]
|
10
10
|
spec.email = ["yoshiori@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
12
|
+
spec.summary = %q{Manage and convert Pact expectations to stubs for Remote Facade.}
|
13
13
|
spec.description = spec.summary
|
14
14
|
spec.homepage = "https://github.com/yoshiori/pact_expectations"
|
15
15
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_expectations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiori SHOJI
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
-
description:
|
83
|
+
description: Manage and convert Pact expectations to stubs for Remote Facade.
|
84
84
|
email:
|
85
85
|
- yoshiori@gmail.com
|
86
86
|
executables: []
|
@@ -120,5 +120,5 @@ rubyforge_project:
|
|
120
120
|
rubygems_version: 2.5.1
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
|
-
summary:
|
123
|
+
summary: Manage and convert Pact expectations to stubs for Remote Facade.
|
124
124
|
test_files: []
|