summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-09-30 13:33:10 -0500
committerLuke Kanies <luke@madstop.com>2008-09-30 13:33:10 -0500
commitb9c75cd14cfae6dca035519f13f7d159f2889d0a (patch)
tree3835d7ab1ecc0223c1b77f5d9b029de3a575530e
parent3749267093923692d6e7bc0c9ce83b43a487b19e (diff)
downloadpuppet-b9c75cd14cfae6dca035519f13f7d159f2889d0a.tar.gz
puppet-b9c75cd14cfae6dca035519f13f7d159f2889d0a.tar.xz
puppet-b9c75cd14cfae6dca035519f13f7d159f2889d0a.zip
Rewriting the user tests, in preparation for enhancing them
Signed-off-by: Luke Kanies <luke@madstop.com>
-rwxr-xr-xspec/unit/type/user.rb50
1 files changed, 9 insertions, 41 deletions
diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb
index d16d752f9..4576f560b 100755
--- a/spec/unit/type/user.rb
+++ b/spec/unit/type/user.rb
@@ -2,55 +2,23 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-module UserTestFunctions
- def mkuser(name)
- user = nil;
- lambda {
- user = Puppet::Type.type(:user).create(
- :name => name,
- :comment => "Puppet Testing User",
- :gid => Puppet::Util::SUIDManager.gid,
- :shell => "/bin/sh",
- :home => "/home/%s" % name
- ) }.should_not raise_error
- user.should_not be_nil
- user
- end
-
- def test_provider_class(klass)
- klass.should_not be_nil
- klass.should be_an_instance_of(Class)
- superclasses = []
- while klass = klass.superclass
- superclasses << klass
- end
- superclasses.should include(Puppet::Provider)
- end
-end
-
-describe Puppet::Type.type(:user) do
+user = Puppet::Type.type(:user)
- include UserTestFunctions
+describe user do
+ after { user.clear }
it "should have a default provider inheriting from Puppet::Provider" do
- test_provider_class Puppet::Type.type(:user).defaultprovider
+ user.defaultprovider.ancestors.should be_include(Puppet::Provider)
end
it "should be able to create a instance" do
- mkuser "123testuser1"
+ user.create(:name => "foo").should_not be_nil
end
-end
-
-describe Puppet::Type.type(:user), "instances" do
- include UserTestFunctions
+ describe "instances" do
- it "should have a valid provider" do
- user = mkuser "123testuser2"
- user.provider.should_not be_nil
- test_provider_class user.provider.class
+ it "should have a valid provider" do
+ user.create(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
+ end
end
-
end
-
-