File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
lib/puppet/file_serving/mount
spec/unit/file_serving/mount Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 5
5
class Puppet ::FileServing ::Mount ::Modules < Puppet ::FileServing ::Mount
6
6
# Return an instance of the appropriate class.
7
7
def find ( path , request )
8
+ raise "No module specified" if path . to_s . empty?
8
9
module_name , relative_path = path . split ( "/" , 2 )
9
10
return nil unless mod = request . environment . module ( module_name )
10
11
11
12
mod . file ( relative_path )
12
13
end
13
14
14
15
def search ( path , request )
15
- module_name , relative_path = path . split ( "/" , 2 )
16
- return nil unless mod = request . environment . module ( module_name )
17
-
18
- return nil unless path = mod . file ( relative_path )
19
- [ path ]
16
+ if result = find ( path , request )
17
+ [ result ]
18
+ end
20
19
end
21
20
22
21
def valid?
Original file line number Diff line number Diff line change 12
12
end
13
13
14
14
describe "when finding files" do
15
+ it "should fail if no module is specified" do
16
+ expect { @mount . find ( "" , @request ) } . to raise_error ( /No module specified/ )
17
+ end
18
+
15
19
it "should use the provided environment to find the module" do
16
20
@environment . expects ( :module )
17
21
37
41
end
38
42
39
43
describe "when searching for files" do
44
+ it "should fail if no module is specified" do
45
+ expect { @mount . find ( "" , @request ) } . to raise_error ( /No module specified/ )
46
+ end
47
+
40
48
it "should use the node's environment to search the module" do
41
49
@environment . expects ( :module )
42
50
You can’t perform that action at this time.
0 commit comments