summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/autoload.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-13 18:24:34 -0600
committerLuke Kanies <luke@madstop.com>2009-02-13 18:24:34 -0600
commit3fbec120768d84d208b14f574dfe916e25cfdbef (patch)
tree865d59f4ea9cf3782db46ce1ae7fd54b95945035 /spec/unit/util/autoload.rb
parenta2270b4a4f093c6c4f171dcf0c0e05fe101dd979 (diff)
parent2561c8e252dcf66890513458750bb1329a03beec (diff)
downloadpuppet-3fbec120768d84d208b14f574dfe916e25cfdbef.tar.gz
puppet-3fbec120768d84d208b14f574dfe916e25cfdbef.tar.xz
puppet-3fbec120768d84d208b14f574dfe916e25cfdbef.zip
Merge branch '0.24.x'
Conflicts: lib/puppet/indirector/facts/facter.rb lib/puppet/provider/augeas/augeas.rb lib/puppet/util/filetype.rb spec/unit/indirector/facts/facter.rb spec/unit/provider/augeas/augeas.rb test/util/filetype.rb
Diffstat (limited to 'spec/unit/util/autoload.rb')
-rwxr-xr-xspec/unit/util/autoload.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/unit/util/autoload.rb b/spec/unit/util/autoload.rb
new file mode 100755
index 000000000..ff717d6c5
--- /dev/null
+++ b/spec/unit/util/autoload.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+require 'puppet/util/autoload'
+
+describe Puppet::Util::Autoload do
+ before do
+ @autoload = Puppet::Util::Autoload.new("foo", "tmp")
+
+ @autoload.stubs(:eachdir).yields "/my/dir"
+ end
+
+ describe "when loading a file" do
+ [RuntimeError, LoadError, SyntaxError].each do |error|
+ it "should not die an if a #{error.to_s} exception is thrown" do
+ FileTest.stubs(:exists?).returns true
+
+ Kernel.expects(:load).raises error
+
+ lambda { @autoload.load("foo") }.should_not raise_error
+ end
+ end
+ end
+
+ describe "when loading all files" do
+ before do
+ Dir.stubs(:glob).returns "file.rb"
+ end
+
+ [RuntimeError, LoadError, SyntaxError].each do |error|
+ it "should not die an if a #{error.to_s} exception is thrown" do
+ Kernel.expects(:require).raises error
+
+ lambda { @autoload.loadall }.should_not raise_error
+ end
+ end
+ end
+end