3
require File.dirname(__FILE__) + '/../../../spec_helper'
4
require 'puppet/file_serving/mount/modules'
6
describe Puppet::FileServing::Mount::Modules do
8
@mount = Puppet::FileServing::Mount::Modules.new("modules")
10
@environment = stub 'environment', :module => nil
11
@request = stub 'request', :environment => @environment
14
describe "when finding files" do
15
it "should use the provided environment to find the module" do
16
@environment.expects(:module)
18
@mount.find("foo", @request)
21
it "should treat the first field of the relative path as the module name" do
22
@environment.expects(:module).with("foo")
23
@mount.find("foo/bar/baz", @request)
26
it "should return nil if the specified module does not exist" do
27
@environment.expects(:module).with("foo").returns nil
28
@mount.find("foo/bar/baz", @request)
31
it "should return the file path from the module" do
33
mod.expects(:file).with("bar/baz").returns "eh"
34
@environment.expects(:module).with("foo").returns mod
35
@mount.find("foo/bar/baz", @request).should == "eh"
39
describe "when searching for files" do
40
it "should use the node's environment to search the module" do
41
@environment.expects(:module)
43
@mount.search("foo", @request)
46
it "should treat the first field of the relative path as the module name" do
47
@environment.expects(:module).with("foo")
48
@mount.search("foo/bar/baz", @request)
51
it "should return nil if the specified module does not exist" do
52
@environment.expects(:module).with("foo").returns nil
53
@mount.search("foo/bar/baz", @request)
56
it "should return the file path as an array from the module" do
58
mod.expects(:file).with("bar/baz").returns "eh"
59
@environment.expects(:module).with("foo").returns mod
60
@mount.search("foo/bar/baz", @request).should == ["eh"]