summaryrefslogtreecommitdiff
path: root/spec/unit/configurer/plugin_handler_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/configurer/plugin_handler_spec.rb')
-rwxr-xr-xspec/unit/configurer/plugin_handler_spec.rb44
1 files changed, 22 insertions, 22 deletions
diff --git a/spec/unit/configurer/plugin_handler_spec.rb b/spec/unit/configurer/plugin_handler_spec.rb
index 295629481..a80236888 100755
--- a/spec/unit/configurer/plugin_handler_spec.rb
+++ b/spec/unit/configurer/plugin_handler_spec.rb
@@ -3,37 +3,37 @@ require 'spec_helper'
require 'puppet/configurer'
require 'puppet/configurer/plugin_handler'
-class PluginHandlerTester
- include Puppet::Configurer::PluginHandler
- attr_accessor :environment
-end
-
describe Puppet::Configurer::PluginHandler do
- before do
- @pluginhandler = PluginHandlerTester.new
+ let(:factory) { Puppet::Configurer::DownloaderFactory.new }
+ let(:pluginhandler) { Puppet::Configurer::PluginHandler.new(factory) }
+ let(:environment) { Puppet::Node::Environment.create(:myenv, []) }
+ before :each do
# PluginHandler#load_plugin has an extra-strong rescue clause
# this mock is to make sure that we don't silently ignore errors
Puppet.expects(:err).never
end
- it "should use an Agent Downloader, with the name, source, destination, ignore, and environment set correctly, to download plugins when downloading is enabled" do
- environment = Puppet::Node::Environment.create(:myenv, [])
- Puppet.features.stubs(:external_facts?).returns(:true)
- plugindest = File.expand_path("/tmp/pdest")
- Puppet[:pluginsource] = "psource"
- Puppet[:plugindest] = plugindest
- Puppet[:pluginsignore] = "pignore"
- Puppet[:pluginfactsource] = "psource"
- Puppet[:pluginfactdest] = plugindest
+ it "downloads plugins and facts" do
+ Puppet.features.stubs(:external_facts?).returns(true)
+
+ plugin_downloader = stub('plugin-downloader', :evaluate => [])
+ facts_downloader = stub('facts-downloader', :evaluate => [])
+
+ factory.expects(:create_plugin_downloader).returns(plugin_downloader)
+ factory.expects(:create_plugin_facts_downloader).returns(facts_downloader)
+
+ pluginhandler.download_plugins(environment)
+ end
+
+ it "skips facts if not enabled" do
+ Puppet.features.stubs(:external_facts?).returns(false)
- downloader = mock 'downloader'
- Puppet::Configurer::Downloader.expects(:new).with("pluginfacts", plugindest, "psource", "pignore", environment).returns downloader
- Puppet::Configurer::Downloader.expects(:new).with("plugin", plugindest, "psource", "pignore", environment).returns downloader
+ plugin_downloader = stub('plugin-downloader', :evaluate => [])
- downloader.stubs(:evaluate).returns([])
- downloader.expects(:evaluate).twice
+ factory.expects(:create_plugin_downloader).returns(plugin_downloader)
+ factory.expects(:create_plugin_facts_downloader).never
- @pluginhandler.download_plugins(environment)
+ pluginhandler.download_plugins(environment)
end
end