]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/rabbitmq/spec/unit/puppet/provider/rabbitmq_vhost/rabbitmqctl_spec.rb
move to puppetlabs rabbitmq module
[dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / puppet / provider / rabbitmq_vhost / rabbitmqctl_spec.rb
1 require 'puppet'
2 require 'mocha'
3 RSpec.configure do |config|
4   config.mock_with :mocha
5 end
6 provider_class = Puppet::Type.type(:rabbitmq_vhost).provider(:rabbitmqctl)
7 describe provider_class do
8   before :each do
9     @resource = Puppet::Type::Rabbitmq_vhost.new(
10       {:name => 'foo'}
11     )
12     @provider = provider_class.new(@resource)
13   end
14   it 'should match vhost names' do
15     @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
16 Listing vhosts ...
17 foo
18 ...done.
19 EOT
20     @provider.exists?.should == 'foo'
21   end
22   it 'should not match if no vhosts on system' do
23     @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
24 Listing vhosts ...
25 ...done.
26 EOT
27     @provider.exists?.should be_nil
28   end
29   it 'should not match if no matching vhosts on system' do
30     @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
31 Listing vhosts ...
32 fooey
33 ...done.
34 EOT
35     @provider.exists?.should be_nil
36   end
37   it 'should call rabbitmqctl to create' do
38     @provider.expects(:rabbitmqctl).with('add_vhost', 'foo')
39     @provider.create
40   end
41   it 'should call rabbitmqctl to create' do
42     @provider.expects(:rabbitmqctl).with('delete_vhost', 'foo')
43     @provider.destroy
44   end
45 end