2 require 'puppet/type/rabbitmq_user'
3 describe Puppet::Type.type(:rabbitmq_user) do
5 @user = Puppet::Type.type(:rabbitmq_user).new(:name => 'foo', :password => 'pass')
7 it 'should accept a user name' do
9 @user[:name].should == 'dan'
10 @user[:admin].should == :false
12 it 'should accept a password' do
13 @user[:password] = 'foo'
14 @user[:password].should == 'foo'
16 it 'should require a password' do
18 Puppet::Type.type(:rabbitmq_user).new(:name => 'foo')
19 }.to raise_error(/must set password/)
21 it 'should require a name' do
23 Puppet::Type.type(:rabbitmq_user).new({})
24 }.to raise_error(Puppet::Error, 'Title or name must be provided')
26 it 'should not allow whitespace in the name' do
29 }.to raise_error(Puppet::Error, /Valid values match/)
31 [true, false, 'true', 'false'].each do |val|
32 it "admin property should accept #{val}" do
34 @user[:admin].should == val.to_s.to_sym
37 it 'should not accept non-boolean values for admin' do
40 }.to raise_error(Puppet::Error, /Invalid value/)
42 it 'should not accept tags with spaces' do
44 @user[:tags] = ['policy maker']
45 }.to raise_error(Puppet::Error, /Invalid tag/)
47 it 'should not accept the administrator tag' do
49 @user[:tags] = ['administrator']
50 }.to raise_error(Puppet::Error, /must use admin property/)