~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to spec/integration/file_serving/configuration.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
#
 
3
#  Created by Luke Kanies on 2007-10-18.
 
4
#  Copyright (c) 2007. All rights reserved.
 
5
 
 
6
require File.dirname(__FILE__) + '/../../spec_helper'
 
7
 
 
8
require 'puppet/file_serving/configuration'
 
9
 
 
10
describe Puppet::FileServing::Configuration, " when finding files with Puppet::FileServing::Mount" do
 
11
    before do
 
12
        # Just in case it already exists.
 
13
        Puppet::FileServing::Configuration.clear_cache
 
14
 
 
15
        @mount = Puppet::FileServing::Mount.new("mymount")
 
16
        FileTest.stubs(:exists?).with("/my/path").returns(true)
 
17
        FileTest.stubs(:readable?).with("/my/path").returns(true)
 
18
        FileTest.stubs(:directory?).with("/my/path").returns(true)
 
19
        @mount.path = "/my/path"
 
20
 
 
21
        FileTest.stubs(:exists?).with(Puppet[:fileserverconfig]).returns(true)
 
22
        @parser = mock 'parser'
 
23
        @parser.stubs(:parse).returns("mymount" => @mount)
 
24
        @parser.stubs(:changed?).returns(true)
 
25
        Puppet::FileServing::Configuration::Parser.stubs(:new).returns(@parser)
 
26
 
 
27
        @config = Puppet::FileServing::Configuration.create
 
28
    end
 
29
 
 
30
    it "should return nil if the file does not exist" do
 
31
        FileTest.expects(:exists?).with("/my/path/my/file").returns(false)
 
32
        @config.file_path("/mymount/my/file").should be_nil
 
33
    end
 
34
 
 
35
    it "should return the full file path if the file exists" do
 
36
        FileTest.expects(:exists?).with("/my/path/my/file").returns(true)
 
37
        @config.file_path("/mymount/my/file").should == "/my/path/my/file"
 
38
    end
 
39
 
 
40
    after do
 
41
        Puppet::FileServing::Configuration.clear_cache
 
42
    end
 
43
end