3
# Created by Luke Kanies on 2007-10-18.
4
# Copyright (c) 2007. All rights reserved.
6
require File.dirname(__FILE__) + '/../../spec_helper'
8
require 'puppet/file_serving/configuration'
10
describe Puppet::FileServing::Configuration, " when finding files with Puppet::FileServing::Mount" do
12
# Just in case it already exists.
13
Puppet::FileServing::Configuration.clear_cache
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"
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)
27
@config = Puppet::FileServing::Configuration.create
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
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"
41
Puppet::FileServing::Configuration.clear_cache