Skip to content

Commit 746883d

Browse files
thatguysimonbethesque
thatguysimon
authored andcommitted
fix(pact_helper_locator): add 'test' dir to file patterns (pact-foundation#196)
1 parent bdb2561 commit 746883d

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

lib/pact/provider/pact_helper_locator.rb

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
module Pact
22
module Provider
33
module PactHelperLocater
4-
PACT_HELPER_FILE_PATTERNS = [
4+
PACT_HELPER_FILE_PATTERNS = [
55
"spec/**/*service*consumer*/pact_helper.rb",
66
"spec/**/*consumer*/pact_helper.rb",
77
"spec/**/pact_helper.rb",
8-
"**/pact_helper.rb"]
8+
"test/**/*service*consumer*/pact_helper.rb",
9+
"test/**/*consumer*/pact_helper.rb",
10+
"test/**/pact_helper.rb",
11+
"**/pact_helper.rb"
12+
]
913

10-
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(", ")}"
11-
12-
def self.pact_helper_path
13-
pact_helper_search_results = []
14-
PACT_HELPER_FILE_PATTERNS.find { | pattern | (pact_helper_search_results.concat(Dir.glob(pattern))).any? }
15-
raise NO_PACT_HELPER_FOUND_MSG if pact_helper_search_results.empty?
16-
File.join(Dir.pwd, pact_helper_search_results[0])
17-
end
14+
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(", ")}"
1815

16+
def self.pact_helper_path
17+
pact_helper_search_results = []
18+
PACT_HELPER_FILE_PATTERNS.find { | pattern | (pact_helper_search_results.concat(Dir.glob(pattern))).any? }
19+
raise NO_PACT_HELPER_FOUND_MSG if pact_helper_search_results.empty?
20+
File.join(Dir.pwd, pact_helper_search_results[0])
21+
end
1922
end
2023
end
2124
end

spec/lib/pact/provider/pact_helper_locator_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def make_pactfile dir
2020
'/spec/serviceconsumers',
2121
'/spec/consumer',
2222
'/spec',
23+
'/test/blah/service-consumers',
24+
'/test/consumers',
25+
'/test/blah/service_consumers',
26+
'/test/serviceconsumers',
27+
'/test/consumer',
28+
'/test',
2329
'/blah',
2430
'/blah/consumer',
2531
''

0 commit comments

Comments
 (0)