diff options
168 files changed, 759 insertions, 467 deletions
diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index 3cb428e63..9398513e7 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -5,23 +5,23 @@ require 'puppet/indirector' require 'puppet/file_serving' require 'puppet/file_serving/file_base' -require 'puppet/file_serving/terminus_selector' +require 'puppet/file_serving/indirection_hooks' # A class that handles retrieving file contents. # It only reads the file when its content is specifically # asked for. class Puppet::FileServing::Content < Puppet::FileServing::FileBase extend Puppet::Indirector - indirects :file_content, :extend => Puppet::FileServing::TerminusSelector + indirects :file_content, :extend => Puppet::FileServing::IndirectionHooks attr_reader :path # Read the content of our file in. - def content(base = nil) + def content # This stat can raise an exception, too. - raise(ArgumentError, "Cannot read the contents of links unless following links") if stat(base).ftype == "symlink" + raise(ArgumentError, "Cannot read the contents of links unless following links") if stat().ftype == "symlink" - ::File.read(full_path(base)) + ::File.read(full_path()) end # Just return the file contents as the yaml. This allows us to diff --git a/lib/puppet/file_serving/file_base.rb b/lib/puppet/file_serving/file_base.rb index b2e9a0656..7f169d1ea 100644 --- a/lib/puppet/file_serving/file_base.rb +++ b/lib/puppet/file_serving/file_base.rb @@ -7,18 +7,19 @@ require 'puppet/file_serving' # The base class for Content and Metadata; provides common # functionality like the behaviour around links. class Puppet::FileServing::FileBase - attr_accessor :path, :base_path + attr_accessor :key - def full_path(base = nil) - base ||= base_path || raise(ArgumentError, "You must set or provide a base path") + # Return the full path to our file. Fails if there's no path set. + def full_path + raise(ArgumentError, "You must set a path to get a file's path") unless self.path - full = File.join(base, self.path) + relative_path ? File.join(path, relative_path) : path end - def initialize(path, options = {}) + def initialize(key, options = {}) raise ArgumentError.new("Files must not be fully qualified") if path =~ /^#{::File::SEPARATOR}/ - @path = path + @key = key @links = :manage options.each do |param, value| @@ -30,17 +31,33 @@ class Puppet::FileServing::FileBase end end + # Determine how we deal with links. attr_reader :links def links=(value) raise(ArgumentError, ":links can only be set to :manage or :follow") unless [:manage, :follow].include?(value) @links = value end + # Set our base path. + attr_reader :path + def path=(path) + raise ArgumentError.new("Paths must be fully qualified") unless path =~ /^#{::File::SEPARATOR}/ + @path = path + end + + # Set a relative path; this is used for recursion, and sets + # the file's path relative to the initial recursion point. + attr_reader :relative_path + def relative_path=(path) + raise ArgumentError.new("Relative paths must not be fully qualified") if path =~ /^#{::File::SEPARATOR}/ + @relative_path = path + end + # Stat our file, using the appropriate link-sensitive method. - def stat(base = nil) + def stat unless defined?(@stat_method) @stat_method = self.links == :manage ? :lstat : :stat end - File.send(@stat_method, full_path(base)) + File.send(@stat_method, full_path()) end end diff --git a/lib/puppet/file_serving/terminus_selector.rb b/lib/puppet/file_serving/indirection_hooks.rb index 06b53ddb1..141642efe 100644 --- a/lib/puppet/file_serving/terminus_selector.rb +++ b/lib/puppet/file_serving/indirection_hooks.rb @@ -8,7 +8,7 @@ require 'puppet/file_serving' # This module is used to pick the appropriate terminus # in file-serving indirections. This is necessary because # the terminus varies based on the URI asked for. -module Puppet::FileServing::TerminusSelector +module Puppet::FileServing::IndirectionHooks PROTOCOL_MAP = {"puppet" => :rest, "file" => :file, "puppetmounts" => :file_server} # Pick an appropriate terminus based on the protocol. diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 62ebccca9..e26e75844 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -7,14 +7,24 @@ require 'puppet/indirector' require 'puppet/file_serving' require 'puppet/file_serving/file_base' require 'puppet/util/checksums' -require 'puppet/file_serving/terminus_selector' +require 'puppet/file_serving/indirection_hooks' # A class that handles retrieving file metadata. class Puppet::FileServing::Metadata < Puppet::FileServing::FileBase + module MetadataHelper + include Puppet::FileServing::IndirectionHooks + + def post_find(instance) + end + + def post_search(key, options = {}) + end + end + include Puppet::Util::Checksums extend Puppet::Indirector - indirects :file_metadata, :extend => Puppet::FileServing::TerminusSelector + indirects :file_metadata, :extend => Puppet::FileServing::IndirectionHooks attr_reader :path, :owner, :group, :mode, :checksum_type, :checksum, :ftype, :destination @@ -27,9 +37,9 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::FileBase # Retrieve the attributes for this file, relative to a base directory. # Note that File.stat raises Errno::ENOENT if the file is absent and this # method does not catch that exception. - def collect_attributes(base = nil) - real_path = full_path(base) - stat = stat(base) + def collect_attributes + real_path = full_path() + stat = stat() @owner = stat.uid @group = stat.gid @ftype = stat.ftype diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb index 9542cbf84..d465aa493 100644 --- a/lib/puppet/file_serving/terminus_helper.rb +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -8,8 +8,12 @@ require 'puppet/file_serving/fileset' # Define some common methods for FileServing termini. module Puppet::FileServing::TerminusHelper # Create model instances for all files in a fileset. - def path2instances(path, options = {}) + def path2instances(key, path, options = {}) args = [:links, :ignore, :recurse].inject({}) { |hash, param| hash[param] = options[param] if options[param]; hash } - Puppet::FileServing::Fileset.new(path, args).files.collect { |file| model.new(file) } + Puppet::FileServing::Fileset.new(path, args).files.collect do |file| + inst = model.new(File.join(key, file), :path => path, :relative_path => file) + inst.links = options[:links] if options[:links] + inst + end end end diff --git a/lib/puppet/indirector/direct_file_server.rb b/lib/puppet/indirector/direct_file_server.rb new file mode 100644 index 000000000..31cc9aa16 --- /dev/null +++ b/lib/puppet/indirector/direct_file_server.rb @@ -0,0 +1,27 @@ +# +# Created by Luke Kanies on 2007-10-24. +# Copyright (c) 2007. All rights reserved. + +require 'puppet/file_serving/terminus_helper' +require 'puppet/util/uri_helper' +require 'puppet/indirector/terminus' + +class Puppet::Indirector::DirectFileServer < Puppet::Indirector::Terminus + + include Puppet::Util::URIHelper + include Puppet::FileServing::TerminusHelper + + def find(key, options = {}) + uri = key2uri(key) + return nil unless FileTest.exists?(uri.path) + instance = model.new(key, :path => uri.path) + instance.links = options[:links] if options[:links] + return instance + end + + def search(key, options = {}) + uri = key2uri(key) + return nil unless FileTest.exists?(uri.path) + path2instances(key, uri.path, options) + end +end diff --git a/lib/puppet/indirector/file_content/file.rb b/lib/puppet/indirector/file_content/file.rb index 4503a7919..30c79583c 100644 --- a/lib/puppet/indirector/file_content/file.rb +++ b/lib/puppet/indirector/file_content/file.rb @@ -3,26 +3,9 @@ # Copyright (c) 2007. All rights reserved. require 'puppet/file_serving/content' -require 'puppet/file_serving/terminus_helper' -require 'puppet/util/uri_helper' require 'puppet/indirector/file_content' -require 'puppet/indirector/file' +require 'puppet/indirector/direct_file_server' -class Puppet::Indirector::FileContent::File < Puppet::Indirector::File +class Puppet::Indirector::FileContent::File < Puppet::Indirector::DirectFileServer desc "Retrieve file contents from disk." - - include Puppet::Util::URIHelper - include Puppet::FileServing::TerminusHelper - - def find(key, options = {}) - uri = key2uri(key) - return nil unless FileTest.exists?(uri.path) - model.new(uri.path, :links => options[:links]) - end - - def search(key, options = {}) - uri = key2uri(key) - return nil unless FileTest.exists?(uri.path) - path2instances(uri.path, options) - end end diff --git a/lib/puppet/indirector/file_metadata/file.rb b/lib/puppet/indirector/file_metadata/file.rb index 823c26c36..b36846bbe 100644 --- a/lib/puppet/indirector/file_metadata/file.rb +++ b/lib/puppet/indirector/file_metadata/file.rb @@ -3,30 +3,24 @@ # Copyright (c) 2007. All rights reserved. require 'puppet/file_serving/metadata' -require 'puppet/file_serving/terminus_helper' require 'puppet/indirector/file_metadata' -require 'puppet/util/uri_helper' -require 'puppet/indirector/code' +require 'puppet/indirector/direct_file_server' -class Puppet::Indirector::FileMetadata::File < Puppet::Indirector::Code +class Puppet::Indirector::FileMetadata::File < Puppet::Indirector::DirectFileServer desc "Retrieve file metadata directly from the local filesystem." - include Puppet::Util::URIHelper - include Puppet::FileServing::TerminusHelper - def find(key, options = {}) - uri = key2uri(key) - - return nil unless FileTest.exists?(uri.path) - data = model.new(uri.path, :links => options[:links]) + return unless data = super data.collect_attributes return data end def search(key, options = {}) - uri = key2uri(key) - return nil unless FileTest.exists?(uri.path) - path2instances(uri.path, options).each { |instance| instance.collect_attributes } + return unless result = super + + result.each { |instance| instance.collect_attributes } + + return result end end diff --git a/lib/puppet/indirector/file_metadata/modules.rb b/lib/puppet/indirector/file_metadata/modules.rb index 739c40fca..5ed7a8a45 100644 --- a/lib/puppet/indirector/file_metadata/modules.rb +++ b/lib/puppet/indirector/file_metadata/modules.rb @@ -11,7 +11,7 @@ class Puppet::Indirector::FileMetadata::Modules < Puppet::Indirector::ModuleFile def find(*args) return unless instance = super - instance.get_attributes + instance.collect_attributes instance end end diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index de88bdc18..2eb323d46 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -25,7 +25,9 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus # Find our key using the fileserver. def find(key, options = {}) return nil unless path = find_path(key, options) - return model.new(path, :links => options[:links]) + result = model.new(key, :path => path) + result.links = options[:links] if options[:links] + return result end # Search for files. This returns an array rather than a single @@ -33,7 +35,7 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus def search(key, options = {}) return nil unless path = find_path(key, options) - path2instances(path, options) + path2instances(key, path, options) end private diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 2bf754198..816b4ffc5 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -117,6 +117,8 @@ class Puppet::Indirector::Indirection terminus_name = terminus_class end + check_authorization(:find, terminus_name, ([key] + args)) + # See if our instance is in the cache and up to date. if cache? and cache.has_most_recent?(key, terminus(terminus_name).version(key)) Puppet.info "Using cached %s %s" % [self.name, key] @@ -130,20 +132,33 @@ class Puppet::Indirector::Indirection Puppet.info "Caching %s %s" % [self.name, key] cache.save(result, *args) end + + terminus(terminus_name).post_find(result) if terminus(terminus_name).respond_to?(:post_find) + return result end end def destroy(*args) + check_authorization(:destroy, terminus_class, args) + terminus.destroy(*args) end def search(*args) - terminus.search(*args) + check_authorization(:search, terminus_class, args) + + result = terminus.search(*args) + + terminus().post_search(result) if terminus().respond_to?(:post_search) + + result end # these become instance methods def save(instance, *args) + check_authorization(:save, terminus_class, ([instance] + args)) + instance.version ||= Time.now.utc dest = cache? ? cache : terminus return if dest.has_most_recent?(instance.name, instance.version) @@ -158,6 +173,18 @@ class Puppet::Indirector::Indirection private + # Check authorization if there's a hook available; fail if there is one + # and it returns false. + def check_authorization(method, terminus_name, arguments) + # Don't check authorization if there's no node. + # LAK:FIXME This is a hack and is quite possibly not the design we want. + return unless arguments[-1].is_a?(Hash) and arguments[-1][:node] + + if terminus(terminus_name).respond_to?(:authorized?) and ! terminus(terminus_name).authorized?(method, *arguments) + raise ArgumentError, "Not authorized to call %s with %s" % [method, arguments[0]] + end + end + # Create a new terminus instance. def make_terminus(terminus_class) # Load our terminus class. diff --git a/lib/puppet/indirector/module_files.rb b/lib/puppet/indirector/module_files.rb index 12794e4c7..c79fae57b 100644 --- a/lib/puppet/indirector/module_files.rb +++ b/lib/puppet/indirector/module_files.rb @@ -30,7 +30,9 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus def find(key, options = {}) return nil unless path = find_path(key, options) - return model.new(path, :links => options[:links]) + result = model.new(key, :path => path) + result.links = options[:links] if options[:links] + return result end # Try to find our module. @@ -41,7 +43,7 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus # Search for a list of files. def search(key, options = {}) return nil unless path = find_path(key, options) - path2instances(path, options) + path2instances(key, path, options) end private diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 2b3df1ae7..f0a805525 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -618,7 +618,6 @@ module Puppet # than this last bit, so it doesn't really make sense. if child = configuration.resource(:file, path) unless child.parent.object_id == self.object_id - puts("Parent is %s, I am %s" % [child.parent.ref, self.ref]) if child.parent self.debug "Not managing more explicit file %s" % path return nil diff --git a/spec/integration/indirector/direct_file_server.rb b/spec/integration/indirector/direct_file_server.rb new file mode 100755 index 000000000..383486986 --- /dev/null +++ b/spec/integration/indirector/direct_file_server.rb @@ -0,0 +1,78 @@ +#!/usr/bin/env ruby +# +# Created by Luke Kanies on 2007-10-19. +# Copyright (c) 2007. All rights reserved. + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/indirector/file_content/file' +require 'puppet/indirector/module_files' + +describe Puppet::Indirector::DirectFileServer, " when interacting with the filesystem and the model" do + before do + # We just test a subclass, since it's close enough. + @terminus = Puppet::Indirector::FileContent::File.new + + @filepath = "/path/to/my/file" + end + + it "should return an instance of the model" do + FileTest.expects(:exists?).with(@filepath).returns(true) + + @terminus.find("file://host#{@filepath}").should be_instance_of(Puppet::FileServing::Content) + end + + it "should return an instance capable of returning its content" do + FileTest.expects(:exists?).with(@filepath).returns(true) + File.stubs(:lstat).with(@filepath).returns(stub("stat", :ftype => "file")) + File.expects(:read).with(@filepath).returns("my content") + + instance = @terminus.find("file://host#{@filepath}") + + instance.content.should == "my content" + end +end + +describe Puppet::Indirector::DirectFileServer, " when interacting with FileServing::Fileset and the model" do + before do + @terminus = Puppet::Indirector::FileContent::File.new + + @filepath = "/my/file" + FileTest.stubs(:exists?).with(@filepath).returns(true) + + stat = stub 'stat', :directory? => true + File.stubs(:lstat).with(@filepath).returns(stat) + + @subfiles = %w{one two} + @subfiles.each do |f| + path = File.join(@filepath, f) + FileTest.stubs(:exists?).with(@path).returns(true) + end + + Dir.expects(:entries).with(@filepath).returns @subfiles + end + + it "should return an instance for every file in the fileset" do + result = @terminus.search("file:///my/file", :recurse => true) + result.should be_instance_of(Array) + result.length.should == 3 + result.each { |r| r.should be_instance_of(Puppet::FileServing::Content) } + end + + it "should return instances capable of returning their content" do + @subfiles.each do |name| + File.stubs(:lstat).with(File.join(@filepath, name)).returns stub("#{name} stat", :ftype => "file", :directory? => false) + File.expects(:read).with(File.join(@filepath, name)).returns("#{name} content") + end + + @terminus.search("file:///my/file", :recurse => true).each do |instance| + case instance.key + when /one/: instance.content.should == "one content" + when /two/: instance.content.should == "two content" + when /\.$/: + else + raise "No valid key for %s" % instance.key.inspect + end + end + end +end diff --git a/spec/integration/indirector/module_files.rb b/spec/integration/indirector/module_files.rb index 3725a1286..3f49ec7fa 100755 --- a/spec/integration/indirector/module_files.rb +++ b/spec/integration/indirector/module_files.rb @@ -5,13 +5,13 @@ require File.dirname(__FILE__) + '/../../spec_helper' -require 'puppet/indirector/file_metadata/modules' +require 'puppet/indirector/file_content/modules' require 'puppet/indirector/module_files' -describe Puppet::Indirector::ModuleFiles, " when interacting with Puppet::Module" do +describe Puppet::Indirector::ModuleFiles, " when interacting with Puppet::Module and FileServing::Content" do it "should look for files in the module's 'files' directory" do # We just test a subclass, since it's close enough. - @terminus = Puppet::Indirector::FileMetadata::Modules.new + @terminus = Puppet::Indirector::FileContent::Modules.new @module = Puppet::Module.new("mymod", "/some/path/mymod") Puppet::Module.expects(:find).with("mymod", nil).returns(@module) @@ -19,8 +19,33 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with Puppet::Module FileTest.expects(:exists?).with(filepath).returns(true) - @terminus.model.expects(:new).with(filepath, :links => nil) + @terminus.find("puppetmounts://host/modules/mymod/myfile").should be_instance_of(Puppet::FileServing::Content) + end +end + +describe Puppet::Indirector::ModuleFiles, " when interacting with FileServing::Fileset and FileServing::Content" do + it "should return an instance for every file in the fileset" do + @terminus = Puppet::Indirector::FileContent::Modules.new + @module = Puppet::Module.new("mymod", "/some/path/mymod") + Puppet::Module.expects(:find).with("mymod", nil).returns(@module) + + filepath = "/some/path/mymod/files/myfile" + FileTest.stubs(:exists?).with(filepath).returns(true) + + stat = stub 'stat', :directory? => true + File.stubs(:lstat).with(filepath).returns(stat) + + subfiles = %w{one two} + subfiles.each do |f| + path = File.join(filepath, f) + FileTest.stubs(:exists?).with(path).returns(true) + end + + Dir.expects(:entries).with(filepath).returns(%w{one two}) - @terminus.find("puppetmounts://host/modules/mymod/myfile") + result = @terminus.search("puppetmounts://host/modules/mymod/myfile", :recurse => true) + result.should be_instance_of(Array) + result.length.should == 3 + result.each { |r| r.should be_instance_of(Puppet::FileServing::Content) } end end diff --git a/spec/lib/shared_behaviours/file_server_terminus.rb b/spec/lib/shared_behaviours/file_server_terminus.rb index e1ec35251..de08f29fc 100644 --- a/spec/lib/shared_behaviours/file_server_terminus.rb +++ b/spec/lib/shared_behaviours/file_server_terminus.rb @@ -32,10 +32,9 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do path = "/my/mount/path/my/file" FileTest.stubs(:exists?).with(path).returns(true) - @test_class.expects(:new).with(path, :links => nil).returns(:myinstance) FileTest.stubs(:exists?).with("/my/mount/path").returns(true) @mount1.expects(:file).with("my/file", :node => nil).returns(path) - @terminus.find("puppetmounts://myhost/one/my/file").should == :myinstance + @terminus.find("puppetmounts://myhost/one/my/file").should be_instance_of(@test_class) end end diff --git a/spec/lib/shared_behaviours/file_serving.rb b/spec/lib/shared_behaviours/file_serving.rb index 6eaec6850..a5e80f89b 100644 --- a/spec/lib/shared_behaviours/file_serving.rb +++ b/spec/lib/shared_behaviours/file_serving.rb @@ -27,12 +27,14 @@ describe "Puppet::FileServing::Files", :shared => true do Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever") Puppet.settings.stubs(:value).with(:environment).returns("") @indirection.terminus(:file_server).expects(:find).with(uri) + @indirection.terminus(:file_server).stubs(:authorized?).returns(true) @test_class.find(uri) end it "should use the file_server terminus when the 'puppetmounts' URI scheme is used" do uri = "puppetmounts:///mymod/my/file" @indirection.terminus(:file_server).expects(:find).with(uri) + @indirection.terminus(:file_server).stubs(:authorized?).returns(true) @test_class.find(uri) end diff --git a/spec/unit/file_serving/content.rb b/spec/unit/file_serving/content.rb index e15aa8be6..89d786295 100755 --- a/spec/unit/file_serving/content.rb +++ b/spec/unit/file_serving/content.rb @@ -13,84 +13,48 @@ describe Puppet::FileServing::Content do Puppet::FileServing::Content.indirection.name.should == :file_content end - it "should should include the TerminusSelector module in its indirection" do - Puppet::FileServing::Content.indirection.metaclass.included_modules.should include(Puppet::FileServing::TerminusSelector) - end -end - -describe Puppet::FileServing::Content, " when initializing" do - it "should accept a file path" do - Puppet::FileServing::Content.new("not/qualified").path.should == "not/qualified" - end - - it "should not allow a fully qualified file path" do - proc { Puppet::FileServing::Content.new("/fully/qualified") }.should raise_error(ArgumentError) - end - - it "should allow specification of whether links should be managed" do - Puppet::FileServing::Content.new("not/qualified", :links => :manage) - end - - it "should fail if :links is set to anything other than :manage or :follow" do - Puppet::FileServing::Content.new("not/qualified", :links => :manage) - end - - it "should default to :manage for :links" do - Puppet::FileServing::Content.new("not/qualified", :links => :manage) + it "should should include the IndirectionHooks module in its indirection" do + Puppet::FileServing::Content.indirection.metaclass.included_modules.should include(Puppet::FileServing::IndirectionHooks) end end describe Puppet::FileServing::Content, " when returning the contents" do before do - @content = Puppet::FileServing::Content.new("sub/path", :links => :follow) - @base = "/my/base" - @full = "/my/base/sub/path" + @path = "/my/base" + @content = Puppet::FileServing::Content.new("sub/path", :links => :follow, :path => @path) end it "should fail if the file is a symlink and links are set to :manage" do @content.links = :manage - File.expects(:lstat).with(@full).returns stub("stat", :ftype => "symlink") - proc { @content.content(@base) }.should raise_error(ArgumentError) - end - - it "should accept a base path path to which the file should be relative" do - File.expects(:stat).with(@full).returns stub("stat", :ftype => "file") - File.expects(:read).with(@full).returns(:mycontent) - @content.content(@base).should == :mycontent + File.expects(:lstat).with(@path).returns stub("stat", :ftype => "symlink") + proc { @content.content }.should raise_error(ArgumentError) end - it "should use the set base path if one is not provided" do - @content.base_path = @base - File.expects(:stat).with(@full).returns stub("stat", :ftype => "file") - File.expects(:read).with(@full).returns(:mycontent) - @content.content() - end - - it "should fail if a base path is neither set nor provided" do - proc { @content.content() }.should raise_error(ArgumentError) + it "should fail if a path is not set" do + proc { @content.content() }.should raise_error(Errno::ENOENT) end it "should raise Errno::ENOENT if the file is absent" do - @content.base_path = "/there/is/absolutely/no/chance/that/this/path/exists" + @content.path = "/there/is/absolutely/no/chance/that/this/path/exists" proc { @content.content() }.should raise_error(Errno::ENOENT) end it "should return the contents of the path if the file exists" do - File.expects(:stat).with(@full).returns stub("stat", :ftype => "file") - File.expects(:read).with(@full).returns(:mycontent) - @content.content(@base).should == :mycontent + File.expects(:stat).with(@path).returns stub("stat", :ftype => "file") + File.expects(:read).with(@path).returns(:mycontent) + @content.content.should == :mycontent end end describe Puppet::FileServing::Content, " when converting to yaml" do - it "should fail if no base path has been set" do - @content = Puppet::FileServing::Content.new("some/path") + it "should fail if no path has been set" do + @content = Puppet::FileServing::Content.new("some/key") proc { @content.to_yaml }.should raise_error(ArgumentError) end it "should return the file contents" do @content = Puppet::FileServing::Content.new("some/path") - @content.base_path = "/base/path" + @content.path = "/base/path" @content.expects(:content).returns(:content) @content.to_yaml.should == :content end diff --git a/spec/unit/file_serving/file_base.rb b/spec/unit/file_serving/file_base.rb index 14be6d003..4c7724f7c 100755 --- a/spec/unit/file_serving/file_base.rb +++ b/spec/unit/file_serving/file_base.rb @@ -5,48 +5,67 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/file_serving/file_base' describe Puppet::FileServing::FileBase, " when initializing" do - it "should accept a file path" do - Puppet::FileServing::FileBase.new("not/qualified").path.should == "not/qualified" - end - - it "should not allow a fully qualified file path" do - proc { Puppet::FileServing::FileBase.new("/fully/qualified") }.should raise_error(ArgumentError) + it "should accept a key in the form of a URI" do + Puppet::FileServing::FileBase.new("puppet://host/module/dir/file").key.should == "puppet://host/module/dir/file" end it "should allow specification of whether links should be managed" do - Puppet::FileServing::FileBase.new("not/qualified", :links => :manage).links.should == :manage + Puppet::FileServing::FileBase.new("puppet://host/module/dir/file", :links => :manage).links.should == :manage end it "should fail if :links is set to anything other than :manage or :follow" do - proc { Puppet::FileServing::FileBase.new("not/qualified", :links => :else) }.should raise_error(ArgumentError) + proc { Puppet::FileServing::FileBase.new("puppet://host/module/dir/file", :links => :else) }.should raise_error(ArgumentError) end it "should default to :manage for :links" do - Puppet::FileServing::FileBase.new("not/qualified").links.should == :manage + Puppet::FileServing::FileBase.new("puppet://host/module/dir/file").links.should == :manage + end + + it "should allow specification of a path" do + FileTest.stubs(:exists?).returns(true) + Puppet::FileServing::FileBase.new("puppet://host/module/dir/file", :path => "/my/file").path.should == "/my/file" + end + + it "should allow specification of a relative path" do + FileTest.stubs(:exists?).returns(true) + Puppet::FileServing::FileBase.new("puppet://host/module/dir/file", :relative_path => "my/file").relative_path.should == "my/file" end end -describe Puppet::FileServing::FileBase do - it "should provide a method for setting the base path" do - @file = Puppet::FileServing::FileBase.new("not/qualified") - @file.base_path = "/something" - @file.base_path.should == "/something" +describe Puppet::FileServing::FileBase, " when setting the base path" do + before do + @file = Puppet::FileServing::FileBase.new("puppet://host/module/dir/file") + end + + it "should require that the base path be fully qualified" do + FileTest.stubs(:exists?).returns(true) + proc { @file.path = "unqualified/file" }.should raise_error(ArgumentError) + end +end + +describe Puppet::FileServing::FileBase, " when setting the relative path" do + it "should require that the relative path be unqualified" do + @file = Puppet::FileServing::FileBase.new("puppet://host/module/dir/file") + FileTest.stubs(:exists?).returns(true) + proc { @file.relative_path = "/qualified/file" }.should raise_error(ArgumentError) end end describe Puppet::FileServing::FileBase, " when determining the full file path" do - it "should return the provided path joined with the qualified path if a path is provided" do - @file = Puppet::FileServing::FileBase.new("not/qualified") - @file.full_path("/this/file").should == "/this/file/not/qualified" + before do + @file = Puppet::FileServing::FileBase.new("mykey", :path => "/this/file") end - it "should return the set base path joined with the qualified path if a base path is set" do - @file = Puppet::FileServing::FileBase.new("not/qualified") - @file.base_path = "/this/file" + it "should return the path if there is no relative path" do + @file.full_path.should == "/this/file" + end + + it "should return the path joined with the relative path if there is a relative path" do + @file.relative_path = "not/qualified" @file.full_path.should == "/this/file/not/qualified" end - it "should should fail if a base path is neither provided nor set" do + it "should should fail if there is no path set" do @file = Puppet::FileServing::FileBase.new("not/qualified") proc { @file.full_path }.should raise_error(ArgumentError) end @@ -54,32 +73,29 @@ end describe Puppet::FileServing::FileBase, " when stat'ing files" do before do - @file = Puppet::FileServing::FileBase.new("not/qualified") - end - - it "should join the provided path with the qualified path is a path is provided" do - File.expects(:lstat).with("/this/file/not/qualified").returns stub("stat", :ftype => "file") - @file.stat("/this/file") + @file = Puppet::FileServing::FileBase.new("mykey", :path => "/this/file") end - it "should use the set base path if no base is provided" do - @file.base_path = "/this/file" - File.expects(:lstat).with("/this/file/not/qualified").returns stub("stat", :ftype => "file") + it "should stat the file's full path" do + @file.stubs(:full_path).returns("/this/file") + File.expects(:lstat).with("/this/file").returns stub("stat", :ftype => "file") @file.stat end - it "should fail if a base path is neither set nor provided" do - proc { @file.stat }.should raise_error(ArgumentError) + it "should fail if the file does not exist" do + @file.stubs(:full_path).returns("/this/file") + File.expects(:lstat).with("/this/file").raises(Errno::ENOENT) + proc { @file.stat }.should raise_error(Errno::ENOENT) end it "should use :lstat if :links is set to :manage" do - File.expects(:lstat).with("/this/file/not/qualified").returns stub("stat", :ftype => "file") - @file.stat("/this/file") + File.expects(:lstat).with("/this/file").returns stub("stat", :ftype => "file") + @file.stat end it "should use :stat if :links is set to :follow" do - File.expects(:stat).with("/this/file/not/qualified").returns stub("stat", :ftype => "file") + File.expects(:stat).with("/this/file").returns stub("stat", :ftype => "file") @file.links = :follow - @file.stat("/this/file") + @file.stat end end diff --git a/spec/unit/file_serving/terminus_selector.rb b/spec/unit/file_serving/indirection_hooks.rb index 9c2c01bfd..34614b7b8 100755 --- a/spec/unit/file_serving/terminus_selector.rb +++ b/spec/unit/file_serving/indirection_hooks.rb @@ -5,12 +5,12 @@ require File.dirname(__FILE__) + '/../../spec_helper' -require 'puppet/file_serving/terminus_selector' +require 'puppet/file_serving/indirection_hooks' -describe Puppet::FileServing::TerminusSelector, " when being used to select termini" do +describe Puppet::FileServing::IndirectionHooks, " when being used to select termini" do before do @object = Object.new - @object.extend(Puppet::FileServing::TerminusSelector) + @object.extend(Puppet::FileServing::IndirectionHooks) end it "should escape the key before parsing" do @@ -83,10 +83,10 @@ describe Puppet::FileServing::TerminusSelector, " when being used to select term end end -describe Puppet::FileServing::TerminusSelector, " when looking for a module whose name matches the mount name" do +describe Puppet::FileServing::IndirectionHooks, " when looking for a module whose name matches the mount name" do before do @object = Object.new - @object.extend(Puppet::FileServing::TerminusSelector) + @object.extend(Puppet::FileServing::IndirectionHooks) @modules = mock 'modules' @object.stubs(:terminus).with(:modules).returns(@modules) diff --git a/spec/unit/file_serving/metadata.rb b/spec/unit/file_serving/metadata.rb index 27ebe2471..f7ab0c8d6 100755 --- a/spec/unit/file_serving/metadata.rb +++ b/spec/unit/file_serving/metadata.rb @@ -5,38 +5,16 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/file_serving/metadata' describe Puppet::FileServing::Metadata do - it "should indirect file_metadata" do - Puppet::FileServing::Metadata.indirection.name.should == :file_metadata - end - - it "should should include the TerminusSelector module in its indirection" do - Puppet::FileServing::Metadata.indirection.metaclass.included_modules.should include(Puppet::FileServing::TerminusSelector) - end -end - -describe Puppet::FileServing::Metadata, " when initializing" do - it "should not allow initialization without a path" do - proc { Puppet::FileServing::Metadata.new() }.should raise_error(ArgumentError) - end - - it "should not allow the path to be fully qualified if it is provided" do - proc { Puppet::FileServing::Metadata.new("/fully/qualified") }.should raise_error(ArgumentError) + it "should should be a subclass of FileBase" do + Puppet::FileServing::Metadata.superclass.should equal(Puppet::FileServing::FileBase) end - it "should allow initialization with a relative path" do - Puppet::FileServing::Metadata.new("not/fully/qualified") - end - - it "should allow specification of whether links should be managed" do - Puppet::FileServing::Metadata.new("not/qualified", :links => :manage) - end - - it "should fail if :links is set to anything other than :manage or :follow" do - Puppet::FileServing::Metadata.new("not/qualified", :links => :manage) + it "should indirect file_metadata" do + Puppet::FileServing::Metadata.indirection.name.should == :file_metadata end - it "should default to :manage for :links" do - Puppet::FileServing::Metadata.new("not/qualified", :links => :manage) + it "should should include the IndirectionHooks module in its indirection" do + Puppet::FileServing::Metadata.indirection.metaclass.included_modules.should include(Puppet::FileServing::IndirectionHooks) end end @@ -44,9 +22,10 @@ describe Puppet::FileServing::Metadata, " when finding the file to use for setti before do @metadata = Puppet::FileServing::Metadata.new("my/path") - @base = "/base/path" @full = "/base/path/my/path" + @metadata.path = @full + # Use a symlink because it's easier to test -- no checksumming @stat = stub "stat", :uid => 10, :gid => 20, :mode => 0755, :ftype => "symlink" end @@ -54,23 +33,22 @@ describe Puppet::FileServing::Metadata, " when finding the file to use for setti it "should accept a base path path to which the file should be relative" do File.expects(:lstat).with(@full).returns @stat File.expects(:readlink).with(@full).returns "/what/ever" - @metadata.collect_attributes(@base) + @metadata.collect_attributes end it "should use the set base path if one is not provided" do - @metadata.base_path = @base File.expects(:lstat).with(@full).returns @stat File.expects(:readlink).with(@full).returns "/what/ever" @metadata.collect_attributes() end it "should fail if a base path is neither set nor provided" do - proc { @metadata.collect_attributes() }.should raise_error(ArgumentError) + proc { @metadata.collect_attributes() }.should raise_error(Errno::ENOENT) end it "should raise an exception if the file does not exist" do - File.expects(:lstat).with("/base/dir/my/path").raises(Errno::ENOENT) - proc { @metadata.collect_attributes("/base/dir")}.should raise_error(Errno::ENOENT) + File.expects(:lstat).with(@full).raises(Errno::ENOENT) + proc { @metadata.collect_attributes()}.should raise_error(Errno::ENOENT) end end @@ -83,12 +61,8 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do @filehandle.expects(:each_line).yields("some content\n") File.stubs(:open).with(@path, 'r').yields(@filehandle) @checksum = Digest::MD5.hexdigest("some content\n") - @metadata = Puppet::FileServing::Metadata.new("file") - @metadata.collect_attributes("/my") - end - - it "should accept a file path" do - @metadata.path.should == "file" + @metadata = Puppet::FileServing::Metadata.new("file", :path => "/my/file") + @metadata.collect_attributes end # LAK:FIXME This should actually change at some point @@ -128,22 +102,22 @@ end describe Puppet::FileServing::Metadata, " when pointing to a symlink" do it "should store the destination of the symlink in :destination if links are :manage" do - file = Puppet::FileServing::Metadata.new("my/file", :links => :manage) + file = Puppet::FileServing::Metadata.new("mykey", :links => :manage, :path => "/base/path/my/file") File.expects(:lstat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "symlink", :mode => 0755) File.expects(:readlink).with("/base/path/my/file").returns "/some/other/path" - file.collect_attributes("/base/path") + file.collect_attributes file.destination.should == "/some/other/path" end it "should not collect the checksum" do - file = Puppet::FileServing::Metadata.new("my/file", :links => :manage) + file = Puppet::FileServing::Metadata.new("my/file", :links => :manage, :path => "/base/path/my/file") File.expects(:lstat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "symlink", :mode => 0755) File.expects(:readlink).with("/base/path/my/file").returns "/some/other/path" - file.collect_attributes("/base/path") + file.collect_attributes file.checksum.should be_nil end end diff --git a/spec/unit/file_serving/terminus_helper.rb b/spec/unit/file_serving/terminus_helper.rb index 3a5274b5a..b919469a2 100755 --- a/spec/unit/file_serving/terminus_helper.rb +++ b/spec/unit/file_serving/terminus_helper.rb @@ -19,20 +19,60 @@ describe Puppet::FileServing::TerminusHelper do it "should use a fileset to find paths" do fileset = mock 'fileset', :files => [] Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(fileset) - @helper.path2instances("/my/file") + @helper.path2instances("url", "/my/file") end it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do fileset = mock 'fileset', :files => [] Puppet::FileServing::Fileset.expects(:new).with("/my/file", :links => :a, :ignore => :b, :recurse => :c).returns(fileset) - @helper.path2instances("/my/file", :links => :a, :ignore => :b, :recurse => :c) + @helper.path2instances("url", "/my/file", :links => :a, :ignore => :b, :recurse => :c) end +end - it "should return an instance of the model for each path returned by the fileset" do - fileset = mock 'fileset', :files => %w{one two} - Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(fileset) - @model.expects(:new).with("one").returns(:one) - @model.expects(:new).with("two").returns(:two) - @helper.path2instances("/my/file").should == [:one, :two] + +describe Puppet::FileServing::TerminusHelper, " when creating instances" do + before do + @helper = Object.new + @helper.extend(Puppet::FileServing::TerminusHelper) + + @model = mock 'model' + @helper.stubs(:model).returns(@model) + + @key = "puppet://host/mount/dir" + + @fileset = mock 'fileset', :files => %w{one two} + Puppet::FileServing::Fileset.expects(:new).returns(@fileset) + end + + it "should create an instance of the model for each path returned by the fileset" do + @model.expects(:new).returns(:one) + @model.expects(:new).returns(:two) + @helper.path2instances(@key, "/my/file").length.should == 2 + end + + it "should set each instance's key to be the original key plus the file-specific path" do + @model.expects(:new).with { |key, options| key == @key + "/one" }.returns(:one) + @model.expects(:new).with { |key, options| key == @key + "/two" }.returns(:two) + @helper.path2instances(@key, "/my/file") + end + + it "should set each returned instance's path to the original path" do + @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one) + @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two) + @helper.path2instances(@key, "/my/file") + end + + it "should set each returned instance's relative path to the file-specific path" do + @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one) + @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two) + @helper.path2instances(@key, "/my/file") + end + + it "should set the links value on each instance if one is provided" do + one = mock 'one', :links= => :manage + two = mock 'two', :links= => :manage + @model.expects(:new).returns(one) + @model.expects(:new).returns(two) + @helper.path2instances(@key, "/my/file", :links => :manage) end end diff --git a/spec/unit/indirector/direct_file_server.rb b/spec/unit/indirector/direct_file_server.rb new file mode 100755 index 000000000..2a8ec1a49 --- /dev/null +++ b/spec/unit/indirector/direct_file_server.rb @@ -0,0 +1,95 @@ +#!/usr/bin/env ruby +# +# Created by Luke Kanies on 2007-10-24. +# Copyright (c) 2007. All rights reserved. + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/indirector/direct_file_server' + +module DirectFileServerTerminusTesting + def setup + Puppet::Indirector::Terminus.stubs(:register_terminus_class) + @model = mock 'model' + @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model + Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection) + + @direct_file_class = Class.new(Puppet::Indirector::DirectFileServer) do + def self.to_s + "Testing::Mytype" + end + end + + @server = @direct_file_class.new + + @uri = "file:///my/local" + end +end + +describe Puppet::Indirector::DirectFileServer, "when finding a single file" do + include DirectFileServerTerminusTesting + + it "should return nil if the file does not exist" do + FileTest.expects(:exists?).with("/my/local").returns false + @server.find(@uri).should be_nil + end + + it "should return a Content instance created with the full path to the file if the file exists" do + FileTest.expects(:exists?).with("/my/local").returns true + @model.expects(:new).returns(:mycontent) + @server.find(@uri).should == :mycontent + end +end + +describe Puppet::Indirector::DirectFileServer, "when creating the instance for a single found file" do + include DirectFileServerTerminusTesting + + before do + @data = mock 'content' + @data.stubs(:collect_attributes) + FileTest.expects(:exists?).with("/my/local").returns true + end + + it "should create the Content instance with the original key as the key" do + @model.expects(:new).with { |key, options| key == @uri }.returns(@data) + @server.find(@uri) + end + + it "should pass the full path to the instance" do + @model.expects(:new).with { |key, options| options[:path] == "/my/local" }.returns(@data) + @server.find(@uri) + end + + it "should pass the :links setting on to the created Content instance if the file exists and there is a value for :links" do + @model.expects(:new).returns(@data) + @data.expects(:links=).with(:manage) + @server.find(@uri, :links => :manage) + end +end + +describe Puppet::Indirector::DirectFileServer, "when searching for multiple files" do + include DirectFileServerTerminusTesting + + it "should return nil if the file does not exist" do + FileTest.expects(:exists?).with("/my/local").returns false + @server.find(@uri).should be_nil + end + + it "should pass the original key to :path2instances" do + FileTest.expects(:exists?).with("/my/local").returns true + @server.expects(:path2instances).with { |uri, path, options| uri == @uri } + @server.search(@uri) + end + + it "should use :path2instances from the terminus_helper to return instances if the file exists" do + FileTest.expects(:exists?).with("/my/local").returns true + @server.expects(:path2instances) + @server.search(@uri) + end + + it "should pass any options on to :path2instances" do + FileTest.expects(:exists?).with("/my/local").returns true + @server.expects(:path2instances).with { |uri, path, options| options == {:testing => :one, :other => :two}} + @server.search(@uri, :testing => :one, :other => :two) + end +end diff --git a/spec/unit/indirector/file_content/file.rb b/spec/unit/indirector/file_content/file.rb index da2c90770..04656e0ed 100755 --- a/spec/unit/indirector/file_content/file.rb +++ b/spec/unit/indirector/file_content/file.rb @@ -12,59 +12,7 @@ describe Puppet::Indirector::FileContent::File do Puppet::Indirector::Terminus.terminus_class(:file_content, :file).should equal(Puppet::Indirector::FileContent::File) end - it "should be a subclass of the File terminus" do - Puppet::Indirector::FileContent::File.superclass.should equal(Puppet::Indirector::File) - end -end - -describe Puppet::Indirector::FileContent::File, "when finding a single file" do - it "should return a Content instance created with the full path to the file if the file exists" do - @content = Puppet::Indirector::FileContent::File.new - @uri = "file:///my/local" - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Content.expects(:new).with("/my/local", :links => nil).returns(:mycontent) - @content.find(@uri).should == :mycontent - end - - it "should pass the :links setting on to the created Content instance if the file exists" do - @content = Puppet::Indirector::FileContent::File.new - @uri = "file:///my/local" - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Content.expects(:new).with("/my/local", :links => :manage).returns(:mycontent) - @content.find(@uri, :links => :manage) - end - - it "should return nil if the file does not exist" do - @content = Puppet::Indirector::FileContent::File.new - @uri = "file:///my/local" - - FileTest.expects(:exists?).with("/my/local").returns false - @content.find(@uri).should be_nil - end -end - -describe Puppet::Indirector::FileContent::File, "when searching for multiple files" do - before do - @content = Puppet::Indirector::FileContent::File.new - @uri = "file:///my/local" - end - - it "should return nil if the file does not exist" do - FileTest.expects(:exists?).with("/my/local").returns false - @content.find(@uri).should be_nil - end - - it "should use :path2instances from the terminus_helper to return instances if the file exists" do - FileTest.expects(:exists?).with("/my/local").returns true - @content.expects(:path2instances).with("/my/local", {}) - @content.search(@uri) - end - - it "should pass any options on to :path2instances" do - FileTest.expects(:exists?).with("/my/local").returns true - @content.expects(:path2instances).with("/my/local", :testing => :one, :other => :two) - @content.search(@uri, :testing => :one, :other => :two) + it "should be a subclass of the DirectFileServer terminus" do + Puppet::Indirector::FileContent::File.superclass.should equal(Puppet::Indirector::DirectFileServer) end end diff --git a/spec/unit/indirector/file_metadata/file.rb b/spec/unit/indirector/file_metadata/file.rb index c88d559a7..0a37a6895 100755 --- a/spec/unit/indirector/file_metadata/file.rb +++ b/spec/unit/indirector/file_metadata/file.rb @@ -11,44 +11,27 @@ describe Puppet::Indirector::FileMetadata::File do it "should be registered with the file_metadata indirection" do Puppet::Indirector::Terminus.terminus_class(:file_metadata, :file).should equal(Puppet::Indirector::FileMetadata::File) end + + it "should be a subclass of the DirectFileServer terminus" do + Puppet::Indirector::FileMetadata::File.superclass.should equal(Puppet::Indirector::DirectFileServer) + end end -describe Puppet::Indirector::FileMetadata::File, "when finding a single file" do +describe Puppet::Indirector::FileMetadata::File, "when creating the instance for a single found file" do before do @metadata = Puppet::Indirector::FileMetadata::File.new @uri = "file:///my/local" - @data = mock 'metadata' - end - - it "should return a Metadata instance created with the full path to the file if the file exists" do - @data.stubs(:collect_attributes) - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => nil).returns(@data) - @metadata.find(@uri).should == @data - end - - it "should pass the :links setting on to the created Content instance if the file exists" do @data.stubs(:collect_attributes) - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => :manage).returns(@data) - @metadata.find(@uri, :links => :manage) end it "should collect its attributes when a file is found" do @data.expects(:collect_attributes) - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => nil).returns(@data) + Puppet::FileServing::Metadata.expects(:new).returns(@data) @metadata.find(@uri).should == @data end - - it "should return nil if the file does not exist" do - FileTest.expects(:exists?).with("/my/local").returns false - @metadata.find(@uri).should be_nil - end end describe Puppet::Indirector::FileMetadata::File, "when searching for multiple files" do @@ -57,26 +40,9 @@ describe Puppet::Indirector::FileMetadata::File, "when searching for multiple fi @uri = "file:///my/local" end - it "should return nil if the file does not exist" do - FileTest.expects(:exists?).with("/my/local").returns false - @metadata.find(@uri).should be_nil - end - - it "should use :path2instances from the terminus_helper to return instances if the file exists" do - FileTest.expects(:exists?).with("/my/local").returns true - @metadata.expects(:path2instances).with("/my/local", {}).returns([]) - @metadata.search(@uri) - end - - it "should pass any options on to :path2instances" do - FileTest.expects(:exists?).with("/my/local").returns true - @metadata.expects(:path2instances).with("/my/local", :testing => :one, :other => :two).returns([]) - @metadata.search(@uri, :testing => :one, :other => :two) - end - it "should collect the attributes of the instances returned" do FileTest.expects(:exists?).with("/my/local").returns true - @metadata.expects(:path2instances).with("/my/local", {}).returns( [mock("one", :collect_attributes => nil), mock("two", :collect_attributes => nil)] ) + @metadata.expects(:path2instances).returns( [mock("one", :collect_attributes => nil), mock("two", :collect_attributes => nil)] ) @metadata.search(@uri) end end diff --git a/spec/unit/indirector/file_metadata/modules.rb b/spec/unit/indirector/file_metadata/modules.rb index 94e1bf0dc..62f01832c 100755 --- a/spec/unit/indirector/file_metadata/modules.rb +++ b/spec/unit/indirector/file_metadata/modules.rb @@ -34,7 +34,7 @@ describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do FileTest.expects(:exists?).with("/path/to/files/my/file").returns true instance = mock 'metadta' Puppet::FileServing::Metadata.expects(:new).returns instance - instance.expects :get_attributes + instance.expects :collect_attributes @finder.find("puppetmounts://hostname/modules/mymod/my/file") end end diff --git a/spec/unit/indirector/file_server.rb b/spec/unit/indirector/file_server.rb index ed36e180e..fda60f1ec 100755 --- a/spec/unit/indirector/file_server.rb +++ b/spec/unit/indirector/file_server.rb @@ -54,7 +54,7 @@ describe Puppet::Indirector::FileServer, " when finding files" do it "should return an instance of the model created with the full path if a file is found" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file") - @model.expects(:new).with("/some/file", :links => nil).returns(:myinstance) + @model.expects(:new).returns(:myinstance) @file_server.find(@uri).should == :myinstance end end @@ -63,11 +63,31 @@ end describe Puppet::Indirector::FileServer, " when returning instances" do include FileServerTerminusTesting - it "should pass the provided :links setting on to the instance if one is provided" do + before do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file") - @model.expects(:new).with("/some/file", :links => :mytest) + @instance = mock 'instance' + end + + it "should create the instance with the key used to find the instance" do + @model.expects(:new).with { |key, *options| key == @uri } + @file_server.find(@uri) + end + + it "should create the instance with the path at which the instance was found" do + @model.expects(:new).with { |key, options| options[:path] == "/some/file" } + @file_server.find(@uri) + end + + it "should set the provided :links setting on to the instance if one is provided" do + @model.expects(:new).returns(@instance) + @instance.expects(:links=).with(:mytest) @file_server.find(@uri, :links => :mytest) end + + it "should not set a :links value if no :links parameter is provided" do + @model.expects(:new).returns(@instance) + @file_server.find(@uri) + end end describe Puppet::Indirector::FileServer, " when checking authorization" do @@ -141,13 +161,13 @@ describe Puppet::Indirector::FileServer, " when searching for files" do it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file") - @file_server.expects(:path2instances).with("/my/file", {}) + @file_server.expects(:path2instances).with(@uri, "/my/file", {}) @file_server.search(@uri) end it "should pass any options on to :path2instances" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file") - @file_server.expects(:path2instances).with("/my/file", :testing => :one, :other => :two) + @file_server.expects(:path2instances).with(@uri, "/my/file", :testing => :one, :other => :two) @file_server.search(@uri, :testing => :one, :other => :two) end end diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb index 00153ff35..5d8453905 100755 --- a/spec/unit/indirector/indirection.rb +++ b/spec/unit/indirector/indirection.rb @@ -67,7 +67,15 @@ describe Puppet::Indirector::Indirection, " when looking for a model instance" d proc { @indirection.find(@name) }.should_not raise_error end - it "should call the terminus's authorization hook if there is one" + it "should pass the instance to the :post_find hook if there is one" do + class << @terminus + def post_find + end + end + @terminus.expects(:post_find).with(@instance) + @terminus.expects(:find).with(@name).returns(@instance) + @indirection.find(@name) + end end describe Puppet::Indirector::Indirection, " when removing a model instance" do @@ -77,8 +85,6 @@ describe Puppet::Indirector::Indirection, " when removing a model instance" do @terminus.expects(:destroy).with(@name).returns(@instance) @indirection.destroy(@name).should == @instance end - - it "should call the terminus's authorization hook if there is one" end describe Puppet::Indirector::Indirection, " when searching for multiple model instances" do @@ -89,7 +95,15 @@ describe Puppet::Indirector::Indirection, " when searching for multiple model in @indirection.search(@name).should == @instance end - it "should call the terminus's authorization hook if there is one" + it "should pass the instances to the :post_search hook if there is one" do + class << @terminus + def post_search + end + end + @terminus.expects(:post_search).with(@instance) + @terminus.expects(:search).with(@name).returns(@instance) + @indirection.search(@name) + end end describe Puppet::Indirector::Indirection, " when storing a model instance" do @@ -99,8 +113,6 @@ describe Puppet::Indirector::Indirection, " when storing a model instance" do @terminus.expects(:save).with(@instance).returns(@instance) @indirection.save(@instance).should == @instance end - - it "should call the terminus's authorization hook if there is one" end describe Puppet::Indirector::Indirection, " when handling instance versions" do @@ -111,8 +123,6 @@ describe Puppet::Indirector::Indirection, " when handling instance versions" do @indirection.version(@name).should == 5 end - it "should call the terminus's authorization hook if there is one" - it "should add versions to found instances that do not already have them" do @terminus.expects(:find).with(@name).returns(@instance) time = mock 'time' @@ -470,3 +480,71 @@ describe Puppet::Indirector::Indirection, " when finding and using a cache" do @indirection.find(name).should equal(real) end end + +describe Puppet::Indirector::Indirection, " when an authorization hook is present" do + include IndirectionTesting + + before do + # So the :respond_to? turns out right. + class << @terminus + def authorized? + end + end + end + + it "should not check authorization if a node name is not provided" do + @terminus.expects(:authorized?).never + @terminus.stubs(:find) + @indirection.find("/my/key") + end + + it "should fail while finding instances if authorization returns false" do + @terminus.expects(:authorized?).with(:find, "/my/key", :node => "mynode").returns(false) + @terminus.stubs(:find) + proc { @indirection.find("/my/key", :node => "mynode") }.should raise_error(ArgumentError) + end + + it "should continue finding instances if authorization returns true" do + @terminus.expects(:authorized?).with(:find, "/my/key", :node => "mynode").returns(true) + @terminus.stubs(:find) + @indirection.find("/my/key", :node => "mynode") + end + + it "should fail while saving instances if authorization returns false" do + @terminus.expects(:authorized?).with(:save, :myinstance, :node => "mynode").returns(false) + @terminus.stubs(:save) + proc { @indirection.save(:myinstance, :node => "mynode") }.should raise_error(ArgumentError) + end + + it "should continue saving instances if authorization returns true" do + instance = stub 'instance', :version => 1.0, :name => "eh" + @terminus.expects(:authorized?).with(:save, instance, :node => "mynode").returns(true) + @terminus.stubs(:save) + @indirection.save(instance, :node => "mynode") + end + + it "should fail while destroying instances if authorization returns false" do + @terminus.expects(:authorized?).with(:destroy, "/my/key", :node => "mynode").returns(false) + @terminus.stubs(:destroy) + proc { @indirection.destroy("/my/key", :node => "mynode") }.should raise_error(ArgumentError) + end + + it "should continue destroying instances if authorization returns true" do + instance = stub 'instance', :version => 1.0, :name => "eh" + @terminus.expects(:authorized?).with(:destroy, instance, :node => "mynode").returns(true) + @terminus.stubs(:destroy) + @indirection.destroy(instance, :node => "mynode") + end + + it "should fail while searching for instances if authorization returns false" do + @terminus.expects(:authorized?).with(:search, "/my/key", :node => "mynode").returns(false) + @terminus.stubs(:search) + proc { @indirection.search("/my/key", :node => "mynode") }.should raise_error(ArgumentError) + end + + it "should continue searching for instances if authorization returns true" do + @terminus.expects(:authorized?).with(:search, "/my/key", :node => "mynode").returns(true) + @terminus.stubs(:search) + @indirection.search("/my/key", :node => "mynode") + end +end diff --git a/spec/unit/indirector/module_files.rb b/spec/unit/indirector/module_files.rb index f2e43f771..9cb683c3c 100755 --- a/spec/unit/indirector/module_files.rb +++ b/spec/unit/indirector/module_files.rb @@ -62,10 +62,10 @@ describe Puppet::Indirector::ModuleFiles, " when finding files" do @module_files.find(@uri).should be_nil end - it "should return an instance of the model created with the full path if a module is found and the file exists" do + it "should return an instance of the model if a module is found and the file exists" do Puppet::Module.expects(:find).with('my', nil).returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @model.expects(:new).with("/module/path/files/local/file", :links => nil).returns(:myinstance) + @model.expects(:new).returns(:myinstance) @module_files.find(@uri).should == :myinstance end @@ -92,12 +92,32 @@ end describe Puppet::Indirector::ModuleFiles, " when returning instances" do include ModuleFilesTerminusTesting - it "should pass the provided :links setting on to the instance if one is provided" do + before do Puppet::Module.expects(:find).with('my', nil).returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @model.expects(:new).with("/module/path/files/local/file", :links => :mytest) + @instance = mock 'instance' + end + + it "should create the instance with the key used to find the instance" do + @model.expects(:new).with { |key, *options| key == @uri } + @module_files.find(@uri) + end + + it "should create the instance with the path at which the instance was found" do + @model.expects(:new).with { |key, options| options[:path] == "/module/path/files/local/file" } + @module_files.find(@uri) + end + + it "should set the provided :links setting on to the instance if one is provided" do + @model.expects(:new).returns(@instance) + @instance.expects(:links=).with(:mytest) @module_files.find(@uri, :links => :mytest) end + + it "should not set a :links value if no :links parameter is provided" do + @model.expects(:new).returns(@instance) + @module_files.find(@uri) + end end describe Puppet::Indirector::ModuleFiles, " when authorizing" do @@ -213,14 +233,14 @@ describe Puppet::Indirector::ModuleFiles, " when searching for files" do it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do Puppet::Module.expects(:find).with('my', nil).returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @module_files.expects(:path2instances).with("/module/path/files/local/file", {}) + @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", {}) @module_files.search(@uri) end it "should pass any options on to :path2instances" do Puppet::Module.expects(:find).with('my', nil).returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @module_files.expects(:path2instances).with("/module/path/files/local/file", :testing => :one, :other => :two) + @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", :testing => :one, :other => :two) @module_files.search(@uri, :testing => :one, :other => :two) end end diff --git a/test/certmgr/ca.rb b/test/certmgr/ca.rb index 543d3dd25..e354f3dea 100755 --- a/test/certmgr/ca.rb +++ b/test/certmgr/ca.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/sslcertificates/ca.rb' diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb index a0cc3abc9..033700089 100755 --- a/test/certmgr/certmgr.rb +++ b/test/certmgr/certmgr.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/sslcertificates.rb' diff --git a/test/certmgr/inventory.rb b/test/certmgr/inventory.rb index 55b9cec6d..9c1e19ffe 100755 --- a/test/certmgr/inventory.rb +++ b/test/certmgr/inventory.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest/certificates' diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb index b0b79a62f..cdbbe3fda 100755 --- a/test/certmgr/support.rb +++ b/test/certmgr/support.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/sslcertificates/support' diff --git a/test/executables/filebucket.rb b/test/executables/filebucket.rb index 82746bde9..491630707 100755 --- a/test/executables/filebucket.rb +++ b/test/executables/filebucket.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/network/client' diff --git a/test/executables/puppetbin.rb b/test/executables/puppetbin.rb index e498a85d2..218787c92 100755 --- a/test/executables/puppetbin.rb +++ b/test/executables/puppetbin.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb index e1c516d98..cdc827079 100755 --- a/test/executables/puppetca.rb +++ b/test/executables/puppetca.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/executables/puppetd.rb b/test/executables/puppetd.rb index ea63d70f2..a482e4b34 100755 --- a/test/executables/puppetd.rb +++ b/test/executables/puppetd.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/network/client' diff --git a/test/executables/puppetmasterd.rb b/test/executables/puppetmasterd.rb index 58726db45..16f7f0f5c 100755 --- a/test/executables/puppetmasterd.rb +++ b/test/executables/puppetmasterd.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/network/client' diff --git a/test/executables/puppetmodule.rb b/test/executables/puppetmodule.rb index 9e04bc2e8..ce28796d7 100755 --- a/test/executables/puppetmodule.rb +++ b/test/executables/puppetmodule.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' diff --git a/test/language/ast.rb b/test/language/ast.rb index dbc1d04ed..141d27087 100755 --- a/test/language/ast.rb +++ b/test/language/ast.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/parser/interpreter' diff --git a/test/language/ast/casestatement.rb b/test/language/ast/casestatement.rb index 4623a2235..0a744b686 100755 --- a/test/language/ast/casestatement.rb +++ b/test/language/ast/casestatement.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2006-12-22. # Copyright (c) 2006. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppettest/parsertesting' diff --git a/test/language/ast/definition.rb b/test/language/ast/definition.rb index d4c987362..b4d58a289 100755 --- a/test/language/ast/definition.rb +++ b/test/language/ast/definition.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2006-02-20. # Copyright (c) 2006. All rights reserved. -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/language/ast/hostclass.rb b/test/language/ast/hostclass.rb index f747779b3..62d4f9ee3 100755 --- a/test/language/ast/hostclass.rb +++ b/test/language/ast/hostclass.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2006-02-20. # Copyright (c) 2006. All rights reserved. -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppettest/parsertesting' diff --git a/test/language/ast/resource.rb b/test/language/ast/resource.rb index 9ef5181af..49c64112d 100755 --- a/test/language/ast/resource.rb +++ b/test/language/ast/resource.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2007-07-8. # Copyright (c) 2007. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppettest/parsertesting' diff --git a/test/language/ast/resource_reference.rb b/test/language/ast/resource_reference.rb index e8883afb9..d3b1ffd8f 100755 --- a/test/language/ast/resource_reference.rb +++ b/test/language/ast/resource_reference.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2007-07-8. # Copyright (c) 2007. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppettest/parsertesting' diff --git a/test/language/ast/selector.rb b/test/language/ast/selector.rb index 7394f5f7d..535fcbf70 100755 --- a/test/language/ast/selector.rb +++ b/test/language/ast/selector.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2006-12-22. # Copyright (c) 2006. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppettest/parsertesting' diff --git a/test/language/ast/variable.rb b/test/language/ast/variable.rb index bf22021d0..09122ce16 100755 --- a/test/language/ast/variable.rb +++ b/test/language/ast/variable.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2007-0419. # Copyright (c) 2006. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppettest/parsertesting' diff --git a/test/language/collector.rb b/test/language/collector.rb index 55c93c2d5..30949c061 100755 --- a/test/language/collector.rb +++ b/test/language/collector.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppettest/parsertesting' diff --git a/test/language/compile.rb b/test/language/compile.rb index 7a8a613af..07ef54626 100755 --- a/test/language/compile.rb +++ b/test/language/compile.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'mocha' require 'puppettest' diff --git a/test/language/functions.rb b/test/language/functions.rb index db107fd36..746ba4b1d 100755 --- a/test/language/functions.rb +++ b/test/language/functions.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/parser/parser' diff --git a/test/language/lexer.rb b/test/language/lexer.rb index 38a7ddb22..e09828d51 100755 --- a/test/language/lexer.rb +++ b/test/language/lexer.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/parser/lexer' diff --git a/test/language/parser.rb b/test/language/parser.rb index 1e7adb45e..04cd3a095 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'mocha' require 'puppet' diff --git a/test/language/resource.rb b/test/language/resource.rb index f25be93b5..942277bd1 100755 --- a/test/language/resource.rb +++ b/test/language/resource.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppettest/resourcetesting' diff --git a/test/language/scope.rb b/test/language/scope.rb index 22734a5fb..990ca9694 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'mocha' require 'puppettest' diff --git a/test/language/snippets.rb b/test/language/snippets.rb index 58a6e7f89..0806a40b4 100755 --- a/test/language/snippets.rb +++ b/test/language/snippets.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/parser/interpreter' diff --git a/test/language/transportable.rb b/test/language/transportable.rb index 4e4573e0b..7ea6a176d 100755 --- a/test/language/transportable.rb +++ b/test/language/transportable.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/transportable' diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index d1e690e70..eb50077b8 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -1,7 +1,9 @@ # Add .../test/lib -$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) +testlib = File.expand_path(File.dirname(__FILE__)) +$LOAD_PATH.unshift(testlib) unless $LOAD_PATH.include?(testlib) # Add .../lib -$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))) +mainlib = File.expand_path(File.join(File.dirname(__FILE__), '../../lib')) +$LOAD_PATH.unshift(mainlib) unless $LOAD_PATH.include?(mainlib) require 'puppet' require 'mocha' diff --git a/test/network/authconfig.rb b/test/network/authconfig.rb index e22431c75..3a05096d5 100755 --- a/test/network/authconfig.rb +++ b/test/network/authconfig.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' diff --git a/test/network/authorization.rb b/test/network/authorization.rb index 766c454e0..23ec8f95c 100755 --- a/test/network/authorization.rb +++ b/test/network/authorization.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/network/authorization' diff --git a/test/network/authstore.rb b/test/network/authstore.rb index 6d2bc08e2..ad4a4f1c2 100755 --- a/test/network/authstore.rb +++ b/test/network/authstore.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb index c996e1abd..74de37900 100755 --- a/test/network/client/ca.rb +++ b/test/network/client/ca.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'mocha' require 'puppettest' diff --git a/test/network/client/client.rb b/test/network/client/client.rb index a297a87e1..4a7e9cdb6 100755 --- a/test/network/client/client.rb +++ b/test/network/client/client.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/network/client/dipper.rb b/test/network/client/dipper.rb index d48b50478..51494be9d 100755 --- a/test/network/client/dipper.rb +++ b/test/network/client/dipper.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/client/resource' diff --git a/test/network/client/master.rb b/test/network/client/master.rb index 4ae77abc2..4f6956470 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/network/client/resource.rb b/test/network/client/resource.rb index 2b034f079..83c195035 100755 --- a/test/network/client/resource.rb +++ b/test/network/client/resource.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/client/resource' diff --git a/test/network/client_request.rb b/test/network/client_request.rb index f7804ec07..7408e2b87 100755 --- a/test/network/client_request.rb +++ b/test/network/client_request.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' diff --git a/test/network/daemon.rb b/test/network/daemon.rb index e794ce241..5105c6e4c 100755 --- a/test/network/daemon.rb +++ b/test/network/daemon.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/daemon' diff --git a/test/network/handler/bucket.rb b/test/network/handler/bucket.rb index 30a192f09..6b28fdb72 100755 --- a/test/network/handler/bucket.rb +++ b/test/network/handler/bucket.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/handler/filebucket' diff --git a/test/network/handler/ca.rb b/test/network/handler/ca.rb index e349f9c4c..16782bb18 100755 --- a/test/network/handler/ca.rb +++ b/test/network/handler/ca.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/handler/ca' diff --git a/test/network/handler/configuration.rb b/test/network/handler/configuration.rb index 1c08fd196..e560bd624 100755 --- a/test/network/handler/configuration.rb +++ b/test/network/handler/configuration.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/handler/configuration' diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb index 8dcbf63ea..3539169dc 100755 --- a/test/network/handler/fileserver.rb +++ b/test/network/handler/fileserver.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/handler/fileserver' diff --git a/test/network/handler/handler.rb b/test/network/handler/handler.rb index b812ca3d3..f108ef98d 100755 --- a/test/network/handler/handler.rb +++ b/test/network/handler/handler.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/handler' diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index 6c4451d06..694888f4d 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/handler/master' diff --git a/test/network/handler/report.rb b/test/network/handler/report.rb index 76326bce6..8719c68b5 100755 --- a/test/network/handler/report.rb +++ b/test/network/handler/report.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/handler/report' diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb index b2acc00b9..0d6373160 100755 --- a/test/network/handler/resource.rb +++ b/test/network/handler/resource.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'base64' diff --git a/test/network/handler/runner.rb b/test/network/handler/runner.rb index 50a00862a..402b27ffc 100755 --- a/test/network/handler/runner.rb +++ b/test/network/handler/runner.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/network/rights.rb b/test/network/rights.rb index a3e780330..e1d9f8a0a 100755 --- a/test/network/rights.rb +++ b/test/network/rights.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/network/rights' diff --git a/test/network/server/mongrel_test.rb b/test/network/server/mongrel_test.rb index 52d8790eb..80e9aa454 100755 --- a/test/network/server/mongrel_test.rb +++ b/test/network/server/mongrel_test.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb index 5919461ed..17263817b 100755 --- a/test/network/server/webrick.rb +++ b/test/network/server/webrick.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/http_server/webrick' diff --git a/test/network/xmlrpc/client.rb b/test/network/xmlrpc/client.rb index a81e95a86..e740e57b4 100755 --- a/test/network/xmlrpc/client.rb +++ b/test/network/xmlrpc/client.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/xmlrpc/client' diff --git a/test/network/xmlrpc/processor.rb b/test/network/xmlrpc/processor.rb index bc29f4c23..079194efa 100755 --- a/test/network/xmlrpc/processor.rb +++ b/test/network/xmlrpc/processor.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/xmlrpc/processor' diff --git a/test/network/xmlrpc/server.rb b/test/network/xmlrpc/server.rb index ff9f72e0c..ae9f17ddf 100755 --- a/test/network/xmlrpc/server.rb +++ b/test/network/xmlrpc/server.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/network/xmlrpc/server' diff --git a/test/network/xmlrpc/webrick_servlet.rb b/test/network/xmlrpc/webrick_servlet.rb index 154cc6cf9..74326f6a0 100755 --- a/test/network/xmlrpc/webrick_servlet.rb +++ b/test/network/xmlrpc/webrick_servlet.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppettest/support/utils' diff --git a/test/other/dsl.rb b/test/other/dsl.rb index 0d891bf1a..108c9fa31 100755 --- a/test/other/dsl.rb +++ b/test/other/dsl.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/dsl' diff --git a/test/other/events.rb b/test/other/events.rb index 30b045695..2dfdfeb74 100755 --- a/test/other/events.rb +++ b/test/other/events.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/other/overrides.rb b/test/other/overrides.rb index bfdf174a4..272f78e30 100755 --- a/test/other/overrides.rb +++ b/test/other/overrides.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/other/propertychange.rb b/test/other/propertychange.rb index 34669771b..eaa4f4082 100755 --- a/test/other/propertychange.rb +++ b/test/other/propertychange.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2006-12-21. # Copyright (c) 2006. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' diff --git a/test/other/provider.rb b/test/other/provider.rb index a39c4e1e9..3e4ad83d6 100755 --- a/test/other/provider.rb +++ b/test/other/provider.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/provider' diff --git a/test/other/puppet.rb b/test/other/puppet.rb index 45039e3c6..6527bed56 100755 --- a/test/other/puppet.rb +++ b/test/other/puppet.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/other/relationship.rb b/test/other/relationship.rb index 60c240b7a..d890a031d 100755 --- a/test/other/relationship.rb +++ b/test/other/relationship.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2006-11-24. # Copyright (c) 2006. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/relationship' diff --git a/test/other/relationships.rb b/test/other/relationships.rb index edf97373c..6771b02ca 100755 --- a/test/other/relationships.rb +++ b/test/other/relationships.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/other/report.rb b/test/other/report.rb index bed510f2f..c45fa740b 100755 --- a/test/other/report.rb +++ b/test/other/report.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/reports' diff --git a/test/other/transactions.rb b/test/other/transactions.rb index 7d17a92e7..fb5cf4018 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/puppet/conffiles.rb b/test/puppet/conffiles.rb index 06f563a08..750570d23 100755 --- a/test/puppet/conffiles.rb +++ b/test/puppet/conffiles.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb index 3d7ee384a..7befb9fa2 100755 --- a/test/puppet/defaults.rb +++ b/test/puppet/defaults.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/puppet/errortest.rb b/test/puppet/errortest.rb index fb06a30f0..d998438f1 100755 --- a/test/puppet/errortest.rb +++ b/test/puppet/errortest.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/puppet/tc_suidmanager.rb b/test/puppet/tc_suidmanager.rb index 905d3d0c9..2e44ead6f 100755 --- a/test/puppet/tc_suidmanager.rb +++ b/test/puppet/tc_suidmanager.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/rails/ast.rb b/test/rails/ast.rb index 48ec18c45..ac086fde1 100755 --- a/test/rails/ast.rb +++ b/test/rails/ast.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/rails' diff --git a/test/rails/collection.rb b/test/rails/collection.rb index cbae9a1e4..d0eecca89 100755 --- a/test/rails/collection.rb +++ b/test/rails/collection.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/rails' diff --git a/test/rails/configuration.rb b/test/rails/configuration.rb index 277753945..ea66bc902 100755 --- a/test/rails/configuration.rb +++ b/test/rails/configuration.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/parser/parser' diff --git a/test/rails/host.rb b/test/rails/host.rb index 0d97e0ffa..dd1bb2a42 100755 --- a/test/rails/host.rb +++ b/test/rails/host.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/rails' diff --git a/test/rails/rails.rb b/test/rails/rails.rb index f6756ed24..c3b48b90e 100755 --- a/test/rails/rails.rb +++ b/test/rails/rails.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/rails' diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb index c2a82929d..d83115b1a 100755 --- a/test/rails/railsparameter.rb +++ b/test/rails/railsparameter.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/rails' diff --git a/test/rails/railsresource.rb b/test/rails/railsresource.rb index 7a1ffd217..58058472d 100755 --- a/test/rails/railsresource.rb +++ b/test/rails/railsresource.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/rails' diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 28cb07f69..e2a61f447 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2007-02-05. # Copyright (c) 2007. All rights reserved. -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/manager/instances.rb b/test/ral/manager/instances.rb index 14b85f95d..6ac4322f5 100755 --- a/test/ral/manager/instances.rb +++ b/test/ral/manager/instances.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2007-06-10. # Copyright (c) 2007. All rights reserved. -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/manager/manager.rb b/test/ral/manager/manager.rb index 4f2ade4e9..8f7e74d4d 100755 --- a/test/ral/manager/manager.rb +++ b/test/ral/manager/manager.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2006-11-29. # Copyright (c) 2006. All rights reserved. -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/manager/provider.rb b/test/ral/manager/provider.rb index 0aeac357f..bb7a21485 100755 --- a/test/ral/manager/provider.rb +++ b/test/ral/manager/provider.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb index b2c111e60..57248159b 100755 --- a/test/ral/manager/type.rb +++ b/test/ral/manager/type.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb index bc32b839b..2da4b1b57 100755 --- a/test/ral/providers/cron/crontab.rb +++ b/test/ral/providers/cron/crontab.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb index 2d5122da0..18b0866b9 100755 --- a/test/ral/providers/group.rb +++ b/test/ral/providers/group.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'etc' diff --git a/test/ral/providers/host/netinfo.rb b/test/ral/providers/host/netinfo.rb index f49a00beb..e513974fc 100755 --- a/test/ral/providers/host/netinfo.rb +++ b/test/ral/providers/host/netinfo.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2006-11-12. # Copyright (c) 2006. All rights reserved. -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb index 5499b0220..98c3acb2e 100755 --- a/test/ral/providers/host/parsed.rb +++ b/test/ral/providers/host/parsed.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'etc' require 'puppettest' diff --git a/test/ral/providers/mailalias/aliases.rb b/test/ral/providers/mailalias/aliases.rb index e54b6659a..663d4359c 100755 --- a/test/ral/providers/mailalias/aliases.rb +++ b/test/ral/providers/mailalias/aliases.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' require 'puppettest/fileparsing' diff --git a/test/ral/providers/mount/netinfo.rb b/test/ral/providers/mount/netinfo.rb index dc4316b8a..9a02bc471 100755 --- a/test/ral/providers/mount/netinfo.rb +++ b/test/ral/providers/mount/netinfo.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2006-11-12. # Copyright (c) 2006. All rights reserved. -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' # diff --git a/test/ral/providers/mount/parsed.rb b/test/ral/providers/mount/parsed.rb index 4fe644734..a7f1f5074 100755 --- a/test/ral/providers/mount/parsed.rb +++ b/test/ral/providers/mount/parsed.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'mocha' require 'puppettest' diff --git a/test/ral/providers/nameservice.rb b/test/ral/providers/nameservice.rb index f15e51d02..7b37cc594 100755 --- a/test/ral/providers/nameservice.rb +++ b/test/ral/providers/nameservice.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/provider/nameservice' diff --git a/test/ral/providers/package.rb b/test/ral/providers/package.rb index a0283b363..a602a4dab 100755 --- a/test/ral/providers/package.rb +++ b/test/ral/providers/package.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'etc' diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb index 8a5982553..18fe70fd0 100755 --- a/test/ral/providers/parsedfile.rb +++ b/test/ral/providers/parsedfile.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/providers/port/parsed.rb b/test/ral/providers/port/parsed.rb index b8237ad86..01ccd3d8c 100755 --- a/test/ral/providers/port/parsed.rb +++ b/test/ral/providers/port/parsed.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' #require 'puppettest/fileparsing' diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb index ee7eb1bca..9aaf77783 100755 --- a/test/ral/providers/provider.rb +++ b/test/ral/providers/provider.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'facter' diff --git a/test/ral/providers/service.rb b/test/ral/providers/service.rb index c4127146f..d527d4356 100755 --- a/test/ral/providers/service.rb +++ b/test/ral/providers/service.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/providers/service/base.rb b/test/ral/providers/service/base.rb index 7300b77af..934127a10 100755 --- a/test/ral/providers/service/base.rb +++ b/test/ral/providers/service/base.rb @@ -3,7 +3,7 @@ # Created by Luke A. Kanies on 2007-01-28. # Copyright (c) 2007. All rights reserved. -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' diff --git a/test/ral/providers/service/debian.rb b/test/ral/providers/service/debian.rb index ed90f8fef..f6c0004ca 100755 --- a/test/ral/providers/service/debian.rb +++ b/test/ral/providers/service/debian.rb @@ -3,7 +3,7 @@ # Created by David Schmitt on 2007-09-13 # Copyright (c) 2007. All rights reserved. -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' diff --git a/test/ral/providers/sshkey/parsed.rb b/test/ral/providers/sshkey/parsed.rb index 017bb983f..b94b7a69a 100755 --- a/test/ral/providers/sshkey/parsed.rb +++ b/test/ral/providers/sshkey/parsed.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' require 'puppettest/fileparsing' diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb index 1c2fd2f1f..18886118c 100755 --- a/test/ral/providers/user.rb +++ b/test/ral/providers/user.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/basic.rb b/test/ral/types/basic.rb index 2802f3440..4427238bf 100755 --- a/test/ral/types/basic.rb +++ b/test/ral/types/basic.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/cron.rb b/test/ral/types/cron.rb index 05fd342d5..a9a00240c 100755 --- a/test/ral/types/cron.rb +++ b/test/ral/types/cron.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb index e7ffa0aec..11a6d4055 100755 --- a/test/ral/types/exec.rb +++ b/test/ral/types/exec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb index de8d60447..aca9d3b9c 100755 --- a/test/ral/types/file.rb +++ b/test/ral/types/file.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'fileutils' diff --git a/test/ral/types/file/target.rb b/test/ral/types/file/target.rb index 8dda94e92..f5cbe4a45 100755 --- a/test/ral/types/file/target.rb +++ b/test/ral/types/file/target.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' require 'fileutils' diff --git a/test/ral/types/filebucket.rb b/test/ral/types/filebucket.rb index 094a5da2b..ecfe0e167 100755 --- a/test/ral/types/filebucket.rb +++ b/test/ral/types/filebucket.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'fileutils' diff --git a/test/ral/types/fileignoresource.rb b/test/ral/types/fileignoresource.rb index 153946770..5c7536453 100755 --- a/test/ral/types/fileignoresource.rb +++ b/test/ral/types/fileignoresource.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'cgi' diff --git a/test/ral/types/filesources.rb b/test/ral/types/filesources.rb index 489bc4e78..1f22fc9e0 100755 --- a/test/ral/types/filesources.rb +++ b/test/ral/types/filesources.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'cgi' diff --git a/test/ral/types/group.rb b/test/ral/types/group.rb index 5189c63a1..944b7e074 100755 --- a/test/ral/types/group.rb +++ b/test/ral/types/group.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'etc' diff --git a/test/ral/types/host.rb b/test/ral/types/host.rb index 8244caed0..69e37da0f 100755 --- a/test/ral/types/host.rb +++ b/test/ral/types/host.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'test/unit' diff --git a/test/ral/types/interface.rb b/test/ral/types/interface.rb index 0de538721..babe133c3 100755 --- a/test/ral/types/interface.rb +++ b/test/ral/types/interface.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/types/mailalias.rb b/test/ral/types/mailalias.rb index 544e6d2ae..ff1dd562a 100755 --- a/test/ral/types/mailalias.rb +++ b/test/ral/types/mailalias.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/types/mount.rb b/test/ral/types/mount.rb index fa5022e3d..1119894d0 100755 --- a/test/ral/types/mount.rb +++ b/test/ral/types/mount.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/types/package.rb b/test/ral/types/package.rb index d09cfdc8e..7d0caa0ba 100755 --- a/test/ral/types/package.rb +++ b/test/ral/types/package.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'facter' diff --git a/test/ral/types/parameter.rb b/test/ral/types/parameter.rb index 70c325e08..89c8b944d 100755 --- a/test/ral/types/parameter.rb +++ b/test/ral/types/parameter.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/port.rb b/test/ral/types/port.rb index 743107e44..e28904d55 100755 --- a/test/ral/types/port.rb +++ b/test/ral/types/port.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/property.rb b/test/ral/types/property.rb index 11975da09..6a3370caa 100755 --- a/test/ral/types/property.rb +++ b/test/ral/types/property.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/resources.rb b/test/ral/types/resources.rb index 3ee785444..0663fe795 100755 --- a/test/ral/types/resources.rb +++ b/test/ral/types/resources.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2006-12-12. # Copyright (c) 2006. All rights reserved. -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/schedule.rb b/test/ral/types/schedule.rb index a07ac791e..2870b8db6 100755 --- a/test/ral/types/schedule.rb +++ b/test/ral/types/schedule.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/type/schedule' diff --git a/test/ral/types/service.rb b/test/ral/types/service.rb index b187a08cd..01533c63e 100755 --- a/test/ral/types/service.rb +++ b/test/ral/types/service.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'mocha' diff --git a/test/ral/types/sshkey.rb b/test/ral/types/sshkey.rb index 26349e382..c610eb9e9 100755 --- a/test/ral/types/sshkey.rb +++ b/test/ral/types/sshkey.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/type/sshkey' diff --git a/test/ral/types/tidy.rb b/test/ral/types/tidy.rb index 521f1acc5..e95f26b95 100755 --- a/test/ral/types/tidy.rb +++ b/test/ral/types/tidy.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' diff --git a/test/ral/types/user.rb b/test/ral/types/user.rb index 9a76c0585..6cbe78f0f 100755 --- a/test/ral/types/user.rb +++ b/test/ral/types/user.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'etc' diff --git a/test/ral/types/yumrepo.rb b/test/ral/types/yumrepo.rb index e1c948e33..899a02135 100755 --- a/test/ral/types/yumrepo.rb +++ b/test/ral/types/yumrepo.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'fileutils' diff --git a/test/ral/types/zone.rb b/test/ral/types/zone.rb index eef791361..eb485b944 100755 --- a/test/ral/types/zone.rb +++ b/test/ral/types/zone.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' require 'puppet/type/zone' diff --git a/test/util/autoload.rb b/test/util/autoload.rb index ca77572c2..6babed774 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/util/autoload' diff --git a/test/util/classgen.rb b/test/util/classgen.rb index 0ecb61f56..24908069d 100755 --- a/test/util/classgen.rb +++ b/test/util/classgen.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/util/execution.rb b/test/util/execution.rb index ce748c75a..be85d6502 100755 --- a/test/util/execution.rb +++ b/test/util/execution.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/util/features.rb b/test/util/features.rb index 1e5858877..e20c73c65 100755 --- a/test/util/features.rb +++ b/test/util/features.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2006-11-07. # Copyright (c) 2006. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/util/feature' diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb index e1a5d39b5..adccfab65 100755 --- a/test/util/fileparsing.rb +++ b/test/util/fileparsing.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppettest/fileparsing' diff --git a/test/util/filetype.rb b/test/util/filetype.rb index e98fb5f6c..6c7ede07b 100755 --- a/test/util/filetype.rb +++ b/test/util/filetype.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/util/filetype' diff --git a/test/util/inifile.rb b/test/util/inifile.rb index d27e7993c..498816b8d 100755 --- a/test/util/inifile.rb +++ b/test/util/inifile.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/util/inifile' diff --git a/test/util/instance_loader.rb b/test/util/instance_loader.rb index be055fc5c..708d3f893 100755 --- a/test/util/instance_loader.rb +++ b/test/util/instance_loader.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/util/instance_loader' diff --git a/test/util/loadedfile.rb b/test/util/loadedfile.rb index 801ba5b2a..fb640466a 100755 --- a/test/util/loadedfile.rb +++ b/test/util/loadedfile.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/util/loadedfile' diff --git a/test/util/log.rb b/test/util/log.rb index 0e5a542db..523652f37 100755 --- a/test/util/log.rb +++ b/test/util/log.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/util/log' diff --git a/test/util/metrics.rb b/test/util/metrics.rb index 2775b3ff1..b0ac1e2f5 100755 --- a/test/util/metrics.rb +++ b/test/util/metrics.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/util/metric' diff --git a/test/util/package.rb b/test/util/package.rb index 737d8e5b4..8d4fbc8e8 100755 --- a/test/util/package.rb +++ b/test/util/package.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppet/util/package' diff --git a/test/util/posixtest.rb b/test/util/posixtest.rb index ae32c7a3f..34d68e3a2 100755 --- a/test/util/posixtest.rb +++ b/test/util/posixtest.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2006-11-07. # Copyright (c) 2006. All rights reserved. -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/util/posix' diff --git a/test/util/settings.rb b/test/util/settings.rb index 7dad04968..cf5dca76d 100755 --- a/test/util/settings.rb +++ b/test/util/settings.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'mocha' require 'puppettest' diff --git a/test/util/storage.rb b/test/util/storage.rb index d583e2c59..5634a94f6 100755 --- a/test/util/storage.rb +++ b/test/util/storage.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppet' require 'puppettest' diff --git a/test/util/subclass_loader.rb b/test/util/subclass_loader.rb index 2066785f7..34b8803fc 100755 --- a/test/util/subclass_loader.rb +++ b/test/util/subclass_loader.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'puppet/util/subclass_loader' diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb index 13a17ed6c..35e1446a1 100755 --- a/test/util/utiltest.rb +++ b/test/util/utiltest.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ +require File.dirname(__FILE__) + '/../lib/puppettest' require 'puppettest' require 'mocha' |