@@ -10,16 +10,17 @@ module Pact
10
10
module StubService
11
11
class CLI < Pact ::MockService ::CLI ::CustomThor
12
12
13
- desc 'PACT_URI ...' , "Start a stub service with the given pact file(s)."
13
+ desc 'PACT_URI ...' , "Start a stub service with the given pact file(s) or directory ."
14
14
long_desc <<-DOC
15
- Start a stub service with the given pact file(s). Pact URIs may be local file paths or HTTP.
15
+ Start a stub service with the given pact file(s) or directories. Pact URIs may be local
16
+ file or directory paths, or HTTP.
16
17
Include any basic auth details in the URL using the format https://USERNAME:PASSWORD@URI.
17
18
Where multiple matching interactions are found, the interactions will be sorted by
18
19
response status, and the first one will be returned. This may lead to some non-deterministic
19
20
behaviour. If you are having problems with this, please raise it on the pact-dev google group,
20
21
and we can discuss some potential enhancements.
21
22
Note that only versions 1 and 2 of the pact specification are currently fully supported.
22
- Pacts using the v3 format may be used, however, any matching features added in v4 will
23
+ Pacts using the v3 format may be used, however, any matching features added in v3 will
23
24
currently be ignored.
24
25
DOC
25
26
@@ -33,13 +34,16 @@ class CLI < Pact::MockService::CLI::CustomThor
33
34
method_option :stub_pactfile_paths , hide : true
34
35
method_option :monkeypatch , hide : true
35
36
36
- def service ( *pactfiles )
37
- raise Thor ::Error . new ( "Please provide an existing pact file to load" ) if pactfiles . empty?
37
+ def service ( *pact_files )
38
38
require 'pact/mock_service/run'
39
- options . stub_pactfile_paths = pactfiles
39
+ require 'pact/support/expand_file_list'
40
+
41
+ expanded_pact_files = file_list ( pact_files )
42
+ raise Thor ::Error . new ( "Please provide at least one pact file to load" ) if expanded_pact_files . empty?
43
+
40
44
opts = Thor ::CoreExt ::HashWithIndifferentAccess . new
41
45
opts . merge! ( options )
42
- opts [ :stub_pactfile_paths ] = pactfiles
46
+ opts [ :stub_pactfile_paths ] = expanded_pact_files
43
47
opts [ :pactfile_write_mode ] = 'none'
44
48
MockService ::Run . ( opts )
45
49
end
@@ -52,6 +56,12 @@ def version
52
56
end
53
57
54
58
default_task :service
59
+
60
+ no_commands do
61
+ def file_list ( pact_files )
62
+ Pact ::Support ::ExpandFileList . call ( pact_files )
63
+ end
64
+ end
55
65
end
56
66
end
57
67
end
0 commit comments