Skip to content

Commit

Permalink
fix(pact_helper_locator): add 'test' dir to file patterns (pact-found…
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguysimon authored and bethesque committed Sep 9, 2019
1 parent bdb2561 commit 746883d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/pact/provider/pact_helper_locator.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/pact/provider/pact_helper_locator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
''
Expand Down

0 comments on commit 746883d

Please sign in to comment.