diff options
author | Luke Kanies <luke@madstop.com> | 2008-12-17 18:29:58 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-12-18 11:10:25 -0600 |
commit | e4ba3db1963081eacc2aef3d865f777b427ef23c (patch) | |
tree | 55a4aa8cdde262880a8affb6cbd4470d49c10c55 /spec/unit | |
parent | b6db54585177f277b1e06bebd4d925d5c272b610 (diff) | |
download | puppet-e4ba3db1963081eacc2aef3d865f777b427ef23c.tar.gz |
Deprecating the Puppet::Type.create.
This method is no longer necessary; you can use the
normal 'new' class method.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/other/selinux.rb | 6 | ||||
-rwxr-xr-x | spec/unit/other/transobject.rb | 8 | ||||
-rwxr-xr-x | spec/unit/parser/compiler.rb | 4 | ||||
-rwxr-xr-x | spec/unit/provider/mount/parsed.rb | 2 | ||||
-rwxr-xr-x | spec/unit/resource.rb | 4 | ||||
-rwxr-xr-x | spec/unit/resource/catalog.rb | 36 | ||||
-rwxr-xr-x | spec/unit/transaction.rb | 28 | ||||
-rwxr-xr-x | spec/unit/type.rb | 24 | ||||
-rw-r--r-- | spec/unit/type/augeas.rb | 14 | ||||
-rwxr-xr-x | spec/unit/type/computer.rb | 8 | ||||
-rwxr-xr-x | spec/unit/type/exec.rb | 2 | ||||
-rwxr-xr-x | spec/unit/type/file.rb | 24 | ||||
-rwxr-xr-x | spec/unit/type/group.rb | 2 | ||||
-rwxr-xr-x | spec/unit/type/macauthorization.rb | 6 | ||||
-rwxr-xr-x | spec/unit/type/mcx.rb | 12 | ||||
-rwxr-xr-x | spec/unit/type/mount.rb | 14 | ||||
-rwxr-xr-x | spec/unit/type/package.rb | 24 | ||||
-rw-r--r-- | spec/unit/type/resources.rb | 6 | ||||
-rwxr-xr-x | spec/unit/type/schedule.rb | 2 | ||||
-rwxr-xr-x | spec/unit/type/selboolean.rb | 8 | ||||
-rwxr-xr-x | spec/unit/type/service.rb | 46 | ||||
-rwxr-xr-x | spec/unit/type/ssh_authorized_key.rb | 20 | ||||
-rwxr-xr-x | spec/unit/type/tidy.rb | 30 | ||||
-rwxr-xr-x | spec/unit/type/user.rb | 10 | ||||
-rwxr-xr-x | spec/unit/type/zfs.rb | 8 | ||||
-rwxr-xr-x | spec/unit/util/storage.rb | 4 |
26 files changed, 176 insertions, 176 deletions
diff --git a/spec/unit/other/selinux.rb b/spec/unit/other/selinux.rb index 5e5568377..81ae9e9b9 100644 --- a/spec/unit/other/selinux.rb +++ b/spec/unit/other/selinux.rb @@ -7,7 +7,7 @@ require 'puppet/type/selmodule' describe Puppet::Type.type(:file), " when manipulating file contexts" do before :each do - @file = Puppet::Type::File.create( + @file = Puppet::Type::File.new( :name => "/tmp/foo", :ensure => "file", :seluser => "user_u", @@ -30,7 +30,7 @@ describe Puppet::Type.type(:selboolean), " when manipulating booleans" do provider_class = Puppet::Type::Selboolean.provider(Puppet::Type::Selboolean.providers[0]) Puppet::Type::Selboolean.expects(:defaultprovider).returns provider_class - @bool = Puppet::Type::Selboolean.create( + @bool = Puppet::Type::Selboolean.new( :name => "foo", :value => "on", :persistent => true ) @@ -59,7 +59,7 @@ describe Puppet::Type.type(:selmodule), " when checking policy modules" do provider_class = Puppet::Type::Selmodule.provider(Puppet::Type::Selmodule.providers[0]) Puppet::Type::Selmodule.expects(:defaultprovider).returns provider_class - @module = Puppet::Type::Selmodule.create( + @module = Puppet::Type::Selmodule.new( :name => "foo", :selmoduledir => "/some/path", :selmodulepath => "/some/path/foo.pp", diff --git a/spec/unit/other/transobject.rb b/spec/unit/other/transobject.rb index 605517281..92ed2662f 100755 --- a/spec/unit/other/transobject.rb +++ b/spec/unit/other/transobject.rb @@ -88,25 +88,25 @@ describe Puppet::TransObject, " when converting to a RAL component instance" do end it "should use a new TransObject whose name is a resource reference of the type and title of the original TransObject" do - Puppet::Type::Component.expects(:create).with { |resource| resource.type == "component" and resource.name == "One::Two[/my/file]" }.returns(:yay) + Puppet::Type::Component.expects(:new).with { |resource| resource.type == "component" and resource.name == "One::Two[/my/file]" }.returns(:yay) @resource.to_component.should == :yay end it "should pass the resource parameters on to the newly created TransObject" do - Puppet::Type::Component.expects(:create).with { |resource| resource["noop"] == "other" }.returns(:yay) + Puppet::Type::Component.expects(:new).with { |resource| resource["noop"] == "other" }.returns(:yay) @resource.to_component.should == :yay end it "should copy over the catalog" do @resource.catalog = "mycat" - Puppet::Type::Component.expects(:create).with { |resource| resource.catalog == "mycat" }.returns(:yay) + Puppet::Type::Component.expects(:new).with { |resource| resource.catalog == "mycat" }.returns(:yay) @resource.to_component end # LAK:FIXME This really isn't the design we want going forward, but it's # good enough for now. it "should not pass resource parameters that are not metaparams" do - Puppet::Type::Component.expects(:create).with { |resource| resource["one"].nil? }.returns(:yay) + Puppet::Type::Component.expects(:new).with { |resource| resource["one"].nil? }.returns(:yay) @resource.to_component.should == :yay end end diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb index 025836229..203105289 100755 --- a/spec/unit/parser/compiler.rb +++ b/spec/unit/parser/compiler.rb @@ -247,8 +247,8 @@ describe Puppet::Parser::Compiler do end it "should fail to add resources that conflict with existing resources" do - file1 = Puppet::Type.type(:file).create :path => "/foo" - file2 = Puppet::Type.type(:file).create :path => "/foo" + file1 = Puppet::Type.type(:file).new :path => "/foo" + file2 = Puppet::Type.type(:file).new :path => "/foo" @compiler.add_resource(@scope, file1) lambda { @compiler.add_resource(@scope, file2) }.should raise_error(Puppet::Resource::Catalog::DuplicateResourceError) diff --git a/spec/unit/provider/mount/parsed.rb b/spec/unit/provider/mount/parsed.rb index 6168c10d2..8a7b52531 100755 --- a/spec/unit/provider/mount/parsed.rb +++ b/spec/unit/provider/mount/parsed.rb @@ -150,7 +150,7 @@ describe provider_class do include ParsedMountTesting before do - @mount = @mount_class.create :name => "/" + @mount = @mount_class.new :name => "/" @provider = @mount.provider end diff --git a/spec/unit/resource.rb b/spec/unit/resource.rb index a743c03ca..f24ec0123 100755 --- a/spec/unit/resource.rb +++ b/spec/unit/resource.rb @@ -214,14 +214,14 @@ describe Puppet::Resource do it "should use the resource type's :create method to create the resource if the resource is of a builtin type" do type = mock 'resource type' - type.expects(:create).with(@resource).returns(:myresource) + type.expects(:new).with(@resource).returns(:myresource) Puppet::Type.expects(:type).with(@resource.type).returns(type) @resource.to_ral.should == :myresource end it "should convert to a component instance if the resource type is not of a builtin type" do component = mock 'component type' - Puppet::Type::Component.expects(:create).with(@resource).returns "meh" + Puppet::Type::Component.expects(:new).with(@resource).returns "meh" Puppet::Type.expects(:type).with(@resource.type).returns(nil) @resource.to_ral.should == "meh" diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb index 5a27e8ec3..c46915f86 100755 --- a/spec/unit/resource/catalog.rb +++ b/spec/unit/resource/catalog.rb @@ -278,9 +278,9 @@ describe Puppet::Resource::Catalog, "when compiling" do describe "when functioning as a resource container" do before do @catalog = Puppet::Resource::Catalog.new("host") - @one = Puppet::Type.type(:notify).create :name => "one" - @two = Puppet::Type.type(:notify).create :name => "two" - @dupe = Puppet::Type.type(:notify).create :name => "one" + @one = Puppet::Type.type(:notify).new :name => "one" + @two = Puppet::Type.type(:notify).new :name => "two" + @dupe = Puppet::Type.type(:notify).new :name => "one" end it "should provide a method to add one or more resources" do @@ -449,7 +449,7 @@ describe Puppet::Resource::Catalog, "when compiling" do end it "should create aliases for resources isomorphic resources whose names do not match their titles" do - resource = Puppet::Type::File.create(:title => "testing", :path => "/something") + resource = Puppet::Type::File.new(:title => "testing", :path => "/something") @catalog.add_resource(resource) @@ -457,7 +457,7 @@ describe Puppet::Resource::Catalog, "when compiling" do end it "should not create aliases for resources non-isomorphic resources whose names do not match their titles" do - resource = Puppet::Type.type(:exec).create(:title => "testing", :command => "echo", :path => %w{/bin /usr/bin /usr/local/bin}) + resource = Puppet::Type.type(:exec).new(:title => "testing", :command => "echo", :path => %w{/bin /usr/bin /usr/local/bin}) @catalog.add_resource(resource) @@ -507,7 +507,7 @@ describe Puppet::Resource::Catalog, "when compiling" do end it "should add an alias for the namevar when the title and name differ on isomorphic resource types" do - resource = Puppet::Type.type(:file).create :path => "/something", :title => "other", :content => "blah" + resource = Puppet::Type.type(:file).new :path => "/something", :title => "other", :content => "blah" resource.expects(:isomorphic?).returns(true) @catalog.add_resource(resource) @catalog.resource(:file, "other").should equal(resource) @@ -515,7 +515,7 @@ describe Puppet::Resource::Catalog, "when compiling" do end it "should not add an alias for the namevar when the title and name differ on non-isomorphic resource types" do - resource = Puppet::Type.type(:file).create :path => "/something", :title => "other", :content => "blah" + resource = Puppet::Type.type(:file).new :path => "/something", :title => "other", :content => "blah" resource.expects(:isomorphic?).returns(false) @catalog.add_resource(resource) @catalog.resource(:file, resource.title).should equal(resource) @@ -528,7 +528,7 @@ describe Puppet::Resource::Catalog, "when compiling" do it "should provide a method to create additional resources that also registers the resource" do args = {:name => "/yay", :ensure => :file} resource = stub 'file', :ref => "File[/yay]", :catalog= => @catalog, :title => "/yay", :[] => "/yay" - Puppet::Type.type(:file).expects(:create).with(args).returns(resource) + Puppet::Type.type(:file).expects(:new).with(args).returns(resource) @catalog.create_resource :file, args @catalog.resource("File[/yay]").should equal(resource) end @@ -596,7 +596,7 @@ describe Puppet::Resource::Catalog, "when compiling" do @transaction.stubs(:evaluate) @transaction.stubs(:cleanup) @transaction.stubs(:addtimes) - Puppet::Type.type(:file).expects(:create).with(args).returns(resource) + Puppet::Type.type(:file).expects(:new).with(args).returns(resource) resource.expects :remove @catalog.apply do |trans| @catalog.create_resource :file, args @@ -611,7 +611,7 @@ describe Puppet::Resource::Catalog, "when compiling" do @transaction.stubs(:evaluate) @transaction.stubs(:cleanup) @transaction.stubs(:addtimes) - file = Puppet::Type.type(:file).create(:name => "/yay", :ensure => :file) + file = Puppet::Type.type(:file).new(:name => "/yay", :ensure => :file) @catalog.apply do |trans| @catalog.add_resource file @catalog.resource("File[/yay]").should_not be_nil @@ -690,18 +690,18 @@ describe Puppet::Resource::Catalog, "when compiling" do before do Puppet::Type.type(:component) @catalog = Puppet::Resource::Catalog.new("host") - @compone = Puppet::Type::Component.create :name => "one" - @comptwo = Puppet::Type::Component.create :name => "two", :require => "Class[one]" + @compone = Puppet::Type::Component.new :name => "one" + @comptwo = Puppet::Type::Component.new :name => "two", :require => "Class[one]" @file = Puppet::Type.type(:file) - @one = @file.create :path => "/one" - @two = @file.create :path => "/two" - @sub = @file.create :path => "/two/subdir" + @one = @file.new :path => "/one" + @two = @file.new :path => "/two" + @sub = @file.new :path => "/two/subdir" @catalog.add_edge @compone, @one @catalog.add_edge @comptwo, @two - @three = @file.create :path => "/three" - @four = @file.create :path => "/four", :require => "File[/three]" - @five = @file.create :path => "/five" + @three = @file.new :path => "/three" + @four = @file.new :path => "/four", :require => "File[/three]" + @five = @file.new :path => "/five" @catalog.add_resource @compone, @comptwo, @one, @two, @three, @four, @five, @sub @relationships = @catalog.relationship_graph diff --git a/spec/unit/transaction.rb b/spec/unit/transaction.rb index 0758e6c1e..2aa0df37b 100755 --- a/spec/unit/transaction.rb +++ b/spec/unit/transaction.rb @@ -7,7 +7,7 @@ require 'puppet/transaction' describe Puppet::Transaction do before do @generator_class = mkgenerator - @generator = mkgenerator.create(:name => "foo") + @generator = mkgenerator.new(:name => "foo") @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @generator @@ -30,8 +30,8 @@ describe Puppet::Transaction do end it "should add all generated resources to the catalog" do - one = @generator_class.create :name => "one" - two = @generator_class.create :name => "two" + one = @generator_class.new :name => "one" + two = @generator_class.new :name => "two" @generator.expects(:generate).returns [one, two] @transaction.generate @@ -40,8 +40,8 @@ describe Puppet::Transaction do end it "should generate and add resources from the generated resources" do - one = @generator_class.create :name => "one" - two = @generator_class.create :name => "two" + one = @generator_class.new :name => "one" + two = @generator_class.new :name => "two" @generator.expects(:generate).returns [one] one.expects(:generate).returns [two] @transaction.generate @@ -50,8 +50,8 @@ describe Puppet::Transaction do end it "should add an edge in the relationship graph between the generating and generated resource" do - one = @generator_class.create :name => "one" - two = @generator_class.create :name => "two" + one = @generator_class.new :name => "one" + two = @generator_class.new :name => "two" @generator.expects(:generate).returns [one] one.expects(:generate).returns [two] @transaction.generate @@ -61,7 +61,7 @@ describe Puppet::Transaction do end it "should finish all non-conflicting resources" do - one = @generator_class.create :name => "one" + one = @generator_class.new :name => "one" one.expects(:finish) @generator.expects(:generate).returns [one] @transaction.generate @@ -74,8 +74,8 @@ describe Puppet::Transaction do end it "should add all generated resources to the catalog" do - one = @generator_class.create :name => "one" - two = @generator_class.create :name => "two" + one = @generator_class.new :name => "one" + two = @generator_class.new :name => "two" @generator.expects(:eval_generate).returns [one, two] @transaction.eval_generate(@generator) @@ -84,7 +84,7 @@ describe Puppet::Transaction do end it "should add an edge in the relationship graph between the generating and generated resource" do - one = @generator_class.create :name => "one" + one = @generator_class.new :name => "one" @generator.expects(:eval_generate).returns [one] @transaction.eval_generate(@generator) @@ -92,15 +92,15 @@ describe Puppet::Transaction do end it "should not recursively eval_generate resources" do - one = @generator_class.create :name => "one" - two = @generator_class.create :name => "two" + one = @generator_class.new :name => "one" + two = @generator_class.new :name => "two" @generator.expects(:eval_generate).returns [one] one.expects(:eval_generate).never @transaction.eval_generate(@generator) end it "should finish all non-conflicting resources" do - one = @generator_class.create :name => "one" + one = @generator_class.new :name => "one" one.expects(:finish) @generator.expects(:eval_generate).returns [one] @transaction.eval_generate(@generator) diff --git a/spec/unit/type.rb b/spec/unit/type.rb index 58c652d2d..672de9eb0 100755 --- a/spec/unit/type.rb +++ b/spec/unit/type.rb @@ -9,37 +9,37 @@ describe Puppet::Type do it "should use its catalog as its expirer" do catalog = Puppet::Resource::Catalog.new - resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) + resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.catalog = catalog resource.expirer.should equal(catalog) end it "should do nothing when asked to expire when it has no catalog" do - resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) + resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) lambda { resource.expire }.should_not raise_error end it "should be able to retrieve a property by name" do - resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) + resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype)) end it "should be able to retrieve a parameter by name" do - resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) + resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.parameter(:name).must be_instance_of(Puppet::Type.type(:mount).attrclass(:name)) end it "should be able to retrieve a property by name using the :parameter method" do - resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) + resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.parameter(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype)) end it "should have a method for setting default values for resources" do - Puppet::Type.type(:mount).create(:name => "foo").should respond_to(:set_default) + Puppet::Type.type(:mount).new(:name => "foo").should respond_to(:set_default) end it "should do nothing for attributes that have no defaults and no specified value" do - Puppet::Type.type(:mount).create(:name => "foo").parameter(:noop).should be_nil + Puppet::Type.type(:mount).new(:name => "foo").parameter(:noop).should be_nil end describe "when initializing" do @@ -247,7 +247,7 @@ describe Puppet::Type do describe "when retrieving current property values" do # Use 'mount' as an example, because it doesn't override 'retrieve' before do - @resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) + @resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) @properties = {} end @@ -278,9 +278,9 @@ describe Puppet::Type do describe "when in a catalog" do before do @catalog = Puppet::Resource::Catalog.new - @container = Puppet::Type.type(:component).create(:name => "container") - @one = Puppet::Type.type(:file).create(:path => "/file/one") - @two = Puppet::Type.type(:file).create(:path => "/file/two") + @container = Puppet::Type.type(:component).new(:name => "container") + @one = Puppet::Type.type(:file).new(:path => "/file/one") + @two = Puppet::Type.type(:file).new(:path => "/file/two") @catalog.add_resource @container @catalog.add_resource @one @@ -317,7 +317,7 @@ describe Puppet::Type::RelationshipMetaparam do describe "when munging relationships" do before do - @resource = Puppet::Type.type(:mount).create :name => "/foo" + @resource = Puppet::Type.type(:mount).new :name => "/foo" @metaparam = Puppet::Type.metaparamclass(:require).new :resource => @resource end 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 } diff --git a/spec/unit/util/storage.rb b/spec/unit/util/storage.rb index 04829598e..522eb392c 100755 --- a/spec/unit/util/storage.rb +++ b/spec/unit/util/storage.rb @@ -37,8 +37,8 @@ describe Puppet::Util::Storage do describe "when caching a Puppet::Type" do before(:all) do - @file_test = Puppet::Type.type(:file).create(:name => "/yayness", :check => %w{checksum type}) - @exec_test = Puppet::Type.type(:exec).create(:name => "/bin/ls /yayness") + @file_test = Puppet::Type.type(:file).new(:name => "/yayness", :check => %w{checksum type}) + @exec_test = Puppet::Type.type(:exec).new(:name => "/bin/ls /yayness") end it "should return an empty hash" do |