Because of how many interfaces changed, a bunch of stubbing that used to be ok suddenly caused test failures.
Signed-off-by: Luke Kanies <[email protected]> --- Local-branch: refactor/master/8233-refactor_parameter_management spec/unit/provider/group/ldap_spec.rb | 14 +++++------- spec/unit/provider/ldap_spec.rb | 2 +- spec/unit/type/file_spec.rb | 16 +++++-------- spec/unit/util/nagios_maker_spec.rb | 38 ++++++++++++++++---------------- 4 files changed, 32 insertions(+), 38 deletions(-) diff --git a/spec/unit/provider/group/ldap_spec.rb b/spec/unit/provider/group/ldap_spec.rb index 947007f..5802b12 100755 --- a/spec/unit/provider/group/ldap_spec.rb +++ b/spec/unit/provider/group/ldap_spec.rb @@ -49,11 +49,10 @@ describe provider_class do high = {:name=>["testing"], :gid=>["640"]} provider_class.manager.expects(:search).returns([low, high]) - resource = stub 'resource', :should => %w{whatever} - resource.stubs(:should).with(:gid).returns nil - resource.stubs(:should).with(:ensure).returns :present + resource = Puppet::Type.type(:group).new(:name => "foo") + resource[:ensure] = :present instance = provider_class.new(:name => "luke", :ensure => :absent) - instance.stubs(:resource).returns resource + instance.resource = resource @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["641"] } @@ -64,11 +63,10 @@ describe provider_class do it "should pick '501' as its GID if no groups are found" do provider_class.manager.expects(:search).returns nil - resource = stub 'resource', :should => %w{whatever} - resource.stubs(:should).with(:gid).returns nil - resource.stubs(:should).with(:ensure).returns :present + resource = Puppet::Type.type(:group).new(:name => "foo") + resource[:ensure] = :present instance = provider_class.new(:name => "luke", :ensure => :absent) - instance.stubs(:resource).returns resource + instance.resource = resource @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["501"] } diff --git a/spec/unit/provider/ldap_spec.rb b/spec/unit/provider/ldap_spec.rb index 79de56b..1ef575c 100755 --- a/spec/unit/provider/ldap_spec.rb +++ b/spec/unit/provider/ldap_spec.rb @@ -61,7 +61,7 @@ describe Puppet::Provider::Ldap do @manager = mock 'manager' @class.stubs(:manager).returns @manager - @resource = mock 'resource' + @resource = Puppet::Type.type(:user).new :name => "foo" @resources = {"one" => @resource} end diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 65c2347..d713cc2 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -1022,27 +1022,23 @@ describe Puppet::Type.type(:file) do end it "should configure each file to be removed" do - local = stub 'local' - local.stubs(:[]).with(:source).returns nil # Thus, a local file - local.stubs(:[]).with(:path).returns "foo" + local = Puppet::Type.type(:file).new(:path => File.join(@file[:path], "local")) @file.expects(:recurse_local).returns("local" => local) - local.expects(:[]=).with(:ensure, :absent) - @file.recurse + local[:ensure].should == :absent end it "should not remove files that exist in the remote repository" do @file["source"] = "/my/file" @file.expects(:recurse_local).returns({}) - remote = stub 'remote' - remote.stubs(:[]).with(:source).returns "/whatever" # Thus, a remote file - remote.stubs(:[]).with(:path).returns "foo" + remote = Puppet::Type.type(:file).new(:path => File.join(@file[:path], "remote")) + remote[:source] = "puppet:///foo" @file.expects(:recurse_remote).with { |hash| hash["remote"] = remote } - remote.expects(:[]=).with(:ensure, :absent).never - @file.recurse + + remote[:ensure].should_not == :absent end end diff --git a/spec/unit/util/nagios_maker_spec.rb b/spec/unit/util/nagios_maker_spec.rb index b61f4fe..90ea1d7 100755 --- a/spec/unit/util/nagios_maker_spec.rb +++ b/spec/unit/util/nagios_maker_spec.rb @@ -11,11 +11,16 @@ describe Puppet::Util::NagiosMaker do before do @module = Puppet::Util::NagiosMaker - @nagtype = stub 'nagios type', :parameters => [], :namevar => :name - Nagios::Base.stubs(:type).with(:test).returns(@nagtype) + @nagtype = stub 'nagios type', :parameters => [], :namevar => :name, :name => "nagtype" + @nagtype.stubs(:attr_accessor) + Nagios::Base.stubs(:type).returns(@nagtype) @provider = stub 'provider', :nagios_type => nil - @type = stub 'type', :newparam => nil, :newproperty => nil, :provide => @provider, :desc => nil, :ensurable => nil + @type = Puppet::Type.newtype(:test_nag_type) + end + + after do + Puppet::Type.rmtype(:test_nag_type) end it "should be able to create a new nagios type" do @@ -34,10 +39,10 @@ describe Puppet::Util::NagiosMaker do end it "should mark the created type as ensurable" do - @type.expects(:ensurable) - Puppet::Type.expects(:newtype).with(:nagios_test).returns(@type) @module.create_nagios_type(:test) + + @type.property_names.should be_include(:ensure) end it "should create a namevar parameter for the nagios type's name parameter" do @@ -50,39 +55,34 @@ describe Puppet::Util::NagiosMaker do it "should create a property for all non-namevar parameters" do @nagtype.stubs(:parameters).returns([:one, :two]) - @type.expects(:newproperty).with(:one) - @type.expects(:newproperty).with(:two) - @type.expects(:newproperty).with(:target) - Puppet::Type.expects(:newtype).with(:nagios_test).returns(@type) @module.create_nagios_type(:test) + + @type.property_names.should be_include(:one) + @type.property_names.should be_include(:two) end it "should skip parameters that start with integers" do - @nagtype.stubs(:parameters).returns(["2dcoords".to_sym, :other]) - - @type.expects(:newproperty).with(:other) - @type.expects(:newproperty).with(:target) + @nagtype.stubs(:parameters).returns([:"2dcoords", :other]) Puppet::Type.expects(:newtype).with(:nagios_test).returns(@type) @module.create_nagios_type(:test) + + @type.property_names.should_not be_include(:"2dcoords") end it "should deduplicate the parameter list" do @nagtype.stubs(:parameters).returns([:one, :one]) - @type.expects(:newproperty).with(:one) - @type.expects(:newproperty).with(:target) - Puppet::Type.expects(:newtype).with(:nagios_test).returns(@type) - @module.create_nagios_type(:test) + lambda { @module.create_nagios_type(:test) }.should_not raise_error end it "should create a target property" do - @type.expects(:newproperty).with(:target) - Puppet::Type.expects(:newtype).with(:nagios_test).returns(@type) @module.create_nagios_type(:test) + + @type.property_names.should be_include(:target) end end -- 1.7.3.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
