Module: Pact::Provider::PactHelperLocater

Defined in:
lib/pact/provider/pact_helper_locator.rb

Constant Summary collapse

PACT_HELPER_FILE_PATTERNS =
[
"spec/**/*service*consumer*/pact_helper.rb",
"spec/**/*consumer*/pact_helper.rb",
"spec/**/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(", ")}"

Class Method Summary collapse

Class Method Details

.pact_helper_pathObject



12
13
14
15
16
17
# File 'lib/pact/provider/pact_helper_locator.rb', line 12

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?
  "#{Dir.pwd}/#{pact_helper_search_results[0]}"
end