diff --git a/lib/pact/provider/pact_helper_locator.rb b/lib/pact/provider/pact_helper_locator.rb index 43f48b5d..a1e0df89 100644 --- a/lib/pact/provider/pact_helper_locator.rb +++ b/lib/pact/provider/pact_helper_locator.rb @@ -1,21 +1,24 @@ module Pact module Provider module PactHelperLocater - PACT_HELPER_FILE_PATTERNS = [ + PACT_HELPER_FILE_PATTERNS = [ "spec/**/*service*consumer*/pact_helper.rb", "spec/**/*consumer*/pact_helper.rb", "spec/**/pact_helper.rb", - "**/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 + 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 diff --git a/spec/lib/pact/provider/pact_helper_locator_spec.rb b/spec/lib/pact/provider/pact_helper_locator_spec.rb index 7c39d8f9..72049a08 100644 --- a/spec/lib/pact/provider/pact_helper_locator_spec.rb +++ b/spec/lib/pact/provider/pact_helper_locator_spec.rb @@ -20,6 +20,12 @@ def make_pactfile dir '/spec/serviceconsumers', '/spec/consumer', '/spec', + '/test/blah/service-consumers', + '/test/consumers', + '/test/blah/service_consumers', + '/test/serviceconsumers', + '/test/consumer', + '/test', '/blah', '/blah/consumer', ''