Sha256: 2df7149492f14cf39117114e0abc85ea2d3befc915f768accadedf678ff44e73

Contents?: true

Size: 898 Bytes

Versions: 21

Compression:

Stored size: 898 Bytes

Contents

module Pact
  module TaskHelper
    def failure_message
      redify(
        "\n* * * * * * * * * * * * * * * * * * *\n" +
        "Provider did not honour pact file.\nSee\n * #{Pact.configuration.log_path}\n * #{Pact.configuration.tmp_dir}\nfor logs and pact files." +
        "\n* * * * * * * * * * * * * * * * * * *\n\n"
      )
    end

    def redify string
      "\e[31m#{string}\e[m"
    end

    def handle_verification_failure
      exit_status = yield
      if exit_status != 0
        $stderr.puts failure_message
        fail
      end
    end

    def spec_criteria defaults = {description: nil, provider_state: nil}
      criteria = {}
      [:description, :provider_state].each  do | key |
        value = ENV.fetch("PACT_#{key.to_s.upcase}", defaults[key])
        criteria[key] = Regexp.new(value) unless value.nil?
      end
      criteria.any? ? criteria : nil
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pact-1.1.0.rc1 lib/pact/tasks/task_helper.rb
pact-1.0.37 lib/pact/tasks/task_helper.rb
pact-1.0.36 lib/pact/tasks/task_helper.rb
pact-1.0.35 lib/pact/tasks/task_helper.rb
pact-1.0.34 lib/pact/tasks/task_helper.rb
pact-1.0.33 lib/pact/tasks/task_helper.rb
pact-1.0.32 lib/pact/tasks/task_helper.rb
pact-1.0.31 lib/pact/tasks/task_helper.rb
pact-1.0.30 lib/pact/tasks/task_helper.rb
pact-1.0.29 lib/pact/tasks/task_helper.rb
pact-1.0.28 lib/pact/tasks/task_helper.rb
pact-1.0.27 lib/pact/tasks/task_helper.rb
pact-1.0.26 lib/pact/tasks/task_helper.rb
pact-1.0.25 lib/pact/tasks/task_helper.rb
pact-1.0.24 lib/pact/tasks/task_helper.rb
pact-1.0.23 lib/pact/tasks/task_helper.rb
pact-1.0.22 lib/pact/tasks/task_helper.rb
pact-1.0.21 lib/pact/tasks/task_helper.rb
pact-1.0.20 lib/pact/tasks/task_helper.rb
pact-1.0.19 lib/pact/tasks/task_helper.rb