~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to spec/unit/file_serving/mount/plugins.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../../spec_helper'
 
4
require 'puppet/file_serving/mount/plugins'
 
5
 
 
6
describe Puppet::FileServing::Mount::Plugins do
 
7
    before do
 
8
        @mount = Puppet::FileServing::Mount::Plugins.new("plugins")
 
9
 
 
10
        @environment = stub 'environment', :module => nil
 
11
        @request = stub 'request', :environment => @environment
 
12
    end
 
13
 
 
14
    describe  "when finding files" do
 
15
        it "should use the provided environment to find the modules" do
 
16
            @environment.expects(:modules).returns []
 
17
 
 
18
            @mount.find("foo", @request)
 
19
        end
 
20
 
 
21
        it "should return nil if no module can be found with a matching plugin" do
 
22
            mod = mock 'module'
 
23
            mod.stubs(:plugin).with("foo/bar").returns nil
 
24
 
 
25
            @environment.stubs(:modules).returns [mod]
 
26
            @mount.find("foo/bar", @request).should be_nil
 
27
        end
 
28
 
 
29
        it "should return the file path from the module" do
 
30
            mod = mock 'module'
 
31
            mod.stubs(:plugin).with("foo/bar").returns "eh"
 
32
 
 
33
            @environment.stubs(:modules).returns [mod]
 
34
            @mount.find("foo/bar", @request).should == "eh"
 
35
        end
 
36
    end
 
37
 
 
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 []
 
41
 
 
42
            @mount.search("foo", @request)
 
43
        end
 
44
 
 
45
        it "should return nil if no modules can be found that have plugins" do
 
46
            mod = mock 'module'
 
47
            mod.stubs(:plugins?).returns false
 
48
 
 
49
            @environment.stubs(:modules).returns []
 
50
            @mount.search("foo/bar", @request).should be_nil
 
51
        end
 
52
 
 
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"
 
56
 
 
57
            @environment.stubs(:modules).returns [one, two]
 
58
            @mount.search("foo/bar", @request).should == %w{/one /two}
 
59
        end
 
60
    end
 
61
end