Sha256: 800d376ac369b8a6511e04d06d99b30ea6a4e594f2768b0db3338d7cf9ad94d6

Contents?: true

Size: 913 Bytes

Versions: 4

Compression:

Stored size: 913 Bytes

Contents

module Pact
  module Provider
    module PactHelperLocater
      PACT_HELPER_FILE_PATTERNS = [
        "spec/**/*service*consumer*/pact_helper.rb",
        "spec/**/*consumer*/pact_helper.rb",
        "spec/**/pact_helper.rb",
        "test/**/*service*consumer*/pact_helper.rb",
        "test/**/*consumer*/pact_helper.rb",
        "test/**/pact_helper.rb",
        "**/pact_helper.rb"
      ]

      NO_PACT_HELPER_FOUND_MSG = "Please create a pact_helper.rb file that can be found using one of the following patterns: #{PACT_HELPER_FILE_PATTERNS.join(", ")}"

      def self.pact_helper_path
        pact_helper_search_results = []
        PACT_HELPER_FILE_PATTERNS.find { | pattern | (pact_helper_search_results.concat(Dir.glob(pattern))).any? }
        raise NO_PACT_HELPER_FOUND_MSG if pact_helper_search_results.empty?
        File.join(Dir.pwd, pact_helper_search_results[0])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-1.42.2 lib/pact/provider/pact_helper_locator.rb
pact-1.42.1 lib/pact/provider/pact_helper_locator.rb
pact-1.42.0 lib/pact/provider/pact_helper_locator.rb
pact-1.41.2 lib/pact/provider/pact_helper_locator.rb