-require 'spec_helper'
-
+require 'puppet'
+require 'mocha'
+RSpec.configure do |config|
+ config.mock_with :mocha
+end
provider_class = Puppet::Type.type(:rabbitmq_vhost).provider(:rabbitmqctl)
describe provider_class do
- let(:resource) do
- Puppet::Type::Rabbitmq_vhost.new(
- name: 'foo'
+ before :each do
+ @resource = Puppet::Type::Rabbitmq_vhost.new(
+ {:name => 'foo'}
)
+ @provider = provider_class.new(@resource)
end
- let(:provider) { provider_class.new(resource) }
-
- it 'matches vhost names' do
- provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
+ it 'should match vhost names' do
+ @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
Listing vhosts ...
foo
...done.
EOT
- expect(provider.exists?).to eq(true)
+ @provider.exists?.should == 'foo'
end
- it 'does not match if no vhosts on system' do
- provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
+ it 'should not match if no vhosts on system' do
+ @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
Listing vhosts ...
...done.
EOT
- expect(provider.exists?).to eq(false)
+ @provider.exists?.should be_nil
end
- it 'does not match if no matching vhosts on system' do
- provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
+ it 'should not match if no matching vhosts on system' do
+ @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
Listing vhosts ...
fooey
...done.
EOT
- expect(provider.exists?).to eq(false)
+ @provider.exists?.should be_nil
end
- it 'calls rabbitmqctl to create' do
- provider.expects(:rabbitmqctl).with('add_vhost', 'foo')
- provider.create
+ it 'should call rabbitmqctl to create' do
+ @provider.expects(:rabbitmqctl).with('add_vhost', 'foo')
+ @provider.create
end
- it 'calls rabbitmqctl to create' do
- provider.expects(:rabbitmqctl).with('delete_vhost', 'foo')
- provider.destroy
+ it 'should call rabbitmqctl to create' do
+ @provider.expects(:rabbitmqctl).with('delete_vhost', 'foo')
+ @provider.destroy
end
end