Skip to content

Commit 8e2dffd

Browse files
committed
feat(verify cli): rename --wip to --ignore-failures
1 parent 2fca940 commit 8e2dffd

13 files changed

+37
-36
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ Gemfile.lock
3131
gemfiles/*.gemfile.lock
3232
reports/pacts
3333
spec/examples.txt
34+
*bethtest*

lib/pact/cli.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class CLI < Thor
88
desc 'verify', "Verify a pact"
99
method_option :pact_helper, aliases: "-h", desc: "Pact helper file", :required => true
1010
method_option :pact_uri, aliases: "-p", desc: "Pact URI"
11-
method_option :wip, type: :boolean, default: false, desc: "If WIP, process will always exit with exit code 0", hide: true
11+
method_option :ignore_failures, type: :boolean, default: false, desc: "Process will always exit with exit code 0", hide: true
1212
method_option :pact_broker_username, aliases: "-u", desc: "Pact broker user name"
1313
method_option :pact_broker_password, aliases: "-w", desc: "Pact broker password"
1414
method_option :backtrace, aliases: "-b", desc: "Show full backtrace", :default => false, :type => :boolean

lib/pact/cli/run_pact_verification.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def pact_spec_options
7272
criteria: SpecCriteria.call(options),
7373
format: options[:format],
7474
out: options[:out],
75-
wip: options[:wip]
75+
ignore_failures: options[:ignore_failures]
7676
}
7777
end
7878
end

lib/pact/provider/pact_spec_runner.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def run_specs
9191
::RSpec::Core::CommandLine.new(NoConfigurationOptions.new)
9292
.run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
9393
end
94-
options[:wip] ? 0 : exit_code
94+
options[:ignore_failures] ? 0 : exit_code
9595
end
9696

9797
def rspec_runner_options
@@ -120,7 +120,7 @@ def initialize_specs
120120
pact_sources.each do | pact_source |
121121
options = {
122122
criteria: @options[:criteria],
123-
wip: @options[:wip]
123+
ignore_failures: @options[:ignore_failures]
124124
}
125125
honour_pactfile pact_source.uri, ordered_pact_json(pact_source.pact_json), options
126126
end
@@ -147,7 +147,7 @@ def configure_output
147147

148148
::RSpec.configuration.full_backtrace = @options[:full_backtrace]
149149

150-
::RSpec.configuration.failure_color = :yellow if @options[:wip]
150+
::RSpec.configuration.failure_color = :yellow if @options[:ignore_failures]
151151
end
152152

153153
def ordered_pact_json(pact_json)

lib/pact/provider/rspec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module ClassMethods
2121
include ::RSpec::Core::DSL
2222

2323
def honour_pactfile pact_uri, pact_json, options
24-
pact_description = options[:wip] ? "WIP pact" : "pact"
24+
pact_description = options[:ignore_failures] ? "Pending pact" : "pact"
2525
Pact.configuration.output_stream.puts "INFO: Reading #{pact_description} at #{pact_uri}"
2626
Pact.configuration.output_stream.puts "INFO: Filtering interactions by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any?
2727
consumer_contract = Pact::ConsumerContract.from_json(pact_json)
@@ -74,7 +74,7 @@ def describe_interaction interaction, options
7474
pact_interaction: interaction,
7575
pact_interaction_example_description: interaction_description_for_rerun_command(interaction),
7676
pact_uri: options[:pact_uri],
77-
pact_wip: options[:wip]
77+
pact_ignore_failures: options[:ignore_failures]
7878
}
7979

8080
describe description_for(interaction), metadata do

lib/pact/provider/rspec/formatter_rspec_3.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ def failed_interactions_count(summary)
4242
summary.failed_examples.collect{ |e| e.metadata[:pact_interaction_example_description] }.uniq.size
4343
end
4444

45-
def wip?(summary)
46-
summary.failed_examples.any?{ |e| e.metadata[:pact_wip] }
45+
def ignore_failures?(summary)
46+
summary.failed_examples.any?{ |e| e.metadata[:pact_ignore_failures] }
4747
end
4848

4949
def failure_title summary
50-
if wip?(summary)
50+
if ignore_failures?(summary)
5151
"#{failed_interactions_count(summary)} pending"
5252
else
5353
::RSpec::Core::Formatters::Helpers.pluralize(failed_interactions_count(summary), "failure")
@@ -69,7 +69,7 @@ def color_for_summary summary
6969
end
7070

7171
def print_rerun_commands summary
72-
if wip?(summary)
72+
if ignore_failures?(summary)
7373
output.puts("\nPending interactions: (Failures listed here are expected and do not affect your suite's status)\n\n")
7474
else
7575
output.puts("\nFailed interactions:\n\n")

lib/pact/tasks/task_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def verify_command pact_helper, pact_uri, rspec_opts, verification_opts
2828
command_parts << "-S pact verify"
2929
command_parts << "--pact-helper" << Shellwords.escape(pact_helper.end_with?(".rb") ? pact_helper : pact_helper + ".rb")
3030
(command_parts << "--pact-uri" << pact_uri) if pact_uri
31-
command_parts << "--wip" if verification_opts[:wip]
31+
command_parts << "--ignore-failures" if verification_opts[:ignore_failures]
3232
command_parts << "--pact-broker-username" << ENV['PACT_BROKER_USERNAME'] if ENV['PACT_BROKER_USERNAME']
3333
command_parts << "--pact-broker-password" << ENV['PACT_BROKER_PASSWORD'] if ENV['PACT_BROKER_PASSWORD']
3434
command_parts << "--backtrace" if ENV['BACKTRACE'] == 'true'

lib/pact/tasks/verification_task.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class VerificationTask < ::Rake::TaskLib
3030

3131
attr_reader :pact_spec_configs
3232
attr_accessor :rspec_opts
33-
attr_accessor :wip
33+
attr_accessor :ignore_failures
3434

3535
def initialize(name)
3636
@rspec_opts = nil
37-
@wip = false
37+
@ignore_failures = false
3838
@pact_spec_configs = []
3939
@name = name
4040
yield self
@@ -76,7 +76,7 @@ def rake_task
7676
require 'pact/tasks/task_helper'
7777

7878
exit_statuses = pact_spec_configs.collect do | config |
79-
Pact::TaskHelper.execute_pact_verify config[:uri], config[:pact_helper], rspec_opts, { wip: wip }
79+
Pact::TaskHelper.execute_pact_verify config[:uri], config[:pact_helper], rspec_opts, { ignore_failures: ignore_failures }
8080
end
8181

8282
Pact::TaskHelper.handle_verification_failure do

spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module RSpec
2020
pactfile_uri: pactfile_uri,
2121
pact_interaction_example_description: description,
2222
pact_json: pact_json,
23-
pact_wip: wip
23+
pact_ignore_failures: ignore_failures
2424
}
2525
end
2626
let(:metadata_2) { metadata.merge(pact_interaction_example_description: 'another interaction')}
@@ -34,7 +34,7 @@ module RSpec
3434
let(:summary) { double("summary", failure_count: 1, failed_examples: failed_examples, examples: examples)}
3535
let(:pact_executing_language) { 'ruby' }
3636
let(:pact_interaction_rerun_command) { Pact::TaskHelper::PACT_INTERACTION_RERUN_COMMAND }
37-
let(:wip) { nil }
37+
let(:ignore_failures) { nil }
3838

3939
subject { Formatter.new output }
4040

@@ -105,8 +105,8 @@ module RSpec
105105
end
106106
end
107107

108-
context "when wip is true" do
109-
let(:wip) { true }
108+
context "when ignore_failures is true" do
109+
let(:ignore_failures) { true }
110110

111111
it "reports failures as pending" do
112112
expect(output_result).to include("1 pending")

spec/lib/pact/tasks/task_helper_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module Pact
88
let(:ruby_path) { "/path/to/ruby" }
99
let(:pact_uri) { "/pact/uri" }
1010
let(:default_pact_helper_path) { "/pact/helper/path.rb" }
11-
let(:verification_options) { { wip: wip } }
12-
let(:wip) { nil }
11+
let(:verification_options) { { ignore_failures: ignore_failures } }
12+
let(:ignore_failures) { nil }
1313

1414
before do
1515
stub_const("FileUtils::RUBY", ruby_path)
@@ -119,10 +119,10 @@ module Pact
119119
end
120120
end
121121

122-
context "with wip: true" do
123-
let(:wip) { true }
124-
it "executes the command with --wip" do
125-
expect(TaskHelper).to receive(:execute_cmd).with(/ --wip\b/)
122+
context "with ignore_failures: true" do
123+
let(:ignore_failures) { true }
124+
it "executes the command with --ignore-failures" do
125+
expect(TaskHelper).to receive(:execute_cmd).with(/ --ignore-failures\b/)
126126
TaskHelper.execute_pact_verify(pact_uri, nil, nil, verification_options)
127127
end
128128
end

spec/lib/pact/tasks/verification_task_spec.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Pact
99
@pact_uri = 'http://example.org/pact.json'
1010
@task_name = 'pact:verify:pact_rake_spec'
1111
@task_name_with_explict_pact_helper = 'pact:verify:pact_rake_spec_with_explict_pact_helper'
12-
@task_name_wip = 'pact:verify:pact_rake_spec_wip'
12+
@task_name_ignore_failures = 'pact:verify:pact_rake_spec_ignore_failures'
1313
@consumer = 'some-consumer'
1414
@criteria = {:description => /wiffle/}
1515

@@ -21,9 +21,9 @@ module Pact
2121
pact.uri @pact_uri
2222
end
2323

24-
VerificationTask.new(:pact_rake_spec_wip) do | pact |
24+
VerificationTask.new(:pact_rake_spec_ignore_failures) do | pact |
2525
pact.uri @pact_uri
26-
pact.wip = true
26+
pact.ignore_failures = true
2727
end
2828
end
2929

@@ -47,23 +47,23 @@ module Pact
4747
describe 'execute' do
4848
context "with no explicit pact_helper" do
4949
it 'verifies the pacts using the TaskHelper' do
50-
expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, nil, nil, { wip: false })
50+
expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, nil, nil, { ignore_failures: false })
5151
Rake::Task[@task_name].execute
5252
end
5353
end
5454

5555
context "with an explict pact_helper" do
5656
let(:verification_config) { [ uri: @pact_uri, pact_helper: @pact_helper] }
5757
it 'verifies the pacts using specified pact_helper' do
58-
expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, @pact_helper, nil, { wip: false })
58+
expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, @pact_helper, nil, { ignore_failures: false })
5959
Rake::Task[@task_name_with_explict_pact_helper].execute
6060
end
6161
end
6262

63-
context "with wip: true" do
64-
it 'verifies the pacts with wip: true' do
65-
expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, anything, anything, { wip: true })
66-
Rake::Task[@task_name_wip].execute
63+
context "with ignore_failures: true" do
64+
it 'verifies the pacts with ignore_failures: true' do
65+
expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, anything, anything, { ignore_failures: true })
66+
Rake::Task[@task_name_ignore_failures].execute
6767
end
6868
end
6969

tasks/foo-bar.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ end
3131

3232
Pact::VerificationTask.new('foobar:wip') do | pact |
3333
pact.uri './spec/pacts/foo-bar-wip.json', pact_helper: './spec/support/bar_pact_helper.rb'
34-
pact.wip = true
34+
pact.ignore_failures = true
3535
end
3636

3737
Pact::VerificationTask.new(:foobar_using_broker) do | pact |

tasks/pact-test.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ end
5555

5656
Pact::VerificationTask.new('test_app:wip') do | pact |
5757
pact.uri './spec/support/test_app_fail.json', pact_helper: './spec/support/pact_helper.rb'
58-
pact.wip = true
58+
pact.ignore_failures = true
5959
end
6060

6161

0 commit comments

Comments
 (0)