From 8e2dffdbab4935d333fff04b3c5f197430f8453f Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Tue, 14 Aug 2018 07:39:01 +1000 Subject: [PATCH] feat(verify cli): rename --wip to --ignore-failures --- .gitignore | 1 + lib/pact/cli.rb | 2 +- lib/pact/cli/run_pact_verification.rb | 2 +- lib/pact/provider/pact_spec_runner.rb | 6 +++--- lib/pact/provider/rspec.rb | 4 ++-- lib/pact/provider/rspec/formatter_rspec_3.rb | 8 ++++---- lib/pact/tasks/task_helper.rb | 2 +- lib/pact/tasks/verification_task.rb | 6 +++--- .../provider/rspec/formatter_rspec_3_spec.rb | 8 ++++---- spec/lib/pact/tasks/task_helper_spec.rb | 12 ++++++------ spec/lib/pact/tasks/verification_task_spec.rb | 18 +++++++++--------- tasks/foo-bar.rake | 2 +- tasks/pact-test.rake | 2 +- 13 files changed, 37 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index b1eadaaf..296c56bc 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ Gemfile.lock gemfiles/*.gemfile.lock reports/pacts spec/examples.txt +*bethtest* \ No newline at end of file diff --git a/lib/pact/cli.rb b/lib/pact/cli.rb index d1337022..ba2ee8c5 100755 --- a/lib/pact/cli.rb +++ b/lib/pact/cli.rb @@ -8,7 +8,7 @@ class CLI < Thor desc 'verify', "Verify a pact" method_option :pact_helper, aliases: "-h", desc: "Pact helper file", :required => true method_option :pact_uri, aliases: "-p", desc: "Pact URI" - method_option :wip, type: :boolean, default: false, desc: "If WIP, process will always exit with exit code 0", hide: true + method_option :ignore_failures, type: :boolean, default: false, desc: "Process will always exit with exit code 0", hide: true method_option :pact_broker_username, aliases: "-u", desc: "Pact broker user name" method_option :pact_broker_password, aliases: "-w", desc: "Pact broker password" method_option :backtrace, aliases: "-b", desc: "Show full backtrace", :default => false, :type => :boolean diff --git a/lib/pact/cli/run_pact_verification.rb b/lib/pact/cli/run_pact_verification.rb index 1fdbaca1..97d32492 100644 --- a/lib/pact/cli/run_pact_verification.rb +++ b/lib/pact/cli/run_pact_verification.rb @@ -72,7 +72,7 @@ def pact_spec_options criteria: SpecCriteria.call(options), format: options[:format], out: options[:out], - wip: options[:wip] + ignore_failures: options[:ignore_failures] } end end diff --git a/lib/pact/provider/pact_spec_runner.rb b/lib/pact/provider/pact_spec_runner.rb index 2d6e887a..d1dbc4ec 100644 --- a/lib/pact/provider/pact_spec_runner.rb +++ b/lib/pact/provider/pact_spec_runner.rb @@ -91,7 +91,7 @@ def run_specs ::RSpec::Core::CommandLine.new(NoConfigurationOptions.new) .run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream) end - options[:wip] ? 0 : exit_code + options[:ignore_failures] ? 0 : exit_code end def rspec_runner_options @@ -120,7 +120,7 @@ def initialize_specs pact_sources.each do | pact_source | options = { criteria: @options[:criteria], - wip: @options[:wip] + ignore_failures: @options[:ignore_failures] } honour_pactfile pact_source.uri, ordered_pact_json(pact_source.pact_json), options end @@ -147,7 +147,7 @@ def configure_output ::RSpec.configuration.full_backtrace = @options[:full_backtrace] - ::RSpec.configuration.failure_color = :yellow if @options[:wip] + ::RSpec.configuration.failure_color = :yellow if @options[:ignore_failures] end def ordered_pact_json(pact_json) diff --git a/lib/pact/provider/rspec.rb b/lib/pact/provider/rspec.rb index 70616e43..d9883bef 100644 --- a/lib/pact/provider/rspec.rb +++ b/lib/pact/provider/rspec.rb @@ -21,7 +21,7 @@ module ClassMethods include ::RSpec::Core::DSL def honour_pactfile pact_uri, pact_json, options - pact_description = options[:wip] ? "WIP pact" : "pact" + pact_description = options[:ignore_failures] ? "Pending pact" : "pact" Pact.configuration.output_stream.puts "INFO: Reading #{pact_description} at #{pact_uri}" Pact.configuration.output_stream.puts "INFO: Filtering interactions by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any? consumer_contract = Pact::ConsumerContract.from_json(pact_json) @@ -74,7 +74,7 @@ def describe_interaction interaction, options pact_interaction: interaction, pact_interaction_example_description: interaction_description_for_rerun_command(interaction), pact_uri: options[:pact_uri], - pact_wip: options[:wip] + pact_ignore_failures: options[:ignore_failures] } describe description_for(interaction), metadata do diff --git a/lib/pact/provider/rspec/formatter_rspec_3.rb b/lib/pact/provider/rspec/formatter_rspec_3.rb index 0bcb9fd8..00a4ee62 100644 --- a/lib/pact/provider/rspec/formatter_rspec_3.rb +++ b/lib/pact/provider/rspec/formatter_rspec_3.rb @@ -42,12 +42,12 @@ def failed_interactions_count(summary) summary.failed_examples.collect{ |e| e.metadata[:pact_interaction_example_description] }.uniq.size end - def wip?(summary) - summary.failed_examples.any?{ |e| e.metadata[:pact_wip] } + def ignore_failures?(summary) + summary.failed_examples.any?{ |e| e.metadata[:pact_ignore_failures] } end def failure_title summary - if wip?(summary) + if ignore_failures?(summary) "#{failed_interactions_count(summary)} pending" else ::RSpec::Core::Formatters::Helpers.pluralize(failed_interactions_count(summary), "failure") @@ -69,7 +69,7 @@ def color_for_summary summary end def print_rerun_commands summary - if wip?(summary) + if ignore_failures?(summary) output.puts("\nPending interactions: (Failures listed here are expected and do not affect your suite's status)\n\n") else output.puts("\nFailed interactions:\n\n") diff --git a/lib/pact/tasks/task_helper.rb b/lib/pact/tasks/task_helper.rb index 0431afad..1daaab0a 100644 --- a/lib/pact/tasks/task_helper.rb +++ b/lib/pact/tasks/task_helper.rb @@ -28,7 +28,7 @@ def verify_command pact_helper, pact_uri, rspec_opts, verification_opts command_parts << "-S pact verify" command_parts << "--pact-helper" << Shellwords.escape(pact_helper.end_with?(".rb") ? pact_helper : pact_helper + ".rb") (command_parts << "--pact-uri" << pact_uri) if pact_uri - command_parts << "--wip" if verification_opts[:wip] + command_parts << "--ignore-failures" if verification_opts[:ignore_failures] command_parts << "--pact-broker-username" << ENV['PACT_BROKER_USERNAME'] if ENV['PACT_BROKER_USERNAME'] command_parts << "--pact-broker-password" << ENV['PACT_BROKER_PASSWORD'] if ENV['PACT_BROKER_PASSWORD'] command_parts << "--backtrace" if ENV['BACKTRACE'] == 'true' diff --git a/lib/pact/tasks/verification_task.rb b/lib/pact/tasks/verification_task.rb index e328cbf9..644abf4d 100644 --- a/lib/pact/tasks/verification_task.rb +++ b/lib/pact/tasks/verification_task.rb @@ -30,11 +30,11 @@ class VerificationTask < ::Rake::TaskLib attr_reader :pact_spec_configs attr_accessor :rspec_opts - attr_accessor :wip + attr_accessor :ignore_failures def initialize(name) @rspec_opts = nil - @wip = false + @ignore_failures = false @pact_spec_configs = [] @name = name yield self @@ -76,7 +76,7 @@ def rake_task require 'pact/tasks/task_helper' exit_statuses = pact_spec_configs.collect do | config | - Pact::TaskHelper.execute_pact_verify config[:uri], config[:pact_helper], rspec_opts, { wip: wip } + Pact::TaskHelper.execute_pact_verify config[:uri], config[:pact_helper], rspec_opts, { ignore_failures: ignore_failures } end Pact::TaskHelper.handle_verification_failure do diff --git a/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb b/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb index 7cb52d0e..643e3dc1 100644 --- a/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb +++ b/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb @@ -20,7 +20,7 @@ module RSpec pactfile_uri: pactfile_uri, pact_interaction_example_description: description, pact_json: pact_json, - pact_wip: wip + pact_ignore_failures: ignore_failures } end let(:metadata_2) { metadata.merge(pact_interaction_example_description: 'another interaction')} @@ -34,7 +34,7 @@ module RSpec let(:summary) { double("summary", failure_count: 1, failed_examples: failed_examples, examples: examples)} let(:pact_executing_language) { 'ruby' } let(:pact_interaction_rerun_command) { Pact::TaskHelper::PACT_INTERACTION_RERUN_COMMAND } - let(:wip) { nil } + let(:ignore_failures) { nil } subject { Formatter.new output } @@ -105,8 +105,8 @@ module RSpec end end - context "when wip is true" do - let(:wip) { true } + context "when ignore_failures is true" do + let(:ignore_failures) { true } it "reports failures as pending" do expect(output_result).to include("1 pending") diff --git a/spec/lib/pact/tasks/task_helper_spec.rb b/spec/lib/pact/tasks/task_helper_spec.rb index 385fe6f5..8ed2a10b 100644 --- a/spec/lib/pact/tasks/task_helper_spec.rb +++ b/spec/lib/pact/tasks/task_helper_spec.rb @@ -8,8 +8,8 @@ module Pact let(:ruby_path) { "/path/to/ruby" } let(:pact_uri) { "/pact/uri" } let(:default_pact_helper_path) { "/pact/helper/path.rb" } - let(:verification_options) { { wip: wip } } - let(:wip) { nil } + let(:verification_options) { { ignore_failures: ignore_failures } } + let(:ignore_failures) { nil } before do stub_const("FileUtils::RUBY", ruby_path) @@ -119,10 +119,10 @@ module Pact end end - context "with wip: true" do - let(:wip) { true } - it "executes the command with --wip" do - expect(TaskHelper).to receive(:execute_cmd).with(/ --wip\b/) + context "with ignore_failures: true" do + let(:ignore_failures) { true } + it "executes the command with --ignore-failures" do + expect(TaskHelper).to receive(:execute_cmd).with(/ --ignore-failures\b/) TaskHelper.execute_pact_verify(pact_uri, nil, nil, verification_options) end end diff --git a/spec/lib/pact/tasks/verification_task_spec.rb b/spec/lib/pact/tasks/verification_task_spec.rb index d86520c6..5ec6a2ec 100644 --- a/spec/lib/pact/tasks/verification_task_spec.rb +++ b/spec/lib/pact/tasks/verification_task_spec.rb @@ -9,7 +9,7 @@ module Pact @pact_uri = 'http://example.org/pact.json' @task_name = 'pact:verify:pact_rake_spec' @task_name_with_explict_pact_helper = 'pact:verify:pact_rake_spec_with_explict_pact_helper' - @task_name_wip = 'pact:verify:pact_rake_spec_wip' + @task_name_ignore_failures = 'pact:verify:pact_rake_spec_ignore_failures' @consumer = 'some-consumer' @criteria = {:description => /wiffle/} @@ -21,9 +21,9 @@ module Pact pact.uri @pact_uri end - VerificationTask.new(:pact_rake_spec_wip) do | pact | + VerificationTask.new(:pact_rake_spec_ignore_failures) do | pact | pact.uri @pact_uri - pact.wip = true + pact.ignore_failures = true end end @@ -47,7 +47,7 @@ module Pact describe 'execute' do context "with no explicit pact_helper" do it 'verifies the pacts using the TaskHelper' do - expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, nil, nil, { wip: false }) + expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, nil, nil, { ignore_failures: false }) Rake::Task[@task_name].execute end end @@ -55,15 +55,15 @@ module Pact context "with an explict pact_helper" do let(:verification_config) { [ uri: @pact_uri, pact_helper: @pact_helper] } it 'verifies the pacts using specified pact_helper' do - expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, @pact_helper, nil, { wip: false }) + expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, @pact_helper, nil, { ignore_failures: false }) Rake::Task[@task_name_with_explict_pact_helper].execute end end - context "with wip: true" do - it 'verifies the pacts with wip: true' do - expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, anything, anything, { wip: true }) - Rake::Task[@task_name_wip].execute + context "with ignore_failures: true" do + it 'verifies the pacts with ignore_failures: true' do + expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, anything, anything, { ignore_failures: true }) + Rake::Task[@task_name_ignore_failures].execute end end diff --git a/tasks/foo-bar.rake b/tasks/foo-bar.rake index fd9fc70e..87d4e5db 100644 --- a/tasks/foo-bar.rake +++ b/tasks/foo-bar.rake @@ -31,7 +31,7 @@ end Pact::VerificationTask.new('foobar:wip') do | pact | pact.uri './spec/pacts/foo-bar-wip.json', pact_helper: './spec/support/bar_pact_helper.rb' - pact.wip = true + pact.ignore_failures = true end Pact::VerificationTask.new(:foobar_using_broker) do | pact | diff --git a/tasks/pact-test.rake b/tasks/pact-test.rake index 415afc46..21126b91 100644 --- a/tasks/pact-test.rake +++ b/tasks/pact-test.rake @@ -55,7 +55,7 @@ end Pact::VerificationTask.new('test_app:wip') do | pact | pact.uri './spec/support/test_app_fail.json', pact_helper: './spec/support/pact_helper.rb' - pact.wip = true + pact.ignore_failures = true end