diff options
-rw-r--r-- | lib/puppet/configurer/plugin_handler.rb | 1 | ||||
-rwxr-xr-x | spec/unit/configurer/plugin_handler.rb | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index def6a1707..e934f5877 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -13,6 +13,7 @@ module Puppet::Configurer::PluginHandler end def load_plugin(file) + return unless FileTest.exist?(file) return if FileTest.directory?(file) begin diff --git a/spec/unit/configurer/plugin_handler.rb b/spec/unit/configurer/plugin_handler.rb index 7baece936..7f59d5bb3 100755 --- a/spec/unit/configurer/plugin_handler.rb +++ b/spec/unit/configurer/plugin_handler.rb @@ -57,6 +57,7 @@ describe Puppet::Configurer::PluginHandler do end it "should load each downloaded file" do + FileTest.stubs(:exist?).returns true downloader = mock 'downloader' Puppet::Configurer::Downloader.expects(:new).returns downloader @@ -72,12 +73,21 @@ describe Puppet::Configurer::PluginHandler do end it "should load plugins when asked to do so" do + FileTest.stubs(:exist?).returns true @pluginhandler.expects(:load).with("foo") @pluginhandler.load_plugin("foo") end + it "should not try to load files that don't exist" do + FileTest.expects(:exist?).with("foo").returns true + @pluginhandler.expects(:load).never + + @pluginhandler.load_plugin("foo") + end + it "should not try to load directories" do + FileTest.stubs(:exist?).returns true FileTest.expects(:directory?).with("foo").returns true @pluginhandler.expects(:load).never @@ -85,6 +95,7 @@ describe Puppet::Configurer::PluginHandler do end it "should warn but not fail if loading a file raises an exception" do + FileTest.stubs(:exist?).returns true @pluginhandler.expects(:load).with("foo").raises "eh" Puppet.expects(:err) @@ -92,6 +103,7 @@ describe Puppet::Configurer::PluginHandler do end it "should warn but not fail if loading a file raises a LoadError" do + FileTest.stubs(:exist?).returns true @pluginhandler.expects(:load).with("foo").raises LoadError.new("eh") Puppet.expects(:err) |