1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#! /usr/bin/env ruby
shared_examples_for "a file_serving model" do
include PuppetSpec::Files
describe "#indirection" do
localpath = PuppetSpec::Files.make_absolute("/etc/sudoers")
localurl = "file://" + localpath
before :each do
# Never connect to the network, no matter what
described_class.indirection.terminus(:rest).class.any_instance.stubs(:find)
end
describe "when running the master application" do
before :each do
Puppet::Application[:master].setup_terminuses
end
{
localpath => :file_server,
localurl => :file_server,
"puppet:///modules/foo/bar" => :file_server,
"puppet://server/modules/foo/bar" => :file_server,
}.each do |key, terminus|
it "should use the #{terminus} terminus when requesting #{key.inspect}" do
described_class.indirection.terminus(terminus).class.any_instance.expects(:find)
described_class.indirection.find(key)
end
end
end
describe "when running the apply application" do
before :each do
Puppet[:default_file_terminus] = 'file_server'
end
{
localpath => :file,
localurl => :file,
"puppet:///modules/foo/bar" => :file_server,
"puppet://server/modules/foo/bar" => :rest,
}.each do |key, terminus|
it "should use the #{terminus} terminus when requesting #{key.inspect}" do
described_class.indirection.terminus(terminus).class.any_instance.expects(:find)
described_class.indirection.find(key)
end
end
end
describe "when running another application" do
before :each do
Puppet[:default_file_terminus] = 'rest'
end
{
localpath => :file,
localurl => :file,
"puppet:///modules/foo/bar" => :rest,
"puppet://server/modules/foo/bar" => :rest,
}.each do |key, terminus|
it "should use the #{terminus} terminus when requesting #{key.inspect}" do
described_class.indirection.terminus(terminus).class.any_instance.expects(:find)
described_class.indirection.find(key)
end
end
end
end
end
|