Sha256: ed5ac361715cbcbc237658e9b6173243984e225a3abf095df97ab8a5047e99ab

Contents?: true

Size: 835 Bytes

Versions: 2

Compression:

Stored size: 835 Bytes

Contents

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

module Pact
  module TaskHelper

    extend self

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

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

    def verify_command pact_helper, pact_uri = nil
      command_parts = []
      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

2 entries across 2 versions & 1 rubygems

Version Path
pact-1.2.1.rc1 lib/pact/tasks/task_helper.rb
pact-1.1.1 lib/pact/tasks/task_helper.rb