pact 1.54.0 → 1.55.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -0
- data/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb +4 -2
- data/lib/pact/pact_broker/pact_selection_description.rb +0 -1
- data/lib/pact/provider/configuration/pact_verification_from_broker.rb +33 -6
- data/lib/pact/provider/pact_source.rb +9 -0
- data/lib/pact/provider/pact_spec_runner.rb +8 -11
- data/lib/pact/provider/rspec.rb +22 -13
- data/lib/pact/provider/rspec/calculate_exit_code.rb +18 -0
- data/lib/pact/provider/rspec/formatter_rspec_3.rb +70 -17
- data/lib/pact/provider/verification_results/create.rb +17 -13
- data/lib/pact/provider/verification_results/publish.rb +1 -1
- data/lib/pact/provider/world.rb +1 -1
- data/lib/pact/tasks/verification_task.rb +6 -0
- data/lib/pact/utils/string.rb +35 -0
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +2 -2
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5df3588ab530c1daf855cfe6277e5753d8ca788066951f3e08ef181af615b1d7
|
4
|
+
data.tar.gz: f13b6198bd1e1383a4dd978ca77bcdc65ee1a60498be14e17bb19ce1622274f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 476546bb221362d55c77df417d04a9f00a69bedc042ab6aabc059d498dc094f24f810ec25ea3f167ad77e366c4d8fd8d95b473d2d8d74ca5a58027d9d03e0e00
|
7
|
+
data.tar.gz: 500c176acb2a0f3e4b611b373afc0a868af0ba3bfa8d2082c4e192ffe00b80a4a63a11cadd408d19c28105091b73961c09ce2193d47705a3355b870fa9f777bf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,42 @@
|
|
1
|
+
<a name="v1.55.4"></a>
|
2
|
+
### v1.55.4 (2020-10-09)
|
3
|
+
|
4
|
+
#### Bug Fixes
|
5
|
+
|
6
|
+
* add back missing output describing the interactions filter ([1a2d7c1](/../../commit/1a2d7c1))
|
7
|
+
|
8
|
+
<a name="v1.55.3"></a>
|
9
|
+
### v1.55.3 (2020-09-28)
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* correct logic for determining if all interactions for a pact have been verified ([c4f968e](/../../commit/c4f968e))
|
14
|
+
* de-duplicate re-run commands ([0813498](/../../commit/0813498))
|
15
|
+
|
16
|
+
<a name="v1.55.2"></a>
|
17
|
+
### v1.55.2 (2020-09-26)
|
18
|
+
|
19
|
+
#### Bug Fixes
|
20
|
+
|
21
|
+
* correctly calculate exit code when a mix of pending and non pending pacts are verified ([533faa1](/../../commit/533faa1))
|
22
|
+
|
23
|
+
<a name="v1.55.1"></a>
|
24
|
+
### v1.55.1 (2020-09-26)
|
25
|
+
|
26
|
+
#### Bug Fixes
|
27
|
+
|
28
|
+
* remove accidentally committed debug logging ([081423e](/../../commit/081423e))
|
29
|
+
|
30
|
+
<a name="v1.55.0"></a>
|
31
|
+
### v1.55.0 (2020-09-26)
|
32
|
+
|
33
|
+
#### Features
|
34
|
+
|
35
|
+
* add consumer_version_selectors to pact verification DSL, and convert consumer_version_tags to selectors ([39e6c4a](/../../commit/39e6c4a))
|
36
|
+
* allow verification task to set just a pact_helper without a URI ([303077d](/../../commit/303077d))
|
37
|
+
* split pending and failed rerun commands into separate sections ([f839391](/../../commit/f839391))
|
38
|
+
* update output during verification so the pact info shows before the describe blocks of the pact that is being verified ([15ec231](/../../commit/15ec231))
|
39
|
+
|
1
40
|
<a name="v1.54.0"></a>
|
2
41
|
### v1.54.0 (2020-09-12)
|
3
42
|
|
@@ -39,9 +39,11 @@ module Pact
|
|
39
39
|
log_message
|
40
40
|
pacts_for_verification
|
41
41
|
else
|
42
|
+
old_selectors = consumer_version_selectors.collect do | selector |
|
43
|
+
{ name: selector[:tag], all: !selector[:latest], fallback: selector[:fallbackTag]}
|
44
|
+
end
|
42
45
|
# Fall back to old method of fetching pacts
|
43
|
-
|
44
|
-
FetchPacts.call(provider, consumer_version_tags, broker_base_url, http_client_options)
|
46
|
+
FetchPacts.call(provider, old_selectors, broker_base_url, http_client_options)
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
@@ -7,7 +7,6 @@ module Pact
|
|
7
7
|
if consumer_version_selectors.any?
|
8
8
|
desc = consumer_version_selectors.collect do |selector|
|
9
9
|
all_or_latest = !selector[:latest] ? "all for tag" : "latest for tag"
|
10
|
-
# TODO support fallback
|
11
10
|
fallback = selector[:fallback] || selector[:fallbackTag]
|
12
11
|
name = fallback ? "#{selector[:tag]} (or #{fallback} if not found)" : selector[:tag]
|
13
12
|
"#{all_or_latest} #{name}"
|
@@ -2,6 +2,7 @@ require 'pact/shared/dsl'
|
|
2
2
|
require 'pact/provider/world'
|
3
3
|
require 'pact/pact_broker/fetch_pact_uris_for_verification'
|
4
4
|
require 'pact/errors'
|
5
|
+
require 'pact/utils/string'
|
5
6
|
|
6
7
|
module Pact
|
7
8
|
module Provider
|
@@ -14,12 +15,13 @@ module Pact
|
|
14
15
|
# in parent scope, it will clash with these ones,
|
15
16
|
# so put an underscore in front of the name to be safer.
|
16
17
|
|
17
|
-
attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_provider_version_tags, :_basic_auth_options, :_enable_pending, :_include_wip_pacts_since, :_verbose
|
18
|
+
attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_provider_version_tags, :_basic_auth_options, :_enable_pending, :_include_wip_pacts_since, :_verbose, :_consumer_version_selectors
|
18
19
|
|
19
20
|
def initialize(provider_name, provider_version_tags)
|
20
21
|
@_provider_name = provider_name
|
21
22
|
@_provider_version_tags = provider_version_tags
|
22
23
|
@_consumer_version_tags = []
|
24
|
+
@_consumer_version_selectors = []
|
23
25
|
@_enable_pending = false
|
24
26
|
@_include_wip_pacts_since = nil
|
25
27
|
@_verbose = false
|
@@ -35,6 +37,10 @@ module Pact
|
|
35
37
|
self._consumer_version_tags = *consumer_version_tags
|
36
38
|
end
|
37
39
|
|
40
|
+
def consumer_version_selectors consumer_version_selectors
|
41
|
+
self._consumer_version_selectors = *consumer_version_selectors
|
42
|
+
end
|
43
|
+
|
38
44
|
def enable_pending enable_pending
|
39
45
|
self._enable_pending = enable_pending
|
40
46
|
end
|
@@ -73,12 +79,33 @@ module Pact
|
|
73
79
|
end
|
74
80
|
|
75
81
|
def consumer_version_selectors
|
76
|
-
|
82
|
+
convert_tags_to_selectors + convert_consumer_version_selectors
|
83
|
+
end
|
84
|
+
|
85
|
+
def convert_tags_to_selectors
|
77
86
|
_consumer_version_tags.collect do | tag |
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
87
|
+
if tag.is_a?(Hash)
|
88
|
+
{
|
89
|
+
tag: tag.fetch(:name),
|
90
|
+
latest: !tag[:all],
|
91
|
+
fallbackTag: tag[:fallback]
|
92
|
+
}
|
93
|
+
elsif tag.is_a?(String)
|
94
|
+
{
|
95
|
+
tag: tag,
|
96
|
+
latest: true
|
97
|
+
}
|
98
|
+
else
|
99
|
+
raise Pact::Error.new("The value supplied for consumer_version_tags must be a String or a Hash. Found #{tag.class}")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def convert_consumer_version_selectors
|
105
|
+
_consumer_version_selectors.collect do | selector |
|
106
|
+
selector.each_with_object({}) do | (key, value), new_selector |
|
107
|
+
new_selector[Pact::Utils::String.camelcase(key.to_s).to_sym] = value
|
108
|
+
end
|
82
109
|
end
|
83
110
|
end
|
84
111
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pact/consumer_contract/pact_file'
|
2
2
|
require 'pact/hal/http_client'
|
3
3
|
require 'pact/hal/entity'
|
4
|
+
require 'pact/consumer_contract'
|
4
5
|
|
5
6
|
module Pact
|
6
7
|
module Provider
|
@@ -20,6 +21,14 @@ module Pact
|
|
20
21
|
@pact_hash ||= JSON.load(pact_json, nil, { max_nesting: 50 })
|
21
22
|
end
|
22
23
|
|
24
|
+
def pending?
|
25
|
+
uri.metadata[:pending]
|
26
|
+
end
|
27
|
+
|
28
|
+
def consumer_contract
|
29
|
+
@consumer_contract ||= Pact::ConsumerContract.from_json(pact_json)
|
30
|
+
end
|
31
|
+
|
23
32
|
def hal_entity
|
24
33
|
http_client_keys = [:username, :password, :token]
|
25
34
|
http_client_options = uri.options.reject{ |k, _| !http_client_keys.include?(k) }
|
@@ -11,6 +11,7 @@ require 'pact/provider/verification_results/publish_all'
|
|
11
11
|
require 'pact/provider/rspec/pact_broker_formatter'
|
12
12
|
require 'pact/provider/rspec/json_formatter'
|
13
13
|
require 'pact/provider/rspec'
|
14
|
+
require 'pact/provider/rspec/calculate_exit_code'
|
14
15
|
|
15
16
|
module Pact
|
16
17
|
module Provider
|
@@ -79,6 +80,7 @@ module Pact
|
|
79
80
|
executing_with_ruby = executing_with_ruby?
|
80
81
|
|
81
82
|
config.after(:suite) do | suite |
|
83
|
+
Pact.provider_world.failed_examples = suite.reporter.failed_examples
|
82
84
|
Pact::Provider::Help::Write.call(Pact.provider_world.pact_sources) if executing_with_ruby
|
83
85
|
end
|
84
86
|
end
|
@@ -90,7 +92,12 @@ module Pact
|
|
90
92
|
::RSpec::Core::CommandLine.new(NoConfigurationOptions.new)
|
91
93
|
.run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
|
92
94
|
end
|
93
|
-
|
95
|
+
|
96
|
+
if options[:ignore_failures]
|
97
|
+
0
|
98
|
+
else
|
99
|
+
Pact::Provider::RSpec::CalculateExitCode.call(pact_sources, Pact.provider_world.failed_examples)
|
100
|
+
end
|
94
101
|
end
|
95
102
|
|
96
103
|
def rspec_runner_options
|
@@ -147,8 +154,6 @@ module Pact
|
|
147
154
|
end
|
148
155
|
|
149
156
|
::RSpec.configuration.full_backtrace = @options[:full_backtrace]
|
150
|
-
|
151
|
-
::RSpec.configuration.failure_color = :yellow if pending_mode?
|
152
157
|
end
|
153
158
|
|
154
159
|
def ordered_pact_json(pact_json)
|
@@ -159,20 +164,12 @@ module Pact
|
|
159
164
|
consumer_contract.to_json
|
160
165
|
end
|
161
166
|
|
162
|
-
def all_pacts_pending?
|
163
|
-
pact_urls.all?{ | pact_url| pact_url.metadata[:pending] }
|
164
|
-
end
|
165
|
-
|
166
167
|
def class_exists? name
|
167
168
|
Kernel.const_get name
|
168
169
|
rescue NameError
|
169
170
|
false
|
170
171
|
end
|
171
172
|
|
172
|
-
def pending_mode?
|
173
|
-
(all_pacts_pending? || options[:ignore_failures])
|
174
|
-
end
|
175
|
-
|
176
173
|
def executing_with_ruby?
|
177
174
|
ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby'
|
178
175
|
end
|
data/lib/pact/provider/rspec.rb
CHANGED
@@ -24,28 +24,36 @@ module Pact
|
|
24
24
|
def honour_pactfile pact_source, pact_json, options
|
25
25
|
pact_uri = pact_source.uri
|
26
26
|
Pact.configuration.output_stream.puts "INFO: Reading pact at #{pact_uri}"
|
27
|
-
if pact_uri.metadata[:notices]
|
28
|
-
pact_uri.metadata[:notices].before_verification_notices_text.each do | text |
|
29
|
-
Pact.configuration.output_stream.puts("DEBUG: #{text}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Pact.configuration.output_stream.puts "DEBUG: Filtering interactions by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any?
|
34
27
|
consumer_contract = Pact::ConsumerContract.from_json(pact_json)
|
35
28
|
suffix = pact_uri.metadata[:pending] ? " [PENDING]": ""
|
36
|
-
|
37
|
-
|
29
|
+
example_group_description = "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}#{suffix}"
|
30
|
+
example_group_metadata = { pactfile_uri: pact_uri, pact_criteria: options[:criteria] }
|
31
|
+
|
32
|
+
::RSpec.describe example_group_description, example_group_metadata do
|
33
|
+
honour_consumer_contract consumer_contract, options.merge(
|
34
|
+
pact_json: pact_json,
|
35
|
+
pact_uri: pact_uri,
|
36
|
+
pact_source: pact_source,
|
37
|
+
consumer_contract: consumer_contract,
|
38
|
+
criteria: options[:criteria]
|
39
|
+
)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
43
|
def honour_consumer_contract consumer_contract, options = {}
|
42
|
-
describe_consumer_contract consumer_contract, options.merge(consumer: consumer_contract.consumer.name)
|
44
|
+
describe_consumer_contract consumer_contract, options.merge(consumer: consumer_contract.consumer.name, pact_context: InteractionContext.new)
|
43
45
|
end
|
44
46
|
|
45
47
|
private
|
46
48
|
|
47
49
|
def describe_consumer_contract consumer_contract, options
|
48
|
-
consumer_interactions(consumer_contract, options).
|
50
|
+
consumer_interactions(consumer_contract, options).tap{ |interactions|
|
51
|
+
if interactions.empty?
|
52
|
+
# If there are no interactions, the documentation formatter never fires to print this out,
|
53
|
+
# so print it out here.
|
54
|
+
Pact.configuration.output_stream.puts "DEBUG: All interactions for #{options[:pact_uri]} have been filtered out by criteria: #{options[:criteria]}" if options[:criteria] && options[:criteria].any?
|
55
|
+
end
|
56
|
+
}.each do |interaction|
|
49
57
|
describe_interaction_with_provider_state interaction, options
|
50
58
|
end
|
51
59
|
end
|
@@ -54,7 +62,7 @@ module Pact
|
|
54
62
|
if options[:criteria].nil?
|
55
63
|
consumer_contract.interactions
|
56
64
|
else
|
57
|
-
consumer_contract.find_interactions
|
65
|
+
consumer_contract.find_interactions(options[:criteria])
|
58
66
|
end
|
59
67
|
end
|
60
68
|
|
@@ -83,13 +91,14 @@ module Pact
|
|
83
91
|
pact_interaction_example_description: interaction_description_for_rerun_command(interaction),
|
84
92
|
pact_uri: options[:pact_uri],
|
85
93
|
pact_source: options[:pact_source],
|
86
|
-
pact_ignore_failures: options[:
|
94
|
+
pact_ignore_failures: options[:pact_source].pending? || options[:ignore_failures],
|
87
95
|
pact_consumer_contract: options[:consumer_contract]
|
88
96
|
}
|
89
97
|
|
90
98
|
describe description_for(interaction), metadata do
|
91
99
|
|
92
100
|
interaction_context = InteractionContext.new
|
101
|
+
pact_context = options[:pact_context]
|
93
102
|
|
94
103
|
before do | example |
|
95
104
|
interaction_context.run_once :before do
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Pact
|
2
|
+
module Provider
|
3
|
+
module RSpec
|
4
|
+
module CalculateExitCode
|
5
|
+
def self.call(pact_sources, failed_examples)
|
6
|
+
any_non_pending_failures = pact_sources.any? do |pact_source|
|
7
|
+
if pact_source.pending?
|
8
|
+
nil
|
9
|
+
else
|
10
|
+
failed_examples.select { |e| e.metadata[:pact_source] == pact_source }.any?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
any_non_pending_failures ? 1 : 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -24,6 +24,26 @@ module Pact
|
|
24
24
|
|
25
25
|
C = ::Term::ANSIColor
|
26
26
|
|
27
|
+
def example_group_started(notification)
|
28
|
+
# This is the metadata on the top level "Verifying a pact between X and Y" describe block
|
29
|
+
if @group_level == 0
|
30
|
+
Pact.configuration.output_stream.puts
|
31
|
+
pact_uri = notification.group.metadata[:pactfile_uri]
|
32
|
+
::RSpec.configuration.failure_color = pact_uri.metadata[:pending] ? :yellow : :red
|
33
|
+
|
34
|
+
if pact_uri.metadata[:notices]
|
35
|
+
pact_uri.metadata[:notices].before_verification_notices_text.each do | text |
|
36
|
+
Pact.configuration.output_stream.puts("DEBUG: #{text}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
criteria = notification.group.metadata[:pact_criteria]
|
41
|
+
Pact.configuration.output_stream.puts "DEBUG: Filtering interactions by: #{criteria}" if criteria && criteria.any?
|
42
|
+
end
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
|
27
47
|
def dump_summary(summary)
|
28
48
|
output.puts "\n" + colorized_totals_line(summary)
|
29
49
|
return if summary.failure_count == 0
|
@@ -35,28 +55,26 @@ module Pact
|
|
35
55
|
private
|
36
56
|
|
37
57
|
def interactions_count(summary)
|
38
|
-
summary.examples.collect{ |e| e
|
58
|
+
summary.examples.collect{ |e| interaction_unique_key(e) }.uniq.size
|
39
59
|
end
|
40
60
|
|
41
61
|
def failed_interactions_count(summary)
|
42
|
-
summary.
|
62
|
+
failed_interaction_examples(summary).size
|
43
63
|
end
|
44
64
|
|
45
|
-
def
|
46
|
-
summary.
|
65
|
+
def pending_interactions_count(summary)
|
66
|
+
pending_interaction_examples(summary).size
|
47
67
|
end
|
48
68
|
|
49
69
|
def failure_title summary
|
50
|
-
|
51
|
-
"#{failed_interactions_count(summary)} pending"
|
52
|
-
else
|
53
|
-
::RSpec::Core::Formatters::Helpers.pluralize(failed_interactions_count(summary), "failure")
|
54
|
-
end
|
70
|
+
::RSpec::Core::Formatters::Helpers.pluralize(failed_interactions_count(summary), "failure")
|
55
71
|
end
|
56
72
|
|
57
73
|
def totals_line summary
|
58
74
|
line = ::RSpec::Core::Formatters::Helpers.pluralize(interactions_count(summary), "interaction")
|
59
75
|
line << ", " << failure_title(summary)
|
76
|
+
pending_count = pending_interactions_count(summary)
|
77
|
+
line << ", " << "#{pending_count} pending" if pending_count > 0
|
60
78
|
line
|
61
79
|
end
|
62
80
|
|
@@ -69,13 +87,20 @@ module Pact
|
|
69
87
|
end
|
70
88
|
|
71
89
|
def print_rerun_commands summary
|
72
|
-
if
|
90
|
+
if pending_interactions_count(summary) > 0
|
91
|
+
set_rspec_failure_color(:yellow)
|
73
92
|
output.puts("\nPending interactions: (Failures listed here are expected and do not affect your suite's status)\n\n")
|
74
|
-
|
75
|
-
|
93
|
+
interaction_rerun_commands(pending_interaction_examples(summary)).each do | message |
|
94
|
+
output.puts(message)
|
95
|
+
end
|
96
|
+
set_rspec_failure_color(:red)
|
76
97
|
end
|
77
|
-
|
78
|
-
|
98
|
+
|
99
|
+
if failed_interactions_count(summary) > 0
|
100
|
+
output.puts("\nFailed interactions:\n\n")
|
101
|
+
interaction_rerun_commands(failed_interaction_examples(summary)).each do | message |
|
102
|
+
output.puts(message)
|
103
|
+
end
|
79
104
|
end
|
80
105
|
end
|
81
106
|
|
@@ -85,10 +110,34 @@ module Pact
|
|
85
110
|
end
|
86
111
|
end
|
87
112
|
|
88
|
-
def
|
89
|
-
summary.
|
113
|
+
def pending_interaction_examples(summary)
|
114
|
+
one_failed_example_per_interaction(summary).select do | example |
|
115
|
+
example.metadata[:pactfile_uri].metadata[:pending]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def failed_interaction_examples(summary)
|
120
|
+
one_failed_example_per_interaction(summary).select do | example |
|
121
|
+
!example.metadata[:pactfile_uri].metadata[:pending]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def one_failed_example_per_interaction(summary)
|
126
|
+
summary.failed_examples.group_by{| e| interaction_unique_key(e)}.values.collect(&:first)
|
127
|
+
end
|
128
|
+
|
129
|
+
def interaction_rerun_commands examples
|
130
|
+
examples.collect do |example|
|
90
131
|
interaction_rerun_command_for example
|
91
|
-
end.uniq
|
132
|
+
end.compact.uniq
|
133
|
+
end
|
134
|
+
|
135
|
+
def interaction_unique_key(example)
|
136
|
+
# pending is just to make the counting easier, it isn't required for the unique key
|
137
|
+
{
|
138
|
+
pactfile_uri: example.metadata[:pactfile_uri],
|
139
|
+
index: example.metadata[:pact_interaction].index,
|
140
|
+
}
|
92
141
|
end
|
93
142
|
|
94
143
|
def interaction_rerun_command_for example
|
@@ -137,6 +186,10 @@ module Pact
|
|
137
186
|
def executing_with_ruby?
|
138
187
|
ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby'
|
139
188
|
end
|
189
|
+
|
190
|
+
def set_rspec_failure_color color
|
191
|
+
::RSpec.configuration.failure_color = color
|
192
|
+
end
|
140
193
|
end
|
141
194
|
end
|
142
195
|
end
|
@@ -28,7 +28,23 @@ module Pact
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def publishable?
|
31
|
-
|
31
|
+
if defined?(@publishable)
|
32
|
+
@publishable
|
33
|
+
else
|
34
|
+
@publishable = pact_source.consumer_contract.interactions.all? do | interaction |
|
35
|
+
examples_for_pact_uri.any?{ |e| example_is_for_interaction?(e, interaction) }
|
36
|
+
end && examples_for_pact_uri.count > 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def example_is_for_interaction?(example, interaction)
|
41
|
+
# Use the Pact Broker id if supported
|
42
|
+
if interaction._id
|
43
|
+
example[:pact_interaction]._id == interaction._id
|
44
|
+
else
|
45
|
+
# fall back to object equality (based on the field values of the interaction)
|
46
|
+
example[:pact_interaction] == interaction
|
47
|
+
end
|
32
48
|
end
|
33
49
|
|
34
50
|
def examples_for_pact_uri
|
@@ -39,18 +55,6 @@ module Pact
|
|
39
55
|
examples_for_pact_uri.count{ |e| e[:status] != 'passed' }
|
40
56
|
end
|
41
57
|
|
42
|
-
def executed_interactions_count
|
43
|
-
examples_for_pact_uri
|
44
|
-
.collect { |e| e[:pact_interaction].object_id }
|
45
|
-
.uniq
|
46
|
-
.count
|
47
|
-
end
|
48
|
-
|
49
|
-
def all_interactions_count
|
50
|
-
interactions = (pact_source.pact_hash['interactions'] || pact_source.pact_hash['messages'])
|
51
|
-
interactions ? interactions.count : 0
|
52
|
-
end
|
53
|
-
|
54
58
|
def test_results_hash_for_pact_uri
|
55
59
|
{
|
56
60
|
tests: examples_for_pact_uri.collect{ |e| clean_example(e) },
|
@@ -81,7 +81,7 @@ module Pact
|
|
81
81
|
Pact.configuration.output_stream.puts "INFO: Tagging version #{provider_application_version} of #{provider_name} as #{tag.inspect}"
|
82
82
|
tag_entity = tag_link.expand(version: provider_application_version, tag: tag).put
|
83
83
|
unless tag_entity.success?
|
84
|
-
raise PublicationError.new("Error returned from tagging request
|
84
|
+
raise PublicationError.new("Error returned from tagging request: status=#{tag_entity.response.code} body=#{tag_entity.response.body}")
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
data/lib/pact/provider/world.rb
CHANGED
@@ -31,6 +31,7 @@ module Pact
|
|
31
31
|
attr_reader :pact_spec_configs
|
32
32
|
attr_accessor :rspec_opts
|
33
33
|
attr_accessor :ignore_failures
|
34
|
+
attr_accessor :_pact_helper
|
34
35
|
|
35
36
|
def initialize(name)
|
36
37
|
@rspec_opts = nil
|
@@ -41,6 +42,10 @@ module Pact
|
|
41
42
|
rake_task
|
42
43
|
end
|
43
44
|
|
45
|
+
def pact_helper(pact_helper)
|
46
|
+
@pact_spec_configs << { pact_helper: pact_helper }
|
47
|
+
end
|
48
|
+
|
44
49
|
def uri(uri, options = {})
|
45
50
|
@pact_spec_configs << {uri: uri, pact_helper: options[:pact_helper]}
|
46
51
|
end
|
@@ -82,6 +87,7 @@ module Pact
|
|
82
87
|
Pact::TaskHelper.handle_verification_failure do
|
83
88
|
exit_statuses.count{ | status | status != 0 }
|
84
89
|
end
|
90
|
+
|
85
91
|
end
|
86
92
|
end
|
87
93
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Can't use refinements because of Travelling Ruby
|
2
|
+
|
3
|
+
module Pact
|
4
|
+
module Utils
|
5
|
+
module String
|
6
|
+
|
7
|
+
extend self
|
8
|
+
|
9
|
+
# ripped from rubyworks/facets, thank you
|
10
|
+
def camelcase(string, *separators)
|
11
|
+
case separators.first
|
12
|
+
when Symbol, TrueClass, FalseClass, NilClass
|
13
|
+
first_letter = separators.shift
|
14
|
+
end
|
15
|
+
|
16
|
+
separators = ['_', '\s'] if separators.empty?
|
17
|
+
|
18
|
+
str = string.dup
|
19
|
+
|
20
|
+
separators.each do |s|
|
21
|
+
str = str.gsub(/(?:#{s}+)([a-z])/){ $1.upcase }
|
22
|
+
end
|
23
|
+
|
24
|
+
case first_letter
|
25
|
+
when :upper, true
|
26
|
+
str = str.gsub(/(\A|\s)([a-z])/){ $1 + $2.upcase }
|
27
|
+
when :lower, false
|
28
|
+
str = str.gsub(/(\A|\s)([A-Z])/){ $1 + $2.downcase }
|
29
|
+
end
|
30
|
+
|
31
|
+
str
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |gem|
|
|
32
32
|
gem.add_runtime_dependency 'webrick', '~> 1.3'
|
33
33
|
gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
|
34
34
|
|
35
|
-
gem.add_runtime_dependency 'pact-support', '~> 1.
|
35
|
+
gem.add_runtime_dependency 'pact-support', '~> 1.15'
|
36
36
|
gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
|
37
37
|
|
38
38
|
gem.add_development_dependency 'rake', '~> 13.0'
|
@@ -43,6 +43,6 @@ Gem::Specification.new do |gem|
|
|
43
43
|
gem.add_development_dependency 'faraday', '~> 0.13'
|
44
44
|
gem.add_development_dependency 'conventional-changelog', '~> 1.3'
|
45
45
|
gem.add_development_dependency 'bump', '~> 0.5'
|
46
|
-
gem.add_development_dependency 'pact-message', '~> 0.
|
46
|
+
gem.add_development_dependency 'pact-message', '~> 0.8'
|
47
47
|
gem.add_development_dependency 'rspec-its', '~> 1.3'
|
48
48
|
end
|
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.55.4
|
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: 2020-09
|
15
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec
|
@@ -102,14 +102,14 @@ dependencies:
|
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: '1.
|
105
|
+
version: '1.15'
|
106
106
|
type: :runtime
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: '1.
|
112
|
+
version: '1.15'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: pact-mock_service
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,14 +248,14 @@ dependencies:
|
|
248
248
|
requirements:
|
249
249
|
- - "~>"
|
250
250
|
- !ruby/object:Gem::Version
|
251
|
-
version: '0.
|
251
|
+
version: '0.8'
|
252
252
|
type: :development
|
253
253
|
prerelease: false
|
254
254
|
version_requirements: !ruby/object:Gem::Requirement
|
255
255
|
requirements:
|
256
256
|
- - "~>"
|
257
257
|
- !ruby/object:Gem::Version
|
258
|
-
version: '0.
|
258
|
+
version: '0.8'
|
259
259
|
- !ruby/object:Gem::Dependency
|
260
260
|
name: rspec-its
|
261
261
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,6 +352,7 @@ files:
|
|
352
352
|
- lib/pact/provider/request.rb
|
353
353
|
- lib/pact/provider/rspec.rb
|
354
354
|
- lib/pact/provider/rspec/backtrace_formatter.rb
|
355
|
+
- lib/pact/provider/rspec/calculate_exit_code.rb
|
355
356
|
- lib/pact/provider/rspec/custom_options_file
|
356
357
|
- lib/pact/provider/rspec/formatter_rspec_2.rb
|
357
358
|
- lib/pact/provider/rspec/formatter_rspec_3.rb
|
@@ -377,6 +378,7 @@ files:
|
|
377
378
|
- lib/pact/tasks/verification_task.rb
|
378
379
|
- lib/pact/templates/help.erb
|
379
380
|
- lib/pact/templates/provider_state.erb
|
381
|
+
- lib/pact/utils/string.rb
|
380
382
|
- lib/pact/version.rb
|
381
383
|
- lib/tasks/pact.rake
|
382
384
|
- pact.gemspec
|