pact 1.21.0 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/pact/provider/rspec.rb +46 -23
- data/lib/pact/provider/rspec/matchers.rb +14 -31
- data/lib/pact/provider/rspec/pact_broker_formatter.rb +19 -0
- data/lib/pact/provider/test_methods.rb +10 -0
- data/lib/pact/provider/verification_results/create.rb +2 -1
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98e5eb1496b65c594ed13101b2fc458979b0dcc3
|
4
|
+
data.tar.gz: '091e47ad1474581a0d6d5fa47c6feded20b10d9a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b222248d8f3d7fc8b5dc5631945b1e44ae1ecb8175d5caea1efda1d57a2073d7e87cc874a52128ce750246170bf141fcb40dcfffb95d00e0f49fc65c1fb9e89
|
7
|
+
data.tar.gz: e65bd27bd345906792632cfa52a19d4c300e9bdfc3249229849d8ce04a36ff921d69feea8ba86272bbeac1f24bcce861ef213780b5c081d1f83c9e6627ba0e88
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
<a name="v1.22.0"></a>
|
2
|
+
### v1.22.0 (2018-03-16)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* do not create reports/pacts/help.md when executing verify from a wrapper language ([f1a2cd4](/../../commit/f1a2cd4))
|
8
|
+
* add support for verifying message pacts ([fa98102](/../../commit/fa98102))
|
9
|
+
|
10
|
+
|
1
11
|
<a name="v1.21.0"></a>
|
2
12
|
### v1.21.0 (2018-03-19)
|
3
13
|
|
data/lib/pact/provider/rspec.rb
CHANGED
@@ -77,31 +77,52 @@ module Pact
|
|
77
77
|
|
78
78
|
describe description_for(interaction), metadata do
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
replay_interaction interaction
|
89
|
-
interaction_context.last_response = last_response
|
90
|
-
end
|
80
|
+
interaction_context = InteractionContext.new
|
81
|
+
|
82
|
+
before do | example |
|
83
|
+
interaction_context.run_once :before do
|
84
|
+
Pact.configuration.logger.info "Running example '#{Pact::RSpec.full_description(example)}'"
|
85
|
+
set_up_provider_state interaction.provider_state, options[:consumer]
|
86
|
+
replay_interaction interaction
|
87
|
+
interaction_context.last_response = last_response
|
91
88
|
end
|
89
|
+
end
|
92
90
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
91
|
+
after do
|
92
|
+
interaction_context.run_once :after do
|
93
|
+
tear_down_provider_state interaction.provider_state, options[:consumer]
|
97
94
|
end
|
98
|
-
|
99
|
-
describe_response Pact::Response.new(interaction.response), interaction_context
|
100
|
-
|
101
95
|
end
|
102
96
|
|
97
|
+
if interaction.respond_to?(:message?) && interaction.message?
|
98
|
+
describe_message Pact::Response.new(interaction.response), interaction_context
|
99
|
+
else
|
100
|
+
describe "with #{interaction.request.method_and_path}" do
|
101
|
+
describe_response Pact::Response.new(interaction.response), interaction_context
|
102
|
+
end
|
103
|
+
end
|
103
104
|
end
|
105
|
+
end
|
104
106
|
|
107
|
+
def describe_message expected_response, interaction_context
|
108
|
+
include Pact::RSpec::Matchers
|
109
|
+
extend Pact::Matchers::Messages
|
110
|
+
|
111
|
+
let(:expected_content) { expected_response.body[:content] }
|
112
|
+
let(:response) { interaction_context.last_response }
|
113
|
+
let(:differ) { Pact.configuration.body_differ_for_content_type diff_content_type }
|
114
|
+
let(:diff_formatter) { Pact.configuration.diff_formatter_for_content_type diff_content_type }
|
115
|
+
let(:diff_options) { { with: differ, diff_formatter: diff_formatter } }
|
116
|
+
let(:diff_content_type) { 'application/json' }
|
117
|
+
let(:response_body) { parse_body_from_response(response) }
|
118
|
+
let(:actual_content) { response_body['content'] }
|
119
|
+
|
120
|
+
it "has matching content" do
|
121
|
+
if response.status != 200
|
122
|
+
raise "An error was raised while verifying the message. The response body is: #{response.body}"
|
123
|
+
end
|
124
|
+
expect(actual_content).to match_term expected_content, diff_options
|
125
|
+
end
|
105
126
|
end
|
106
127
|
|
107
128
|
def describe_response expected_response, interaction_context
|
@@ -124,7 +145,8 @@ module Pact
|
|
124
145
|
let(:diff_options) { { with: differ, diff_formatter: diff_formatter } }
|
125
146
|
|
126
147
|
if expected_response.status
|
127
|
-
it "has status code #{expected_response.status}" do
|
148
|
+
it "has status code #{expected_response.status}" do | example |
|
149
|
+
set_metadata(example, :pact_actual_status, response_status)
|
128
150
|
expect(response_status).to eql expected_response_status
|
129
151
|
end
|
130
152
|
end
|
@@ -132,7 +154,8 @@ module Pact
|
|
132
154
|
if expected_response.headers
|
133
155
|
describe "includes headers" do
|
134
156
|
expected_response.headers.each do |name, expected_header_value|
|
135
|
-
it "\"#{name}\" which #{expected_desc_for_it(expected_header_value)}" do
|
157
|
+
it "\"#{name}\" which #{expected_desc_for_it(expected_header_value)}" do | example |
|
158
|
+
set_metadata(example, :pact_actual_headers, response.headers)
|
136
159
|
header_value = response.headers[name]
|
137
160
|
expect(header_value).to match_header(name, expected_header_value)
|
138
161
|
end
|
@@ -141,8 +164,9 @@ module Pact
|
|
141
164
|
end
|
142
165
|
|
143
166
|
if expected_response.body
|
144
|
-
it "has a matching body" do
|
145
|
-
|
167
|
+
it "has a matching body" do | example |
|
168
|
+
set_metadata(example, :pact_actual_body, response_body)
|
169
|
+
expect(response_body).to match_term expected_response_body, diff_options, example
|
146
170
|
end
|
147
171
|
end
|
148
172
|
end
|
@@ -155,7 +179,6 @@ module Pact
|
|
155
179
|
def interaction_description_for_rerun_command interaction
|
156
180
|
description_for(interaction).capitalize + ( interaction.provider_state ? " given #{interaction.provider_state}" : "")
|
157
181
|
end
|
158
|
-
|
159
182
|
end
|
160
183
|
|
161
184
|
# The "arrange" and "act" parts of the test really only need to be run once,
|
@@ -4,11 +4,9 @@ require 'pact/provider/matchers/messages'
|
|
4
4
|
require 'pact/rspec'
|
5
5
|
require 'pact/shared/json_differ'
|
6
6
|
|
7
|
-
|
8
7
|
module Pact
|
9
8
|
module RSpec
|
10
9
|
module Matchers
|
11
|
-
|
12
10
|
module RSpec2Delegator
|
13
11
|
# For backwards compatiblity with rspec-2
|
14
12
|
def method_missing(method, *args, &block)
|
@@ -21,33 +19,40 @@ module Pact
|
|
21
19
|
end
|
22
20
|
|
23
21
|
class MatchTerm
|
24
|
-
|
25
22
|
include Pact::Matchers::Messages
|
26
23
|
include RSpec2Delegator
|
27
24
|
|
28
|
-
def initialize expected, differ, diff_formatter
|
25
|
+
def initialize expected, differ, diff_formatter, example
|
29
26
|
@expected = expected
|
30
27
|
@differ = differ
|
31
28
|
@diff_formatter = diff_formatter
|
29
|
+
@example = example
|
32
30
|
end
|
33
31
|
|
34
32
|
def matches? actual
|
35
33
|
@actual = actual
|
36
|
-
|
34
|
+
@difference = @differ.call(@expected, @actual)
|
35
|
+
unless @difference.empty?
|
36
|
+
Pact::RSpec.with_rspec_3 do
|
37
|
+
@example.metadata[:pact_diff] = @difference
|
38
|
+
end
|
39
|
+
Pact::RSpec.with_rspec_2 do
|
40
|
+
@example.example.metadata[:pact_diff] = @difference
|
41
|
+
end
|
42
|
+
end
|
43
|
+
@difference.empty?
|
37
44
|
end
|
38
45
|
|
39
46
|
def failure_message
|
40
47
|
match_term_failure_message @difference, @actual, @diff_formatter, Pact::RSpec.color_enabled?
|
41
48
|
end
|
42
|
-
|
43
49
|
end
|
44
50
|
|
45
|
-
def match_term expected, options
|
46
|
-
MatchTerm.new(expected, options.fetch(:with), options.fetch(:diff_formatter))
|
51
|
+
def match_term expected, options, example
|
52
|
+
MatchTerm.new(expected, options.fetch(:with), options.fetch(:diff_formatter), example)
|
47
53
|
end
|
48
54
|
|
49
55
|
class MatchHeader
|
50
|
-
|
51
56
|
include Pact::Matchers
|
52
57
|
include Pact::Matchers::Messages
|
53
58
|
include RSpec2Delegator
|
@@ -65,33 +70,11 @@ module Pact
|
|
65
70
|
def failure_message
|
66
71
|
match_header_failure_message @header_name, @expected, @actual
|
67
72
|
end
|
68
|
-
|
69
73
|
end
|
70
74
|
|
71
75
|
def match_header header_name, expected
|
72
76
|
MatchHeader.new(header_name, expected)
|
73
77
|
end
|
74
|
-
|
75
78
|
end
|
76
79
|
end
|
77
80
|
end
|
78
|
-
|
79
|
-
|
80
|
-
# RSpec::Matchers.define :match_header do |header_name, expected|
|
81
|
-
|
82
|
-
# include Pact::Matchers
|
83
|
-
# include Pact::Matchers::Messages
|
84
|
-
|
85
|
-
# match do |actual|
|
86
|
-
# diff(expected, actual).empty?
|
87
|
-
# end
|
88
|
-
|
89
|
-
# def failure_message_for_should(actual)
|
90
|
-
# match_header_failure_message header_name, expected, actual
|
91
|
-
# end
|
92
|
-
|
93
|
-
# # failure_message_for_should do | actual |
|
94
|
-
# # match_header_failure_message header_name, expected, actual
|
95
|
-
# # end
|
96
|
-
|
97
|
-
# end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rspec/core/formatters'
|
2
2
|
require 'pact/provider/verification_results/publish_all'
|
3
3
|
require 'term/ansicolor'
|
4
|
+
require 'pact/matchers/extract_diff_messages'
|
4
5
|
|
5
6
|
module Pact
|
6
7
|
module Provider
|
@@ -59,6 +60,24 @@ module Pact
|
|
59
60
|
message: ::Term::ANSIColor.uncolor(example.exception.message)
|
60
61
|
}
|
61
62
|
end
|
63
|
+
|
64
|
+
if example.metadata[:pact_actual_status]
|
65
|
+
hash[:actualStatus] = example.metadata[:pact_actual_status]
|
66
|
+
end
|
67
|
+
|
68
|
+
if example.metadata[:pact_actual_headers]
|
69
|
+
hash[:actualHeaders] = example.metadata[:pact_actual_headers]
|
70
|
+
end
|
71
|
+
|
72
|
+
if example.metadata[:pact_actual_body]
|
73
|
+
hash[:actualBody] = example.metadata[:pact_actual_body]
|
74
|
+
end
|
75
|
+
|
76
|
+
if example.metadata[:pact_diff]
|
77
|
+
hash[:differences] = Pact::Matchers::ExtractDiffMessages.call(example.metadata[:pact_diff])
|
78
|
+
.to_a
|
79
|
+
.collect{ | description | {description: description} }
|
80
|
+
end
|
62
81
|
end
|
63
82
|
end
|
64
83
|
end
|
@@ -41,6 +41,16 @@ module Pact
|
|
41
41
|
def tear_down_provider_state provider_state_name, consumer, options = {}
|
42
42
|
Pact.configuration.provider_state_tear_down.call(provider_state_name, consumer, options)
|
43
43
|
end
|
44
|
+
|
45
|
+
def set_metadata example, key, value
|
46
|
+
Pact::RSpec.with_rspec_3 do
|
47
|
+
example.metadata[key] = value
|
48
|
+
end
|
49
|
+
|
50
|
+
Pact::RSpec.with_rspec_2 do
|
51
|
+
example.example.metadata[key] = value
|
52
|
+
end
|
53
|
+
end
|
44
54
|
end
|
45
55
|
end
|
46
56
|
end
|
@@ -47,7 +47,8 @@ module Pact
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def all_interactions_count
|
50
|
-
pact_source.pact_hash['interactions'].
|
50
|
+
interactions = (pact_source.pact_hash['interactions'] || pact_source.pact_hash['messages'])
|
51
|
+
interactions ? interactions.count : 0
|
51
52
|
end
|
52
53
|
|
53
54
|
def test_results_hash_for_pact_uri
|
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.add_runtime_dependency 'webrick'
|
29
29
|
gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
|
30
30
|
|
31
|
-
gem.add_runtime_dependency 'pact-support', '~> 1.
|
31
|
+
gem.add_runtime_dependency 'pact-support', '~> 1.4'
|
32
32
|
gem.add_runtime_dependency 'pact-mock_service', '~> 2.0'
|
33
33
|
|
34
34
|
gem.add_development_dependency 'rake', '~> 10.0.3'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Fraser
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2018-03-
|
15
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|
@@ -124,14 +124,14 @@ dependencies:
|
|
124
124
|
requirements:
|
125
125
|
- - "~>"
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version: '1.
|
127
|
+
version: '1.4'
|
128
128
|
type: :runtime
|
129
129
|
prerelease: false
|
130
130
|
version_requirements: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
132
|
- - "~>"
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version: '1.
|
134
|
+
version: '1.4'
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: pact-mock_service
|
137
137
|
requirement: !ruby/object:Gem::Requirement
|