3
require File.dirname(__FILE__) + '/../../../spec_helper'
4
require 'puppet/file_serving/mount/plugins'
6
describe Puppet::FileServing::Mount::Plugins do
8
@mount = Puppet::FileServing::Mount::Plugins.new("plugins")
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 modules" do
16
@environment.expects(:modules).returns []
18
@mount.find("foo", @request)
21
it "should return nil if no module can be found with a matching plugin" do
23
mod.stubs(:plugin).with("foo/bar").returns nil
25
@environment.stubs(:modules).returns [mod]
26
@mount.find("foo/bar", @request).should be_nil
29
it "should return the file path from the module" do
31
mod.stubs(:plugin).with("foo/bar").returns "eh"
33
@environment.stubs(:modules).returns [mod]
34
@mount.find("foo/bar", @request).should == "eh"
38
describe "when searching for files" do
39
it "should use the node's environment to find the modules" do
40
@environment.expects(:modules).returns []
42
@mount.search("foo", @request)
45
it "should return nil if no modules can be found that have plugins" do
47
mod.stubs(:plugins?).returns false
49
@environment.stubs(:modules).returns []
50
@mount.search("foo/bar", @request).should be_nil
53
it "should return the plugin paths for each module that has plugins" do
54
one = stub 'module', :plugins? => true, :plugin_directory => "/one"
55
two = stub 'module', :plugins? => true, :plugin_directory => "/two"
57
@environment.stubs(:modules).returns [one, two]
58
@mount.search("foo/bar", @request).should == %w{/one /two}