summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider/package/freebsd_spec.rb
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@rimspace.net>2011-01-26 00:13:47 -0800
committerDaniel Pittman <daniel@rimspace.net>2011-01-26 00:13:47 -0800
commitd8716416746b4a88c05fa9583a08ba9b5b624787 (patch)
tree302fc75dbf843b3211c4b9b2c0d0207db04dc1a2 /spec/unit/provider/package/freebsd_spec.rb
parent3478190ce9b8f28c0e36c8102342471eda2ca446 (diff)
downloadpuppet-d8716416746b4a88c05fa9583a08ba9b5b624787.tar.gz
puppet-d8716416746b4a88c05fa9583a08ba9b5b624787.tar.xz
puppet-d8716416746b4a88c05fa9583a08ba9b5b624787.zip
Feature #5855 -- undefined method 'withenv' in FreeBSD package provider.
The FreeBSD package provider fails to install when any source is given, yielding instead an 'undefined method' error. This adds tests that prove the bug exists.
Diffstat (limited to 'spec/unit/provider/package/freebsd_spec.rb')
-rwxr-xr-xspec/unit/provider/package/freebsd_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/unit/provider/package/freebsd_spec.rb b/spec/unit/provider/package/freebsd_spec.rb
new file mode 100755
index 000000000..0d38a16cf
--- /dev/null
+++ b/spec/unit/provider/package/freebsd_spec.rb
@@ -0,0 +1,55 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider_class = Puppet::Type.type(:package).provider(:freebsd)
+
+describe provider_class do
+ before :each do
+ # Create a mock resource
+ @resource = stub 'resource'
+
+ # A catch all; no parameters set
+ @resource.stubs(:[]).returns(nil)
+
+ # But set name and source
+ @resource.stubs(:[]).with(:name).returns "mypackage"
+ @resource.stubs(:[]).with(:ensure).returns :installed
+
+ @provider = provider_class.new
+ @provider.resource = @resource
+ end
+
+ it "should have an install method" do
+ @provider = provider_class.new
+ @provider.should respond_to(:install)
+ end
+
+ describe "when installing" do
+ before :each do
+ @resource.stubs(:should).with(:ensure).returns(:installed)
+ end
+
+ it "should install a package from a path to a directory" do
+ # For better or worse, trailing '/' is needed. --daniel 2011-01-26
+ path = '/path/to/directory/'
+ @resource.stubs(:[]).with(:source).returns(path)
+ Puppet::Util::Execution.expects(:withenv).once.with({:PKG_PATH => path}).yields
+ @provider.expects(:pkgadd).once.with("mypackage")
+
+ expect { @provider.install }.should_not raise_error
+ end
+
+ %w{http https ftp}.each do |protocol|
+ it "should install a package via #{protocol}" do
+ # For better or worse, trailing '/' is needed. --daniel 2011-01-26
+ path = "#{protocol}://localhost/"
+ @resource.stubs(:[]).with(:source).returns(path)
+ Puppet::Util::Execution.expects(:withenv).once.with({:PACKAGESITE => path}).yields
+ @provider.expects(:pkgadd).once.with('-r', "mypackage")
+
+ expect { @provider.install }.should_not raise_error
+ end
+ end
+ end
+end