Sha256: 06615c922232338cda712cc28e9e20a85866f902e6e06e066b2fd216f122a217

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

require 'pact/provider/pact_helper_locator'
require 'rake/file_utils'
require 'shellwords'

module Pact
  module TaskHelper

    extend self

    def execute_pact_verify pact_uri = nil, pact_helper = nil, rspec_opts = nil
      execute_cmd verify_command(pact_helper || Pact::Provider::PactHelperLocater.pact_helper_path, pact_uri, rspec_opts)
    end

    def handle_verification_failure
      exit_status = yield
      abort if exit_status != 0
    end

    def verify_command pact_helper, pact_uri, rspec_opts
      command_parts = []
      # Clear SPEC_OPTS, otherwise we can get extra formatters, creating duplicate output eg. CI Reporting.
      # Allow deliberate configuration using rspec_opts in VerificationTask.
      command_parts << "SPEC_OPTS=#{Shellwords.escape(rspec_opts || '')}"
      command_parts << FileUtils::RUBY
      command_parts << "-S pact verify"
      command_parts << "-h" << (pact_helper.end_with?(".rb") ? pact_helper : pact_helper + ".rb")
      (command_parts << "-p" << pact_uri) if pact_uri
      command_parts.flatten.join(" ")
    end

    def execute_cmd command
      system(command) ? 0 : 1
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact-1.4.0 lib/pact/tasks/task_helper.rb
pact-1.4.0.rc4 lib/pact/tasks/task_helper.rb
pact-1.4.0.rc3 lib/pact/tasks/task_helper.rb
pact-1.4.0.rc2 lib/pact/tasks/task_helper.rb
pact-1.3.3 lib/pact/tasks/task_helper.rb
pact-1.3.2 lib/pact/tasks/task_helper.rb
pact-1.3.1 lib/pact/tasks/task_helper.rb
pact-1.3.0 lib/pact/tasks/task_helper.rb
pact-1.2.1.rc2 lib/pact/tasks/task_helper.rb