summaryrefslogtreecommitdiff
path: root/spec/unit/type
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/type')
-rw-r--r--spec/unit/type/augeas.rb14
-rwxr-xr-xspec/unit/type/computer.rb8
-rwxr-xr-xspec/unit/type/exec.rb2
-rwxr-xr-xspec/unit/type/file.rb24
-rwxr-xr-xspec/unit/type/group.rb2
-rwxr-xr-xspec/unit/type/macauthorization.rb6
-rwxr-xr-xspec/unit/type/mcx.rb12
-rwxr-xr-xspec/unit/type/mount.rb14
-rwxr-xr-xspec/unit/type/package.rb24
-rw-r--r--spec/unit/type/resources.rb6
-rwxr-xr-xspec/unit/type/schedule.rb2
-rwxr-xr-xspec/unit/type/selboolean.rb8
-rwxr-xr-xspec/unit/type/service.rb46
-rwxr-xr-xspec/unit/type/ssh_authorized_key.rb20
-rwxr-xr-xspec/unit/type/tidy.rb30
-rwxr-xr-xspec/unit/type/user.rb10
-rwxr-xr-xspec/unit/type/zfs.rb8
17 files changed, 118 insertions, 118 deletions
diff --git a/spec/unit/type/augeas.rb b/spec/unit/type/augeas.rb
index d91ff631a..4a605f8f2 100644
--- a/spec/unit/type/augeas.rb
+++ b/spec/unit/type/augeas.rb
@@ -13,7 +13,7 @@ describe augeas do
end
it "should have a valid provider" do
- augeas.create(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
+ augeas.new(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
end
end
@@ -21,7 +21,7 @@ describe augeas do
it "should be able to create a instance" do
provider_class = Puppet::Type::Augeas.provider(Puppet::Type::Augeas.providers[0])
Puppet::Type::Augeas.expects(:defaultprovider).returns provider_class
- augeas.create(:name => "bar").should_not be_nil
+ augeas.new(:name => "bar").should_not be_nil
end
it "should have an parse_commands feature" do
@@ -67,23 +67,23 @@ describe augeas do
end
it "should be blank for context" do
- augeas.create(:name => :context)[:context].should == ""
+ augeas.new(:name => :context)[:context].should == ""
end
it "should be blank for onlyif" do
- augeas.create(:name => :onlyif)[:onlyif].should == ""
+ augeas.new(:name => :onlyif)[:onlyif].should == ""
end
it "should be blank for load_path" do
- augeas.create(:name => :load_path)[:load_path].should == ""
+ augeas.new(:name => :load_path)[:load_path].should == ""
end
it "should be / for root" do
- augeas.create(:name => :root)[:root].should == "/"
+ augeas.new(:name => :root)[:root].should == "/"
end
it "should be false for type_check" do
- augeas.create(:name => :type_check)[:type_check].should == :false
+ augeas.new(:name => :type_check)[:type_check].should == :false
end
end
diff --git a/spec/unit/type/computer.rb b/spec/unit/type/computer.rb
index bfb04250b..26299487e 100755
--- a/spec/unit/type/computer.rb
+++ b/spec/unit/type/computer.rb
@@ -8,7 +8,7 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
before do
provider_class = Puppet::Type::Computer.provider(Puppet::Type::Computer.providers[0])
Puppet::Type::Computer.expects(:defaultprovider).returns provider_class
- @resource = Puppet::Type::Computer.create(
+ @resource = Puppet::Type::Computer.new(
:name => "puppetcomputertest",
:en_address => "aa:bb:cc:dd:ee:ff",
:ip_address => "1.2.3.4")
@@ -19,7 +19,7 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
it "should be able to create a instance" do
provider_class = Puppet::Type::Computer.provider(Puppet::Type::Computer.providers[0])
Puppet::Type::Computer.expects(:defaultprovider).returns provider_class
- computer.create(:name => "bar").should_not be_nil
+ computer.new(:name => "bar").should_not be_nil
end
properties = [:en_address, :ip_address]
@@ -58,11 +58,11 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do
end
it "should be nil for en_address" do
- computer.create(:name => :en_address)[:en_address].should == nil
+ computer.new(:name => :en_address)[:en_address].should == nil
end
it "should be nil for ip_address" do
- computer.create(:name => :ip_address)[:ip_address].should == nil
+ computer.new(:name => :ip_address)[:ip_address].should == nil
end
end
diff --git a/spec/unit/type/exec.rb b/spec/unit/type/exec.rb
index c6c082dd5..5f2fe5fa8 100755
--- a/spec/unit/type/exec.rb
+++ b/spec/unit/type/exec.rb
@@ -7,7 +7,7 @@ module ExecModuleTesting
@user_name = 'some_user_name'
@group_name = 'some_group_name'
Puppet.features.stubs(:root?).returns(true)
- @execer = Puppet::Type.type(:exec).create(:name => command, :path => %w{/usr/bin /bin}, :user => @user_name, :group => @group_name)
+ @execer = Puppet::Type.type(:exec).new(:name => command, :path => %w{/usr/bin /bin}, :user => @user_name, :group => @group_name)
status = stub "process"
status.stubs(:exitstatus).returns(exitstatus)
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 838a8b663..631284e3b 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -7,7 +7,7 @@ describe Puppet::Type.type(:file) do
@path = Tempfile.new("puppetspec")
@path.close!()
@path = @path.path
- @file = Puppet::Type::File.create(:name => @path)
+ @file = Puppet::Type::File.new(:name => @path)
@catalog = mock 'catalog'
@catalog.stub_everything
@@ -101,7 +101,7 @@ describe Puppet::Type.type(:file) do
File.open(@file, "w", 0644) { |f| f.puts "yayness"; f.flush }
File.symlink(@file, @link)
- @resource = Puppet::Type.type(:file).create(
+ @resource = Puppet::Type.type(:file).new(
:path => @link,
:mode => "755"
)
@@ -128,12 +128,12 @@ describe Puppet::Type.type(:file) do
end
it "should be able to retrieve a stat instance for the file it is managing" do
- Puppet::Type.type(:file).create(:path => "/foo/bar", :source => "/bar/foo").should respond_to(:stat)
+ Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo").should respond_to(:stat)
end
describe "when stat'ing its file" do
before do
- @resource = Puppet::Type.type(:file).create(:path => "/foo/bar")
+ @resource = Puppet::Type.type(:file).new(:path => "/foo/bar")
@resource[:links] = :manage # so we always use :lstat
end
@@ -197,13 +197,13 @@ describe Puppet::Type.type(:file) do
describe "when flushing" do
it "should flush all properties that respond to :flush" do
- @resource = Puppet::Type.type(:file).create(:path => "/foo/bar", :source => "/bar/foo")
+ @resource = Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo")
@resource.parameter(:source).expects(:flush)
@resource.flush
end
it "should reset its stat reference" do
- @resource = Puppet::Type.type(:file).create(:path => "/foo/bar")
+ @resource = Puppet::Type.type(:file).new(:path => "/foo/bar")
File.expects(:lstat).times(2).returns("stat1").then.returns("stat2")
@resource.stat.should == "stat1"
@resource.flush
@@ -593,7 +593,7 @@ describe Puppet::Type.type(:file) do
end
it "should not copy the parent resource's parent" do
- Puppet::Type.type(:file).expects(:create).with { |options| ! options.include?(:parent) }
+ Puppet::Type.type(:file).expects(:new).with { |options| ! options.include?(:parent) }
@file.newchild("my/path")
end
@@ -601,21 +601,21 @@ describe Puppet::Type.type(:file) do
it "should not pass on #{param} to the sub resource" do
@file[param] = value
- @file.class.expects(:create).with { |params| params[param].nil? }
+ @file.class.expects(:new).with { |params| params[param].nil? }
@file.newchild("sub/file")
end
end
it "should copy all of the parent resource's 'should' values that were set at initialization" do
- file = @file.class.create(:path => "/foo/bar", :owner => "root", :group => "wheel")
+ file = @file.class.new(:path => "/foo/bar", :owner => "root", :group => "wheel")
@catalog.add_resource(file)
- file.class.expects(:create).with { |options| options[:owner] == "root" and options[:group] == "wheel" }
+ file.class.expects(:new).with { |options| options[:owner] == "root" and options[:group] == "wheel" }
file.newchild("my/path")
end
it "should not copy default values to the new child" do
- @file.class.expects(:create).with { |params| params[:backup].nil? }
+ @file.class.expects(:new).with { |params| params[:backup].nil? }
@file.newchild("my/path")
end
@@ -626,7 +626,7 @@ describe Puppet::Type.type(:file) do
@file.parameter(:source).copy_source_values
- @file.class.expects(:create).with { |params| params[:group].nil? }
+ @file.class.expects(:new).with { |params| params[:group].nil? }
@file.newchild("my/path")
end
end
diff --git a/spec/unit/type/group.rb b/spec/unit/type/group.rb
index 4467223b4..c9a7fc904 100755
--- a/spec/unit/type/group.rb
+++ b/spec/unit/type/group.rb
@@ -31,6 +31,6 @@ describe Puppet::Type.type(:group) do
# #1407 - we need to declare the allowdupe param as boolean.
it "should have a boolean method for determining if duplicates are allowed" do
- @class.create(:name => "foo").methods.should be_include("allowdupe?")
+ @class.new(:name => "foo").methods.should be_include("allowdupe?")
end
end
diff --git a/spec/unit/type/macauthorization.rb b/spec/unit/type/macauthorization.rb
index 15690d897..5873265f5 100755
--- a/spec/unit/type/macauthorization.rb
+++ b/spec/unit/type/macauthorization.rb
@@ -52,19 +52,19 @@ describe Puppet::Type.type(:macauthorization), "when checking macauthorization o
it "should be able to create an instance" do
lambda {
- macauth_type.create(:name => 'foo')
+ macauth_type.new(:name => 'foo')
}.should_not raise_error
end
it "should support :present as a value to :ensure" do
lambda {
- macauth_type.create(:name => "foo", :ensure => :present)
+ macauth_type.new(:name => "foo", :ensure => :present)
}.should_not raise_error
end
it "should support :absent as a value to :ensure" do
lambda {
- macauth_type.create(:name => "foo", :ensure => :absent)
+ macauth_type.new(:name => "foo", :ensure => :absent)
}.should_not raise_error
end
diff --git a/spec/unit/type/mcx.rb b/spec/unit/type/mcx.rb
index de7908e0f..eee7793d8 100755
--- a/spec/unit/type/mcx.rb
+++ b/spec/unit/type/mcx.rb
@@ -59,15 +59,15 @@ describe mcx_type, "default values" do
end
it "should be nil for :ds_type" do
- mcx_type.create(:name => '/Foo/bar')[:ds_type].should be_nil
+ mcx_type.new(:name => '/Foo/bar')[:ds_type].should be_nil
end
it "should be nil for :ds_name" do
- mcx_type.create(:name => '/Foo/bar')[:ds_name].should be_nil
+ mcx_type.new(:name => '/Foo/bar')[:ds_name].should be_nil
end
it "should be nil for :content" do
- mcx_type.create(:name => '/Foo/bar')[:content].should be_nil
+ mcx_type.new(:name => '/Foo/bar')[:content].should be_nil
end
end
@@ -81,19 +81,19 @@ describe mcx_type, "when validating properties" do
it "should be able to create an instance" do
lambda {
- mcx_type.create(:name => '/Foo/bar')
+ mcx_type.new(:name => '/Foo/bar')
}.should_not raise_error
end
it "should support :present as a value to :ensure" do
lambda {
- mcx_type.create(:name => "/Foo/bar", :ensure => :present)
+ mcx_type.new(:name => "/Foo/bar", :ensure => :present)
}.should_not raise_error
end
it "should support :absent as a value to :ensure" do
lambda {
- mcx_type.create(:name => "/Foo/bar", :ensure => :absent)
+ mcx_type.new(:name => "/Foo/bar", :ensure => :absent)
}.should_not raise_error
end
diff --git a/spec/unit/type/mount.rb b/spec/unit/type/mount.rb
index 72028f312..fd9c6cb52 100755
--- a/spec/unit/type/mount.rb
+++ b/spec/unit/type/mount.rb
@@ -8,7 +8,7 @@ describe Puppet::Type.type(:mount) do
end
it "should have no default value for :ensure" do
- mount = Puppet::Type.type(:mount).create(:name => "yay")
+ mount = Puppet::Type.type(:mount).new(:name => "yay")
mount.should(:ensure).should be_nil
end
end
@@ -34,20 +34,20 @@ describe Puppet::Type.type(:mount)::Ensure, "when validating values" do
end
it "should support :present as a value to :ensure" do
- Puppet::Type.type(:mount).create(:name => "yay", :ensure => :present)
+ Puppet::Type.type(:mount).new(:name => "yay", :ensure => :present)
end
it "should alias :unmounted to :present as a value to :ensure" do
- mount = Puppet::Type.type(:mount).create(:name => "yay", :ensure => :unmounted)
+ mount = Puppet::Type.type(:mount).new(:name => "yay", :ensure => :unmounted)
mount.should(:ensure).should == :present
end
it "should support :absent as a value to :ensure" do
- Puppet::Type.type(:mount).create(:name => "yay", :ensure => :absent)
+ Puppet::Type.type(:mount).new(:name => "yay", :ensure => :absent)
end
it "should support :mounted as a value to :ensure" do
- Puppet::Type.type(:mount).create(:name => "yay", :ensure => :mounted)
+ Puppet::Type.type(:mount).new(:name => "yay", :ensure => :mounted)
end
end
@@ -55,7 +55,7 @@ describe Puppet::Type.type(:mount)::Ensure do
before :each do
@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)
+ @mount = Puppet::Type.type(:mount).new(:name => "yay", :check => :ensure)
@ensure = @mount.property(:ensure)
end
@@ -185,7 +185,7 @@ describe Puppet::Type.type(:mount), "when modifying an existing mount entry" do
before do
@provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :remount => nil
Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider)
- @mount = Puppet::Type.type(:mount).create(:name => "yay", :ensure => :mounted)
+ @mount = Puppet::Type.type(:mount).new(:name => "yay", :ensure => :mounted)
{:device => "/foo/bar", :blockdevice => "/other/bar", :target => "/what/ever", :fstype => 'eh', :options => "", :pass => 0, :dump => 0, :atboot => 0,
:ensure => :mounted}.each do
diff --git a/spec/unit/type/package.rb b/spec/unit/type/package.rb
index 10d74d0b6..b76374eba 100755
--- a/spec/unit/type/package.rb
+++ b/spec/unit/type/package.rb
@@ -24,7 +24,7 @@ describe Puppet::Type.type(:package) do
end
it "should default to being installed" do
- pkg = Puppet::Type.type(:package).create(:name => "yay")
+ pkg = Puppet::Type.type(:package).new(:name => "yay")
pkg.should(:ensure).should == :present
end
end
@@ -48,50 +48,50 @@ describe Puppet::Type.type(:package), "when validating attribute values" do
end
it "should support :present as a value to :ensure" do
- Puppet::Type.type(:package).create(:name => "yay", :ensure => :present)
+ Puppet::Type.type(:package).new(:name => "yay", :ensure => :present)
end
it "should alias :installed to :present as a value to :ensure" do
- pkg = Puppet::Type.type(:package).create(:name => "yay", :ensure => :installed)
+ pkg = Puppet::Type.type(:package).new(:name => "yay", :ensure => :installed)
pkg.should(:ensure).should == :present
end
it "should support :absent as a value to :ensure" do
- Puppet::Type.type(:package).create(:name => "yay", :ensure => :absent)
+ Puppet::Type.type(:package).new(:name => "yay", :ensure => :absent)
end
it "should support :purged as a value to :ensure if the provider has the :purgeable feature" do
@provider.expects(:satisfies?).with(:purgeable).returns(true)
- Puppet::Type.type(:package).create(:name => "yay", :ensure => :purged)
+ Puppet::Type.type(:package).new(:name => "yay", :ensure => :purged)
end
it "should not support :purged as a value to :ensure if the provider does not have the :purgeable feature" do
@provider.expects(:satisfies?).with(:purgeable).returns(false)
- proc { Puppet::Type.type(:package).create(:name => "yay", :ensure => :purged) }.should raise_error(Puppet::Error)
+ proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => :purged) }.should raise_error(Puppet::Error)
end
it "should support :latest as a value to :ensure if the provider has the :upgradeable feature" do
@provider.expects(:satisfies?).with(:upgradeable).returns(true)
- Puppet::Type.type(:package).create(:name => "yay", :ensure => :latest)
+ Puppet::Type.type(:package).new(:name => "yay", :ensure => :latest)
end
it "should not support :latest as a value to :ensure if the provider does not have the :upgradeable feature" do
@provider.expects(:satisfies?).with(:upgradeable).returns(false)
- proc { Puppet::Type.type(:package).create(:name => "yay", :ensure => :latest) }.should raise_error(Puppet::Error)
+ proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => :latest) }.should raise_error(Puppet::Error)
end
it "should support version numbers as a value to :ensure if the provider has the :versionable feature" do
@provider.expects(:satisfies?).with(:versionable).returns(true)
- Puppet::Type.type(:package).create(:name => "yay", :ensure => "1.0")
+ Puppet::Type.type(:package).new(:name => "yay", :ensure => "1.0")
end
it "should not support version numbers as a value to :ensure if the provider does not have the :versionable feature" do
@provider.expects(:satisfies?).with(:versionable).returns(false)
- proc { Puppet::Type.type(:package).create(:name => "yay", :ensure => "1.0") }.should raise_error(Puppet::Error)
+ proc { Puppet::Type.type(:package).new(:name => "yay", :ensure => "1.0") }.should raise_error(Puppet::Error)
end
it "should accept any string as an argument to :source" do
- proc { Puppet::Type.type(:package).create(:name => "yay", :source => "stuff") }.should_not raise_error(Puppet::Error)
+ proc { Puppet::Type.type(:package).new(:name => "yay", :source => "stuff") }.should_not raise_error(Puppet::Error)
end
end
@@ -106,7 +106,7 @@ describe Puppet::Type.type(:package) do
@provider = stub 'provider', :class => Puppet::Type.type(:package).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
Puppet::Type.type(:package).defaultprovider.stubs(:new).returns(@provider)
Puppet::Type.type(:package).defaultprovider.stubs(:instances).returns([])
- @package = Puppet::Type.type(:package).create(:name => "yay")
+ @package = Puppet::Type.type(:package).new(:name => "yay")
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource(@package)
diff --git a/spec/unit/type/resources.rb b/spec/unit/type/resources.rb
index 414af2839..147f21db4 100644
--- a/spec/unit/type/resources.rb
+++ b/spec/unit/type/resources.rb
@@ -10,15 +10,15 @@ describe resources do
it "should fail if the specified resource type does not exist" do
Puppet::Type.stubs(:type).with("Resources").returns resources
Puppet::Type.expects(:type).with("nosuchtype").returns nil
- lambda { resources.create :name => "nosuchtype" }.should raise_error(Puppet::Error)
+ lambda { resources.new :name => "nosuchtype" }.should raise_error(Puppet::Error)
end
it "should not fail when the specified resource type exists" do
- lambda { resources.create :name => "file" }.should_not raise_error
+ lambda { resources.new :name => "file" }.should_not raise_error
end
it "should set its :resource_type attribute" do
- resources.create(:name => "file").resource_type.should == Puppet::Type.type(:file)
+ resources.new(:name => "file").resource_type.should == Puppet::Type.type(:file)
end
end
end
diff --git a/spec/unit/type/schedule.rb b/spec/unit/type/schedule.rb
index 7761b4346..8807d0fa0 100755
--- a/spec/unit/type/schedule.rb
+++ b/spec/unit/type/schedule.rb
@@ -43,7 +43,7 @@ describe Puppet::Type.type(:schedule) do
before :each do
Puppet.settings.stubs(:value).with(:ignoreschedules).returns(false)
- @schedule = Puppet::Type.type(:schedule).create(:name => "testing")
+ @schedule = Puppet::Type.type(:schedule).new(:name => "testing")
end
describe Puppet::Type.type(:schedule) do
diff --git a/spec/unit/type/selboolean.rb b/spec/unit/type/selboolean.rb
index 6efec49ca..7f719b46e 100755
--- a/spec/unit/type/selboolean.rb
+++ b/spec/unit/type/selboolean.rb
@@ -27,19 +27,19 @@ describe Puppet::Type.type(:selboolean), "when validating values" do
end
it "should support :on as a value to :value" do
- Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on)
+ Puppet::Type.type(:selboolean).new(:name => "yay", :value => :on)
end
it "should support :off as a value to :value" do
- Puppet::Type.type(:selboolean).create(:name => "yay", :value => :off)
+ Puppet::Type.type(:selboolean).new(:name => "yay", :value => :off)
end
it "should support :true as a value to :persistent" do
- Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on, :persistent => :true)
+ Puppet::Type.type(:selboolean).new(:name => "yay", :value => :on, :persistent => :true)
end
it "should support :false as a value to :persistent" do
- Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on, :persistent => :false)
+ Puppet::Type.type(:selboolean).new(:name => "yay", :value => :on, :persistent => :false)
end
end
diff --git a/spec/unit/type/service.rb b/spec/unit/type/service.rb
index 3f14f5d56..5e9d3b37f 100755
--- a/spec/unit/type/service.rb
+++ b/spec/unit/type/service.rb
@@ -33,86 +33,86 @@ describe Puppet::Type.type(:service), "when validating attribute values" do
end
it "should support :running as a value to :ensure" do
- Puppet::Type.type(:service).create(:name => "yay", :ensure => :running)
+ Puppet::Type.type(:service).new(:name => "yay", :ensure => :running)
end
it "should support :stopped as a value to :ensure" do
- Puppet::Type.type(:service).create(:name => "yay", :ensure => :stopped)
+ Puppet::Type.type(:service).new(:name => "yay", :ensure => :stopped)
end
it "should alias the value :true to :running in :ensure" do
- svc = Puppet::Type.type(:service).create(:name => "yay", :ensure => true)
+ svc = Puppet::Type.type(:service).new(:name => "yay", :ensure => true)
svc.should(:ensure).should == :running
end
it "should alias the value :false to :stopped in :ensure" do
- svc = Puppet::Type.type(:service).create(:name => "yay", :ensure => false)
+ svc = Puppet::Type.type(:service).new(:name => "yay", :ensure => false)
svc.should(:ensure).should == :stopped
end
it "should support :true as a value to :enable" do
- Puppet::Type.type(:service).create(:name => "yay", :enable => :true)
+ Puppet::Type.type(:service).new(:name => "yay", :enable => :true)
end
it "should support :false as a value to :enable" do
- Puppet::Type.type(:service).create(:name => "yay", :enable => :false)
+ Puppet::Type.type(:service).new(:name => "yay", :enable => :false)
end
it "should support :true as a value to :hasstatus" do
- Puppet::Type.type(:service).create(:name => "yay", :hasstatus => :true)
+ Puppet::Type.type(:service).new(:name => "yay", :hasstatus => :true)
end
it "should support :false as a value to :hasstatus" do
- Puppet::Type.type(:service).create(:name => "yay", :hasstatus => :false)
+ Puppet::Type.type(:service).new(:name => "yay", :hasstatus => :false)
end
it "should support :true as a value to :hasrestart" do
- Puppet::Type.type(:service).create(:name => "yay", :hasrestart => :true)
+ Puppet::Type.type(:service).new(:name => "yay", :hasrestart => :true)
end
it "should support :false as a value to :hasrestart" do
- Puppet::Type.type(:service).create(:name => "yay", :hasrestart => :false)
+ Puppet::Type.type(:service).new(:name => "yay", :hasrestart => :false)
end
it "should allow setting the :enable parameter if the provider has the :enableable feature" do
Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true)
Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(true)
- svc = Puppet::Type.type(:service).create(:name => "yay", :enable => true)
+ svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true)
svc.should(:enable).should == :true
end
it "should not allow setting the :enable parameter if the provider is missing the :enableable feature" do
Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true)
Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(false)
- svc = Puppet::Type.type(:service).create(:name => "yay", :enable => true)
+ svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true)
svc.should(:enable).should be_nil
end
it "should discard paths that do not exist" do
FileTest.stubs(:exist?).returns(false)
FileTest.stubs(:directory?).returns(false)
- svc = Puppet::Type.type(:service).create(:name => "yay", :path => "/one/two")
+ svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two")
svc[:path].should be_empty
end
it "should discard paths that are not directories" do
FileTest.stubs(:exist?).returns(true)
FileTest.stubs(:directory?).returns(false)
- svc = Puppet::Type.type(:service).create(:name => "yay", :path => "/one/two")
+ svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two")
svc[:path].should be_empty
end
it "should split paths on ':'" do
FileTest.stubs(:exist?).returns(true)
FileTest.stubs(:directory?).returns(true)
- svc = Puppet::Type.type(:service).create(:name => "yay", :path => "/one/two:/three/four")
+ svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two:/three/four")
svc[:path].should == %w{/one/two /three/four}
end
it "should accept arrays of paths joined by ':'" do
FileTest.stubs(:exist?).returns(true)
FileTest.stubs(:directory?).returns(true)
- svc = Puppet::Type.type(:service).create(:name => "yay", :path => ["/one:/two", "/three:/four"])
+ svc = Puppet::Type.type(:service).new(:name => "yay", :path => ["/one:/two", "/three:/four"])
svc[:path].should == %w{/one /two /three /four}
end
end
@@ -124,31 +124,31 @@ describe Puppet::Type.type(:service), "when setting default attribute values" do
Puppet::Type.type(:service).defaultprovider.stubs(:respond_to?).returns(true)
Puppet::Type.type(:service).defaultprovider.stubs(:defpath).returns("testing")
- svc = Puppet::Type.type(:service).create(:name => "other")
+ svc = Puppet::Type.type(:service).new(:name => "other")
svc[:path].should == ["testing"]
end
it "should default 'pattern' to the binary if one is provided" do
- svc = Puppet::Type.type(:service).create(:name => "other", :binary => "/some/binary")
+ svc = Puppet::Type.type(:service).new(:name => "other", :binary => "/some/binary")
svc[:pattern].should == "/some/binary"
end
it "should default 'pattern' to the name if no pattern is provided" do
- svc = Puppet::Type.type(:service).create(:name => "other")
+ svc = Puppet::Type.type(:service).new(:name => "other")
svc[:pattern].should == "other"
end
it "should default 'control' to the upcased service name with periods replaced by underscores if the provider supports the 'controllable' feature" do
provider = stub 'provider', :controllable? => true, :class => Puppet::Type.type(:service).defaultprovider, :clear => nil
Puppet::Type.type(:service).defaultprovider.stubs(:new).returns(provider)
- svc = Puppet::Type.type(:service).create(:name => "nfs.client")
+ svc = Puppet::Type.type(:service).new(:name => "nfs.client")
svc[:control].should == "NFS_CLIENT_START"
end
end
describe Puppet::Type.type(:service), "when retrieving the host's current state" do
before do
- @service = Puppet::Type.type(:service).create(:name => "yay")
+ @service = Puppet::Type.type(:service).new(:name => "yay")
end
it "should use the provider's status to determine whether the service is running" do
@@ -167,7 +167,7 @@ end
describe Puppet::Type.type(:service), "when changing the host" do
before do
- @service = Puppet::Type.type(:service).create(:name => "yay")
+ @service = Puppet::Type.type(:service).new(:name => "yay")
end
it "should start the service if it is supposed to be running" do
@@ -213,7 +213,7 @@ end
describe Puppet::Type.type(:service), "when refreshing the service" do
before do
- @service = Puppet::Type.type(:service).create(:name => "yay")
+ @service = Puppet::Type.type(:service).new(:name => "yay")
end
it "should restart the service if it is running" do
diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb
index 0e32ef77a..9a2389eef 100755
--- a/spec/unit/type/ssh_authorized_key.rb
+++ b/spec/unit/type/ssh_authorized_key.rb
@@ -34,31 +34,31 @@ describe ssh_authorized_key do
end
it "should support :present as a value for :ensure" do
- proc { @class.create(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error
+ proc { @class.new(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error
end
it "should support :absent as a value for :ensure" do
- proc { @class.create(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error
+ proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error
end
it "should have an type property" do
@class.attrtype(:type).should == :property
end
it "should support ssh-dss as an type value" do
- proc { @class.create(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error
+ proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error
end
it "should support ssh-rsa as an type value" do
- proc { @class.create(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error
+ proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error
end
it "should support :dsa as an type value" do
- proc { @class.create(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error
+ proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error
end
it "should support :rsa as an type value" do
- proc { @class.create(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error
+ proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error
end
it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa in the ssh_authorized_key_type" do
- proc { @class.create(:name => "whev", :type => :something) }.should raise_error(Puppet::Error)
+ proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error)
end
it "should have an key property" do
@@ -74,13 +74,13 @@ describe ssh_authorized_key do
end
it "'s options property should return well formed string of arrays from is_to_s" do
- resource = @class.create(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
+ resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c"
end
it "'s options property should return well formed string of arrays from is_to_s" do
- resource = @class.create(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
+ resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c"
end
@@ -91,7 +91,7 @@ describe ssh_authorized_key do
it "should raise an error when neither user nor target is given" do
proc do
- @class.create(
+ @class.new(
:name => "Test",
:key => "AAA",
:type => "ssh-rsa",
diff --git a/spec/unit/type/tidy.rb b/spec/unit/type/tidy.rb
index acbbd141d..72f6b0f10 100755
--- a/spec/unit/type/tidy.rb
+++ b/spec/unit/type/tidy.rb
@@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
describe Puppet::Type.type(:tidy) do
it "should use :lstat when stating a file" do
- tidy = Puppet::Type.type(:tidy).create :path => "/foo/bar", :age => "1d"
+ tidy = Puppet::Type.type(:tidy).new :path => "/foo/bar", :age => "1d"
stat = mock 'stat'
File.expects(:lstat).with("/foo/bar").returns stat
tidy.stat("/foo/bar").should == stat
@@ -23,7 +23,7 @@ describe Puppet::Type.type(:tidy) do
describe "when validating parameter values" do
describe "for 'recurse'" do
before do
- @tidy = Puppet::Type.type(:tidy).create :path => "/tmp", :age => "100d"
+ @tidy = Puppet::Type.type(:tidy).new :path => "/tmp", :age => "100d"
end
it "should allow 'true'" do
@@ -64,7 +64,7 @@ describe Puppet::Type.type(:tidy) do
convertors.each do |unit, multiple|
it "should consider a %s to be %s seconds" % [unit, multiple] do
- tidy = Puppet::Type.type(:tidy).create :path => "/what/ever", :age => "5%s" % unit.to_s[0..0]
+ tidy = Puppet::Type.type(:tidy).new :path => "/what/ever", :age => "5%s" % unit.to_s[0..0]
tidy[:age].should == 5 * multiple
end
@@ -81,7 +81,7 @@ describe Puppet::Type.type(:tidy) do
convertors.each do |unit, multiple|
it "should consider a %s to be 1024^%s bytes" % [unit, multiple] do
- tidy = Puppet::Type.type(:tidy).create :path => "/what/ever", :size => "5%s" % unit
+ tidy = Puppet::Type.type(:tidy).new :path => "/what/ever", :size => "5%s" % unit
total = 5
multiple.times { total *= 1024 }
@@ -92,7 +92,7 @@ describe Puppet::Type.type(:tidy) do
describe "when tidying" do
before do
- @tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
+ @tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat', :ftype => "directory"
File.stubs(:lstat).with("/what/ever").returns @stat
end
@@ -100,25 +100,25 @@ describe Puppet::Type.type(:tidy) do
describe "and generating files" do
it "should set the backup on the file if backup is set on the tidy instance" do
@tidy[:backup] = "whatever"
- Puppet::Type.type(:file).expects(:create).with { |args| args[:backup] == "whatever" }
+ Puppet::Type.type(:file).expects(:new).with { |args| args[:backup] == "whatever" }
@tidy.mkfile("/what/ever")
end
it "should set the file's path to the tidy's path" do
- Puppet::Type.type(:file).expects(:create).with { |args| args[:path] == "/what/ever" }
+ Puppet::Type.type(:file).expects(:new).with { |args| args[:path] == "/what/ever" }
@tidy.mkfile("/what/ever")
end
it "should configure the file for deletion" do
- Puppet::Type.type(:file).expects(:create).with { |args| args[:ensure] == :absent }
+ Puppet::Type.type(:file).expects(:new).with { |args| args[:ensure] == :absent }
@tidy.mkfile("/what/ever")
end
it "should force deletion on the file" do
- Puppet::Type.type(:file).expects(:create).with { |args| args[:force] == true }
+ Puppet::Type.type(:file).expects(:new).with { |args| args[:force] == true }
@tidy.mkfile("/what/ever")
end
@@ -133,7 +133,7 @@ describe Puppet::Type.type(:tidy) do
describe "and recursion is not used" do
it "should generate a file resource if the file should be tidied" do
@tidy.expects(:tidy?).with("/what/ever").returns true
- file = Puppet::Type.type(:file).create(:path => "/eh")
+ file = Puppet::Type.type(:file).new(:path => "/eh")
@tidy.expects(:mkfile).with("/what/ever").returns file
@tidy.generate.should == [file]
@@ -170,7 +170,7 @@ describe Puppet::Type.type(:tidy) do
@tidy.expects(:tidy?).with("/what/ever/one").returns true
@tidy.expects(:tidy?).with("/what/ever/two").returns false
- file = Puppet::Type.type(:file).create(:path => "/eh")
+ file = Puppet::Type.type(:file).new(:path => "/eh")
@tidy.expects(:mkfile).with("/what/ever").returns file
@tidy.expects(:mkfile).with("/what/ever/one").returns file
@@ -180,7 +180,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file matches provided glob patterns" do
before do
- @tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
+ @tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@tidy[:matches] = %w{*foo* *bar*}
@stat = mock 'stat'
@@ -206,7 +206,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file is too old" do
before do
- @tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
+ @tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat'
@tidy[:age] = "1s"
@@ -236,7 +236,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file is too large" do
before do
- @tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
+ @tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat', :ftype => "file"
@tidy[:size] = "1kb"
@@ -258,7 +258,7 @@ describe Puppet::Type.type(:tidy) do
describe "and determining whether a file should be tidied" do
before do
- @tidy = Puppet::Type.type(:tidy).create :path => "/what/ever"
+ @tidy = Puppet::Type.type(:tidy).new :path => "/what/ever"
@stat = stub 'stat', :ftype => "file"
File.stubs(:lstat).with("/what/ever").returns @stat
end
diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb
index 6e71ebbcc..5d84591da 100755
--- a/spec/unit/type/user.rb
+++ b/spec/unit/type/user.rb
@@ -15,7 +15,7 @@ describe user do
end
it "should be able to create a instance" do
- user.create(:name => "foo").should_not be_nil
+ user.new(:name => "foo").should_not be_nil
end
it "should have an allows_duplicates feature" do
@@ -36,7 +36,7 @@ describe user do
describe "instances" do
it "should have a valid provider" do
- user.create(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
+ user.new(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
end
end
@@ -70,7 +70,7 @@ describe user do
describe "when retrieving all current values" do
before do
- @user = user.create(:name => "foo", :uid => 10, :gid => 10)
+ @user = user.new(:name => "foo", :uid => 10, :gid => 10)
end
it "should return a hash containing values for all set properties" do
@@ -239,11 +239,11 @@ describe user do
describe "when user has roles" do
it "should autorequire roles" do
#this is a little funky because the autorequire depends on a property with a feature
- testuser = Puppet::Type.type(:user).create(:name => "testuser")
+ testuser = Puppet::Type.type(:user).new(:name => "testuser")
testuser.provider.class.expects(:feature?).with(:manages_solaris_rbac).returns(true)
testuser[:roles] = "testrole"
- testrole = Puppet::Type.type(:user).create(:name => "testrole")
+ testrole = Puppet::Type.type(:user).new(:name => "testrole")
config = Puppet::Resource::Catalog.new :testing do |conf|
[testuser, testrole].each { |resource| conf.add_resource resource }
diff --git a/spec/unit/type/zfs.rb b/spec/unit/type/zfs.rb
index 56efa30de..e1af6821a 100755
--- a/spec/unit/type/zfs.rb
+++ b/spec/unit/type/zfs.rb
@@ -28,11 +28,11 @@ describe zfs do
Puppet::Type.type(:zpool).stubs(:defaultprovider).returns(provider)
- foo_pool = Puppet::Type.type(:zpool).create(:name => "foo")
+ foo_pool = Puppet::Type.type(:zpool).new(:name => "foo")
- foo_bar_zfs = Puppet::Type.type(:zfs).create(:name => "foo/bar")
- foo_bar_baz_zfs = Puppet::Type.type(:zfs).create(:name => "foo/bar/baz")
- foo_bar_baz_buz_zfs = Puppet::Type.type(:zfs).create(:name => "foo/bar/baz/buz")
+ foo_bar_zfs = Puppet::Type.type(:zfs).new(:name => "foo/bar")
+ foo_bar_baz_zfs = Puppet::Type.type(:zfs).new(:name => "foo/bar/baz")
+ foo_bar_baz_buz_zfs = Puppet::Type.type(:zfs).new(:name => "foo/bar/baz/buz")
config = Puppet::Resource::Catalog.new :testing do |conf|
[foo_pool, foo_bar_zfs, foo_bar_baz_zfs, foo_bar_baz_buz_zfs].each { |resource| conf.add_resource resource }