summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-05-16 16:08:56 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-05-16 16:08:56 +1000
commit7897335318be2bb98187b570fb7c867ebe109c12 (patch)
treec337fc64373fa3424e0449907ca46ea142345ca3 /spec
parent83ef1b0cda1b010eea3f7d001716ea52f7081c24 (diff)
parenta1409d73b4bb8acbf5db2f8d7a244c2bca81db14 (diff)
downloadpuppet-7897335318be2bb98187b570fb7c867ebe109c12.tar.gz
puppet-7897335318be2bb98187b570fb7c867ebe109c12.tar.xz
puppet-7897335318be2bb98187b570fb7c867ebe109c12.zip
Merge branch '0.24.x' of git://github.com/lak/puppet into 0.24.x
Diffstat (limited to 'spec')
-rwxr-xr-xspec/integration/type/package.rb (renamed from spec/integration/ral/types/package.rb)2
-rwxr-xr-xspec/unit/indirector/node/ldap.rb91
-rwxr-xr-xspec/unit/provider/confine.rb225
-rwxr-xr-xspec/unit/provider/confine_collection.rb113
-rwxr-xr-xspec/unit/provider/confiner.rb62
-rwxr-xr-xspec/unit/provider/interface/redhat.rb (renamed from spec/unit/ral/provider/interface/redhat.rb)2
-rwxr-xr-xspec/unit/provider/interface/sunos.rb (renamed from spec/unit/ral/provider/interface/sunos.rb)2
-rwxr-xr-xspec/unit/provider/mount.rb (renamed from spec/unit/ral/provider/mount.rb)2
-rwxr-xr-xspec/unit/provider/mount/parsed.rb (renamed from spec/unit/ral/provider/mount/parsed.rb)2
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed.rb (renamed from spec/unit/ral/provider/ssh_authorized_key/parsed.rb)2
-rwxr-xr-xspec/unit/type.rb (renamed from spec/unit/ral/type.rb)2
-rwxr-xr-xspec/unit/type/exec.rb (renamed from spec/unit/ral/type/exec.rb)2
-rwxr-xr-xspec/unit/type/file.rb (renamed from spec/unit/ral/type/file.rb)2
-rwxr-xr-xspec/unit/type/interface.rb (renamed from spec/unit/ral/type/interface.rb)2
-rwxr-xr-xspec/unit/type/mount.rb (renamed from spec/unit/ral/type/mount.rb)52
-rwxr-xr-xspec/unit/type/nagios.rb (renamed from spec/unit/ral/type/nagios.rb)2
-rwxr-xr-xspec/unit/type/noop_metaparam.rb (renamed from spec/unit/ral/type/noop_metaparam.rb)2
-rwxr-xr-xspec/unit/type/package.rb (renamed from spec/unit/ral/type/package.rb)2
-rwxr-xr-xspec/unit/type/schedule.rb (renamed from spec/unit/ral/type/schedule.rb)2
-rwxr-xr-xspec/unit/type/service.rb (renamed from spec/unit/ral/type/service.rb)2
-rwxr-xr-xspec/unit/type/ssh_authorized_key.rb (renamed from spec/unit/ral/type/ssh_authorized_key.rb)2
-rwxr-xr-xspec/unit/type/user.rb (renamed from spec/unit/ral/type/user.rb)12
22 files changed, 537 insertions, 50 deletions
diff --git a/spec/integration/ral/types/package.rb b/spec/integration/type/package.rb
index 20567629d..c244fa1cd 100755
--- a/spec/integration/ral/types/package.rb
+++ b/spec/integration/type/package.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/type/package'
diff --git a/spec/unit/indirector/node/ldap.rb b/spec/unit/indirector/node/ldap.rb
index a40698662..878039c7c 100755
--- a/spec/unit/indirector/node/ldap.rb
+++ b/spec/unit/indirector/node/ldap.rb
@@ -17,6 +17,7 @@ describe Puppet::Node::Ldap do
@searcher.stubs(:connection).returns(@connection)
@searcher.stubs(:class_attributes).returns([])
@searcher.stubs(:parent_attribute).returns(nil)
+ @searcher.stubs(:stacked_attributes).returns([])
@searcher.stubs(:search_base).returns(:yay)
@searcher.stubs(:search_filter).returns(:filter)
@@ -195,6 +196,96 @@ describe Puppet::Node::Ldap do
proc { @searcher.find(@request) }.should raise_error(ArgumentError)
end
end
+
+ describe "and a puppet variable is specified" do
+ before do
+ @searcher.stubs(:stacked_attributes).returns(['puppetvar'])
+ end
+
+ it "should add the variable to the node parameters" do
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=two})
+ @entry.stubs(:to_hash).returns({})
+ @node.expects(:parameters=).with("one" => "two")
+ @searcher.find(@request)
+ end
+
+ it "should not overwrite node parameters specified as ldap object attribute" do
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=two})
+ @entry.stubs(:to_hash).returns("one" => "three")
+ @node.expects(:parameters=).with("one" => "three")
+ @searcher.find(@request)
+ end
+
+ it "should set entries without an equal sign to nil" do
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one})
+ @entry.stubs(:to_hash).returns({})
+ @node.expects(:parameters=).with("one" => nil)
+ @searcher.find(@request)
+ end
+
+ it "should ignore empty entries" do
+ @entry.stubs(:vals).with("puppetvar").returns(%w{})
+ @entry.stubs(:to_hash).returns({})
+ @searcher.find(@request)
+ end
+ end
+ describe "and a puppet variable as well as a parent node are specified" do
+ before do
+ @parent = mock 'parent'
+
+ @searcher.meta_def(:search_filter) do |name|
+ return name
+ end
+ @connection.stubs(:search).with { |*args| args[2] == @name }.yields(@entry)
+ @connection.stubs(:search).with { |*args| args[2] == 'parent' }.yields(@parent)
+
+ @searcher.stubs(:stacked_attributes).returns(['puppetvar'])
+ @searcher.stubs(:parent_attribute).returns(:parent)
+ end
+
+ it "should add parent node variables to the child node parameters" do
+ @parent.stubs(:to_hash).returns({})
+ @parent.stubs(:vals).with("puppetvar").returns(%w{one=two})
+ @parent.stubs(:vals).with(:parent).returns(nil)
+
+ @entry.stubs(:to_hash).returns({})
+ @entry.stubs(:vals).with("puppetvar").returns(%w{})
+ @entry.stubs(:vals).with(:parent).returns(%w{parent})
+
+ @node.expects(:parameters=).with("one" => "two")
+
+ @searcher.find(@request)
+ end
+
+ it "should overwrite parent node variables with child node parameters" do
+ @parent.stubs(:to_hash).returns({})
+ @parent.stubs(:vals).with("puppetvar").returns(%w{one=two})
+ @parent.stubs(:vals).with(:parent).returns(nil)
+
+ @entry.stubs(:to_hash).returns({})
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=three})
+ @entry.stubs(:vals).with(:parent).returns(%w{parent})
+
+ @node.expects(:parameters=).with("one" => "three")
+
+ @searcher.find(@request)
+ end
+
+ it "should not overwrite parent node parameters specified as ldap object attribute" do
+ @parent.stubs(:to_hash).returns("one" => "three")
+ @parent.stubs(:vals).with("puppetvar").returns(%w{})
+ @parent.stubs(:vals).with(:parent).returns(nil)
+
+ @entry.stubs(:vals).with("puppetvar").returns(%w{one=two})
+ @entry.stubs(:to_hash).returns({})
+ @entry.stubs(:vals).with(:parent).returns(%w{parent})
+
+ @node.expects(:parameters=).with("one" => "three")
+
+ @searcher.find(@request)
+ end
+
+ end
end
end
diff --git a/spec/unit/provider/confine.rb b/spec/unit/provider/confine.rb
new file mode 100755
index 000000000..bb2e751d6
--- /dev/null
+++ b/spec/unit/provider/confine.rb
@@ -0,0 +1,225 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/provider/confine'
+
+describe Puppet::Provider::Confine do
+ it "should require a test" do
+ lambda { Puppet::Provider::Confine.new }.should raise_error(ArgumentError)
+ end
+
+ it "should require a value" do
+ lambda { Puppet::Provider::Confine.new(:exists) }.should raise_error(ArgumentError)
+ end
+
+ it "should have a test" do
+ Puppet::Provider::Confine.new(:exists, "/some/file").test.should == :exists
+ end
+
+ it "should always convert values to an array" do
+ Puppet::Provider::Confine.new(:exists, "/some/file").values.should be_instance_of(Array)
+ end
+
+ it "should have an accessor for its fact" do
+ Puppet::Provider::Confine.new(:foo, :bar).should respond_to(:fact)
+ end
+
+ it "should be possible to mark the confine as a binary test" do
+ Puppet::Provider::Confine.new(:foo, :bar).should respond_to(:for_binary=)
+ end
+
+ it "should have a boolean method to indicate it's a binary confine" do
+ Puppet::Provider::Confine.new(:foo, :bar).should respond_to(:for_binary?)
+ end
+
+ it "should indicate it's a boolean confine if it has been marked that way" do
+ confine = Puppet::Provider::Confine.new(:foo, :bar)
+ confine.for_binary = true
+ confine.should be_for_binary
+ end
+
+ it "should have a method for returning a binary's path" do
+ Puppet::Provider::Confine.new(:foo, :bar).private_methods.should be_include("binary")
+ end
+
+ describe "when testing values" do
+ before { @confine = Puppet::Provider::Confine.new("eh", "foo") }
+
+ describe "and the test is 'false'" do
+ it "should use the 'false?' method to test validity" do
+ @confine = Puppet::Provider::Confine.new(:false, "foo")
+ @confine.expects(:false?).with("foo")
+ @confine.valid?
+ end
+
+ it "should return true if the value is false" do
+ @confine.false?(false).should be_true
+ end
+
+ it "should return false if the value is not false" do
+ @confine.false?("else").should be_false
+ end
+
+ it "should log that a value is false" do
+ @confine = Puppet::Provider::Confine.new(:false, "foo")
+ Puppet.expects(:debug).with { |l| l.include?("false") }
+ @confine.valid?
+ end
+ end
+
+ describe "and the test is 'true'" do
+ it "should use the 'true?' method to test validity" do
+ @confine = Puppet::Provider::Confine.new(:true, "foo")
+ @confine.expects(:true?).with("foo")
+ @confine.valid?
+ end
+
+ it "should return true if the value is not false" do
+ @confine.true?("else").should be_true
+ end
+
+ it "should return false if the value is false" do
+ @confine.true?(nil).should be_false
+ end
+ end
+
+ describe "and the test is 'exists'" do
+ it "should use the 'exists?' method to test validity" do
+ @confine = Puppet::Provider::Confine.new(:exists, "foo")
+ @confine.expects(:exists?).with("foo")
+ @confine.valid?
+ end
+
+ it "should return false if the value is false" do
+ @confine.exists?(false).should be_false
+ end
+
+ it "should return false if the value does not point to a file" do
+ FileTest.expects(:exist?).with("/my/file").returns false
+ @confine.exists?("/my/file").should be_false
+ end
+
+ it "should return true if the value points to a file" do
+ FileTest.expects(:exist?).with("/my/file").returns true
+ @confine.exists?("/my/file").should be_true
+ end
+
+ it "should log that a value is true" do
+ @confine = Puppet::Provider::Confine.new(:true, nil)
+ Puppet.expects(:debug).with { |l| l.include?("true") }
+ @confine.valid?
+ end
+
+ describe "and the confine is for binaries" do
+ before { @confine.stubs(:for_binary).returns true }
+ it "should use its 'binary' method to look up the full path of the file" do
+ @confine.expects(:binary).returns nil
+ @confine.exists?("/my/file")
+ end
+
+ it "should return false if no binary can be found" do
+ @confine.expects(:binary).with("/my/file").returns nil
+ @confine.exists?("/my/file").should be_false
+ end
+
+ it "should return true if the binary can be found and the file exists" do
+ @confine.expects(:binary).with("/my/file").returns "/my/file"
+ FileTest.expects(:exist?).with("/my/file").returns true
+ @confine.exists?("/my/file").should be_true
+ end
+
+ it "should return false if the binary can be found but the file does not exist" do
+ @confine.expects(:binary).with("/my/file").returns "/my/file"
+ FileTest.expects(:exist?).with("/my/file").returns true
+ @confine.exists?("/my/file").should be_true
+ end
+ end
+ end
+
+ describe "and the test is not 'true', 'false', or 'exists'" do
+ it "should use the 'match?' method to test validity" do
+ @confine = Puppet::Provider::Confine.new("yay", "foo")
+ @confine.expects(:match?).with("foo")
+ @confine.valid?
+ end
+
+ it "should return true if the value matches the facter value" do
+ Facter.expects(:value).returns("foo")
+
+ @confine.match?("foo").should be_true
+ end
+
+ it "should return false if the value does not match the facter value" do
+ Facter.expects(:value).returns("boo")
+
+ @confine.match?("foo").should be_false
+ end
+
+ it "should be case insensitive" do
+ Facter.expects(:value).returns("FOO")
+
+ @confine.match?("foo").should be_true
+ end
+
+ it "should not care whether the value is a string or symbol" do
+ Facter.expects(:value).returns("FOO")
+
+ @confine.match?(:foo).should be_true
+ end
+
+ it "should cache the fact during testing" do
+ Facter.expects(:value).once.returns("FOO")
+
+ @confine.match?(:foo)
+ @confine.match?(:foo)
+ end
+
+ it "should log that the fact value is not correct" do
+ @confine = Puppet::Provider::Confine.new("foo", ["bar", "bee"])
+ Facter.expects(:value).with("foo").returns "yayness"
+ Puppet.expects(:debug).with { |l| l.include?("facter") and l.include?("bar,bee") }
+ @confine.valid?
+ end
+ end
+ end
+
+ describe "when testing all values" do
+ before { @confine = Puppet::Provider::Confine.new(:true, %w{a b c}) }
+
+ it "should be invalid if any values fail" do
+ @confine.stubs(:true?).returns true
+ @confine.expects(:true?).with("b").returns false
+ @confine.should_not be_valid
+ end
+
+ it "should be valid if all values pass" do
+ @confine.stubs(:true?).returns true
+ @confine.should be_valid
+ end
+
+ it "should short-cut at the first failing value" do
+ @confine.expects(:true?).once.returns false
+ @confine.valid?
+ end
+
+ it "should remove the cached facter value" do
+ @confine = Puppet::Provider::Confine.new(:foo, :bar)
+ Facter.expects(:value).with(:foo).times(2).returns "eh"
+ @confine.valid?
+ @confine.valid?
+ end
+ end
+
+ describe "when testing the result of the values" do
+ before { @confine = Puppet::Provider::Confine.new(:true, %w{a b c d}) }
+
+ it "should return an array with the result of the test for each value" do
+ @confine.stubs(:true?).returns true
+ @confine.expects(:true?).with("b").returns false
+ @confine.expects(:true?).with("d").returns false
+
+ @confine.result.should == [true, false, true, false]
+ end
+ end
+end
diff --git a/spec/unit/provider/confine_collection.rb b/spec/unit/provider/confine_collection.rb
new file mode 100755
index 000000000..3430d604f
--- /dev/null
+++ b/spec/unit/provider/confine_collection.rb
@@ -0,0 +1,113 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/provider/confine_collection'
+
+describe Puppet::Provider::ConfineCollection do
+ it "should be able to add confines" do
+ Puppet::Provider::ConfineCollection.new.should respond_to(:confine)
+ end
+
+ it "should create a Confine instance for every confine call" do
+ Puppet::Provider::Confine.expects(:new).with(:foo, :bar).returns "eh"
+ Puppet::Provider::Confine.expects(:new).with(:baz, :bee).returns "eh"
+ Puppet::Provider::ConfineCollection.new.confine :foo => :bar, :baz => :bee
+ end
+
+ it "should mark each confine as a binary confine if :for_binary => true is included" do
+ confine = mock 'confine'
+ confine.expects(:for_binary=).with true
+ Puppet::Provider::Confine.expects(:new).with(:foo, :bar).returns confine
+ Puppet::Provider::ConfineCollection.new.confine :foo => :bar, :for_binary => true
+ end
+
+ it "should be valid if no confines are present" do
+ Puppet::Provider::ConfineCollection.new.should be_valid
+ end
+
+ it "should be valid if all confines are valid" do
+ c1 = mock 'c1', :valid? => true
+ c2 = mock 'c2', :valid? => true
+
+ Puppet::Provider::Confine.expects(:new).times(2).returns(c1).then.returns(c2)
+
+ confiner = Puppet::Provider::ConfineCollection.new
+ confiner.confine :foo => :bar, :baz => :bee
+
+ confiner.should be_valid
+ end
+
+ it "should not be valid if any confines are valid" do
+ c1 = mock 'c1', :valid? => true
+ c2 = mock 'c2', :valid? => false
+
+ Puppet::Provider::Confine.expects(:new).times(2).returns(c1).then.returns(c2)
+
+ confiner = Puppet::Provider::ConfineCollection.new
+ confiner.confine :foo => :bar, :baz => :bee
+
+ confiner.should_not be_valid
+ end
+
+ describe "when providing a complete result" do
+ before do
+ @confiner = Puppet::Provider::ConfineCollection.new
+ end
+
+ it "should return a hash" do
+ @confiner.result.should be_instance_of(Hash)
+ end
+
+ it "should return an empty hash if the confiner is valid" do
+ @confiner.result.should == {}
+ end
+
+ it "should contain the number of incorrectly false values" do
+ c1 = stub 'c1', :result => [true, false, true], :test => :true
+ c2 = stub 'c2', :result => [false, true, false], :test => :true
+
+ Puppet::Provider::Confine.expects(:new).times(2).returns(c1).then.returns(c2)
+
+ confiner = Puppet::Provider::ConfineCollection.new
+ confiner.confine :foo => :bar, :baz => :bee
+
+ confiner.result[:true].should == 3
+ end
+
+ it "should contain the number of incorrectly true values" do
+ c1 = stub 'c1', :result => [true, false, true], :test => :false
+ c2 = stub 'c2', :result => [false, true, false], :test => :false
+
+ Puppet::Provider::Confine.expects(:new).times(2).returns(c1).then.returns(c2)
+
+ confiner = Puppet::Provider::ConfineCollection.new
+ confiner.confine :foo => :bar, :baz => :bee
+
+ confiner.result[:false].should == 3
+ end
+
+ it "should contain the missing files" do
+ FileTest.stubs(:exist?).returns true
+ FileTest.expects(:exist?).with("/two").returns false
+ FileTest.expects(:exist?).with("/four").returns false
+
+ confiner = Puppet::Provider::ConfineCollection.new
+ confiner.confine :exists => %w{/one /two}
+ confiner.confine :exists => %w{/three /four}
+
+ confiner.result[:exists].should == %w{/two /four}
+ end
+
+ it "should contain a hash of facts and the allowed values" do
+ Facter.expects(:value).with(:foo).returns "yay"
+ Facter.expects(:value).with(:bar).returns "boo"
+ confiner = Puppet::Provider::ConfineCollection.new
+ confiner.confine :foo => "yes", :bar => "boo"
+
+ result = confiner.result
+ result[:facter][:foo].should == %w{yes}
+ result[:facter][:bar].should be_nil
+ end
+ end
+end
diff --git a/spec/unit/provider/confiner.rb b/spec/unit/provider/confiner.rb
new file mode 100755
index 000000000..38fffc102
--- /dev/null
+++ b/spec/unit/provider/confiner.rb
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/provider/confiner'
+
+describe Puppet::Provider::Confiner do
+ before do
+ @object = Object.new
+ @object.extend(Puppet::Provider::Confiner)
+ end
+
+ it "should have a method for defining confines" do
+ @object.should respond_to(:confine)
+ end
+
+ it "should have a method for returning its confine collection" do
+ @object.should respond_to(:confine_collection)
+ end
+
+ it "should have a method for testing suitability" do
+ @object.should respond_to(:suitable?)
+ end
+
+ it "should delegate its confine method to its confine collection" do
+ coll = mock 'collection'
+ @object.stubs(:confine_collection).returns coll
+ coll.expects(:confine).with(:foo => :bar, :bee => :baz)
+ @object.confine(:foo => :bar, :bee => :baz)
+ end
+
+ it "should create a new confine collection if one does not exist" do
+ Puppet::Provider::ConfineCollection.expects(:new).returns "mycoll"
+ @object.confine_collection.should == "mycoll"
+ end
+
+ it "should reuse the confine collection" do
+ @object.confine_collection.should equal(@object.confine_collection)
+ end
+
+ describe "when testing suitability" do
+ before do
+ @coll = mock 'collection'
+ @object.stubs(:confine_collection).returns @coll
+ end
+
+ it "should return true if the confine collection is valid" do
+ @coll.expects(:valid?).returns true
+ @object.should be_suitable
+ end
+
+ it "should return false if the confine collection is invalid" do
+ @coll.expects(:valid?).returns false
+ @object.should_not be_suitable
+ end
+
+ it "should return the result of the confine collection if a long result is asked for" do
+ @coll.expects(:result).returns "myresult"
+ @object.suitable?(false).should == "myresult"
+ end
+ end
+end
diff --git a/spec/unit/ral/provider/interface/redhat.rb b/spec/unit/provider/interface/redhat.rb
index 9bf1b9722..5a7a8dfcd 100755
--- a/spec/unit/ral/provider/interface/redhat.rb
+++ b/spec/unit/provider/interface/redhat.rb
@@ -3,7 +3,7 @@
# Created by Luke Kanies on 2007-11-20.
# Copyright (c) 2006. All rights reserved.
-require File.dirname(__FILE__) + '/../../../../spec_helper'
+require File.dirname(__FILE__) + '/../../../spec_helper'
provider_class = Puppet::Type.type(:interface).provider(:redhat)
diff --git a/spec/unit/ral/provider/interface/sunos.rb b/spec/unit/provider/interface/sunos.rb
index 7b9f462e6..6a7bd19c1 100755
--- a/spec/unit/ral/provider/interface/sunos.rb
+++ b/spec/unit/provider/interface/sunos.rb
@@ -3,7 +3,7 @@
# Created by Luke Kanies on 2007-11-25.
# Copyright (c) 2006. All rights reserved.
-require File.dirname(__FILE__) + '/../../../../spec_helper'
+require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/provider/interface/sunos'
diff --git a/spec/unit/ral/provider/mount.rb b/spec/unit/provider/mount.rb
index 0b90d53c9..41abcd424 100755
--- a/spec/unit/ral/provider/mount.rb
+++ b/spec/unit/provider/mount.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/provider/mount'
diff --git a/spec/unit/ral/provider/mount/parsed.rb b/spec/unit/provider/mount/parsed.rb
index 21276d911..ba65b70a4 100755
--- a/spec/unit/ral/provider/mount/parsed.rb
+++ b/spec/unit/provider/mount/parsed.rb
@@ -3,7 +3,7 @@
# Created by Luke Kanies on 2007-9-12.
# Copyright (c) 2006. All rights reserved.
-require File.dirname(__FILE__) + '/../../../../spec_helper'
+require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppettest/support/utils'
require 'puppettest/fileparsing'
diff --git a/spec/unit/ral/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb
index 459001cb5..c35ddc513 100755
--- a/spec/unit/ral/provider/ssh_authorized_key/parsed.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../../spec_helper'
+require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppettest'
require 'puppettest/support/utils'
diff --git a/spec/unit/ral/type.rb b/spec/unit/type.rb
index 5980167d6..9815ed32d 100755
--- a/spec/unit/ral/type.rb
+++ b/spec/unit/type.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/../spec_helper'
describe Puppet::Type, " when in a configuration" do
before do
diff --git a/spec/unit/ral/type/exec.rb b/spec/unit/type/exec.rb
index 260804227..cf0e02929 100755
--- a/spec/unit/ral/type/exec.rb
+++ b/spec/unit/type/exec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/type/exec'
diff --git a/spec/unit/ral/type/file.rb b/spec/unit/type/file.rb
index e1a597434..12b806d88 100755
--- a/spec/unit/ral/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
describe Puppet::Type.type(:file) do
before do
diff --git a/spec/unit/ral/type/interface.rb b/spec/unit/type/interface.rb
index 2e0176152..27f34b7e0 100755
--- a/spec/unit/ral/type/interface.rb
+++ b/spec/unit/type/interface.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
interface = Puppet::Type.type(:interface)
diff --git a/spec/unit/ral/type/mount.rb b/spec/unit/type/mount.rb
index 8fa2e6f7c..a9b78672e 100755
--- a/spec/unit/ral/type/mount.rb
+++ b/spec/unit/type/mount.rb
@@ -1,77 +1,75 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
-require 'puppet/type/mount'
-
-describe Puppet::Type::Mount do
+describe Puppet::Type.type(:mount) do
it "should have a :refreshable feature that requires the :remount method" do
- Puppet::Type::Mount.provider_feature(:refreshable).methods.should == [:remount]
+ Puppet::Type.type(:mount).provider_feature(:refreshable).methods.should == [:remount]
end
it "should have no default value for :ensure" do
- mount = Puppet::Type::Mount.create(:name => "yay")
+ mount = Puppet::Type.type(:mount).create(:name => "yay")
mount.should(:ensure).should be_nil
end
- after { Puppet::Type::Mount.clear }
+ after { Puppet::Type.type(:mount).clear }
end
-describe Puppet::Type::Mount, "when validating attributes" do
+describe Puppet::Type.type(:mount), "when validating attributes" do
[:name, :remounts].each do |param|
it "should have a #{param} parameter" do
- Puppet::Type::Mount.attrtype(param).should == :param
+ Puppet::Type.type(:mount).attrtype(param).should == :param
end
end
[:ensure, :device, :blockdevice, :fstype, :options, :pass, :dump, :atboot, :target].each do |param|
it "should have a #{param} property" do
- Puppet::Type::Mount.attrtype(param).should == :property
+ Puppet::Type.type(:mount).attrtype(param).should == :property
end
end
end
-describe Puppet::Type::Mount::Ensure, "when validating values" do
+describe Puppet::Type.type(:mount)::Ensure, "when validating values" do
before do
- @provider = stub 'provider', :class => Puppet::Type::Mount.defaultprovider, :clear => nil
- Puppet::Type::Mount.defaultprovider.expects(:new).returns(@provider)
+ @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil
+ Puppet::Type.type(:mount).defaultprovider.expects(:new).returns(@provider)
end
it "should support :present as a value to :ensure" do
- Puppet::Type::Mount.create(:name => "yay", :ensure => :present)
+ Puppet::Type.type(:mount).create(:name => "yay", :ensure => :present)
end
it "should alias :unmounted to :present as a value to :ensure" do
- mount = Puppet::Type::Mount.create(:name => "yay", :ensure => :unmounted)
+ mount = Puppet::Type.type(:mount).create(:name => "yay", :ensure => :unmounted)
mount.should(:ensure).should == :present
end
it "should support :absent as a value to :ensure" do
- Puppet::Type::Mount.create(:name => "yay", :ensure => :absent)
+ Puppet::Type.type(:mount).create(:name => "yay", :ensure => :absent)
end
it "should support :mounted as a value to :ensure" do
- Puppet::Type::Mount.create(:name => "yay", :ensure => :mounted)
+ Puppet::Type.type(:mount).create(:name => "yay", :ensure => :mounted)
end
- after { Puppet::Type::Mount.clear }
+ after { Puppet::Type.type(:mount).clear }
end
-describe Puppet::Type::Mount::Ensure do
+describe Puppet::Type.type(:mount)::Ensure do
before :each do
- @provider = stub 'provider', :class => Puppet::Type::Mount.defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
- Puppet::Type::Mount.defaultprovider.stubs(:new).returns(@provider)
- @mount = Puppet::Type::Mount.create(:name => "yay", :check => :ensure)
+ @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
+ Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider)
+ @mount = Puppet::Type.type(:mount).create(:name => "yay", :check => :ensure)
@ensure = @mount.property(:ensure)
end
after :each do
- Puppet::Type::Mount.clear
+ Puppet::Type.type(:mount).clear
end
def mount_stub(params)
- Puppet::Type::Mount.validproperties.each do |prop|
+ Puppet::Type.type(:mount).validproperties.each do |prop|
unless params[prop]
params[prop] = :absent
@mount[prop] = :absent
@@ -83,7 +81,7 @@ describe Puppet::Type::Mount::Ensure do
end
end
- describe Puppet::Type::Mount::Ensure, "when retrieving its current state" do
+ describe Puppet::Type.type(:mount)::Ensure, "when retrieving its current state" do
it "should return the provider's value if it is :absent" do
@provider.expects(:ensure).returns(:absent)
@@ -103,7 +101,7 @@ describe Puppet::Type::Mount::Ensure do
end
end
- describe Puppet::Type::Mount::Ensure, "when changing the host" do
+ describe Puppet::Type.type(:mount)::Ensure, "when changing the host" do
it "should destroy itself if it should be absent" do
@provider.stubs(:mounted?).returns(false)
@@ -166,7 +164,7 @@ describe Puppet::Type::Mount::Ensure do
end
end
- describe Puppet::Type::Mount, "when responding to events" do
+ describe Puppet::Type.type(:mount), "when responding to events" do
it "should remount if it is currently mounted" do
@provider.expects(:mounted?).returns(true)
diff --git a/spec/unit/ral/type/nagios.rb b/spec/unit/type/nagios.rb
index 35f00b0e5..563c82c2f 100755
--- a/spec/unit/ral/type/nagios.rb
+++ b/spec/unit/type/nagios.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/external/nagios'
diff --git a/spec/unit/ral/type/noop_metaparam.rb b/spec/unit/type/noop_metaparam.rb
index 0cbed3714..2a3e0160d 100755
--- a/spec/unit/ral/type/noop_metaparam.rb
+++ b/spec/unit/type/noop_metaparam.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/metatype/metaparams'
diff --git a/spec/unit/ral/type/package.rb b/spec/unit/type/package.rb
index 5d96dc4ae..335910c63 100755
--- a/spec/unit/ral/type/package.rb
+++ b/spec/unit/type/package.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/type/package'
diff --git a/spec/unit/ral/type/schedule.rb b/spec/unit/type/schedule.rb
index 4e9840c34..da38f68a9 100755
--- a/spec/unit/ral/type/schedule.rb
+++ b/spec/unit/type/schedule.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/type/schedule'
diff --git a/spec/unit/ral/type/service.rb b/spec/unit/type/service.rb
index 0f00992fa..e8358cb22 100755
--- a/spec/unit/ral/type/service.rb
+++ b/spec/unit/type/service.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/type/service'
diff --git a/spec/unit/ral/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb
index d27cb9f25..0e869747d 100755
--- a/spec/unit/ral/type/ssh_authorized_key.rb
+++ b/spec/unit/type/ssh_authorized_key.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
ssh_authorized_key = Puppet::Type.type(:ssh_authorized_key)
diff --git a/spec/unit/ral/type/user.rb b/spec/unit/type/user.rb
index 4e43a8ceb..d16d752f9 100755
--- a/spec/unit/ral/type/user.rb
+++ b/spec/unit/type/user.rb
@@ -1,14 +1,12 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
-
-require 'puppet/type/user'
+require File.dirname(__FILE__) + '/../../spec_helper'
module UserTestFunctions
def mkuser(name)
user = nil;
lambda {
- user = Puppet::Type::User.create(
+ user = Puppet::Type.type(:user).create(
:name => name,
:comment => "Puppet Testing User",
:gid => Puppet::Util::SUIDManager.gid,
@@ -30,12 +28,12 @@ module UserTestFunctions
end
end
-describe Puppet::Type::User do
+describe Puppet::Type.type(:user) do
include UserTestFunctions
it "should have a default provider inheriting from Puppet::Provider" do
- test_provider_class Puppet::Type::User.defaultprovider
+ test_provider_class Puppet::Type.type(:user).defaultprovider
end
it "should be able to create a instance" do
@@ -43,7 +41,7 @@ describe Puppet::Type::User do
end
end
-describe Puppet::Type::User, "instances" do
+describe Puppet::Type.type(:user), "instances" do
include UserTestFunctions