3 RSpec.configure do |config|
4 config.mock_with :mocha
6 provider_class = Puppet::Type.type(:rabbitmq_binding).provider(:rabbitmqadmin)
7 describe provider_class do
9 @resource = Puppet::Type::Rabbitmq_binding.new(
10 {:name => 'source@target@/',
11 :destination_type => :queue,
12 :routing_key => 'blablub',
16 @provider = provider_class.new(@resource)
19 it 'should return instances' do
20 provider_class.expects(:rabbitmqctl).with('list_vhosts', '-q').returns <<-EOT
23 provider_class.expects(:rabbitmqctl).with('list_bindings', '-q', '-p', '/', 'source_name', 'destination_name', 'destination_kind', 'routing_key', 'arguments').returns <<-EOT
26 instances = provider_class.instances
27 instances.size.should == 1
30 it 'should call rabbitmqadmin to create' do
31 @provider.expects(:rabbitmqadmin).with('declare', 'binding', '--vhost=/', '--user=guest', '--password=guest', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=source', 'destination=target', 'arguments={}', 'routing_key=blablub', 'destination_type=queue')
35 it 'should call rabbitmqadmin to destroy' do
36 @provider.expects(:rabbitmqadmin).with('delete', 'binding', '--vhost=/', '--user=guest', '--password=guest', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=source', 'destination_type=queue', 'destination=target', 'properties_key=blablub')
40 context 'specifying credentials' do
42 @resource = Puppet::Type::Rabbitmq_binding.new(
43 {:name => 'source@test2@/',
44 :destination_type => :queue,
45 :routing_key => 'blablubd',
51 @provider = provider_class.new(@resource)
54 it 'should call rabbitmqadmin to create' do
55 @provider.expects(:rabbitmqadmin).with('declare', 'binding', '--vhost=/', '--user=colin', '--password=secret', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=source', 'destination=test2', 'arguments={}', 'routing_key=blablubd', 'destination_type=queue')