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

« back to all changes in this revision

Viewing changes to spec/unit/file_serving/mount/modules.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/modules'
 
5
 
 
6
describe Puppet::FileServing::Mount::Modules do
 
7
    before do
 
8
        @mount = Puppet::FileServing::Mount::Modules.new("modules")
 
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 module" do
 
16
            @environment.expects(:module)
 
17
 
 
18
            @mount.find("foo", @request)
 
19
        end
 
20
 
 
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)
 
24
        end
 
25
 
 
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)
 
29
        end
 
30
 
 
31
        it "should return the file path from the module" do
 
32
            mod = mock 'module'
 
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"
 
36
        end
 
37
    end
 
38
 
 
39
    describe "when searching for files" do
 
40
        it "should use the node's environment to search the module" do
 
41
            @environment.expects(:module)
 
42
 
 
43
            @mount.search("foo", @request)
 
44
        end
 
45
 
 
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)
 
49
        end
 
50
 
 
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)
 
54
        end
 
55
 
 
56
        it "should return the file path as an array from the module" do
 
57
            mod = mock 'module'
 
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"]
 
61
        end
 
62
    end
 
63
end