-require 'spec_helper'
+require 'puppet'
+require 'puppet/type/rabbitmq_exchange'
describe Puppet::Type.type(:rabbitmq_exchange) do
- let(:exchange) do
- Puppet::Type.type(:rabbitmq_exchange).new(
- name: 'foo@bar',
- type: :topic,
- internal: false,
- auto_delete: false,
- durable: true
+ before :each do
+ @exchange = Puppet::Type.type(:rabbitmq_exchange).new(
+ :name => 'foo@bar',
+ :type => :topic,
+ :internal => false,
+ :auto_delete => false,
+ :durable => true
)
end
-
- it 'accepts an exchange name' do
- exchange[:name] = 'dan@pl'
- expect(exchange[:name]).to eq('dan@pl')
+ it 'should accept an exchange name' do
+ @exchange[:name] = 'dan@pl'
+ @exchange[:name].should == 'dan@pl'
end
- it 'requires a name' do
- expect do
+ it 'should require a name' do
+ expect {
Puppet::Type.type(:rabbitmq_exchange).new({})
- end.to raise_error(Puppet::Error, 'Title or name must be provided')
+ }.to raise_error(Puppet::Error, 'Title or name must be provided')
end
- it 'does not allow whitespace in the name' do
- expect do
- exchange[:name] = 'b r'
- end.to raise_error(Puppet::Error, %r{Valid values match})
+ it 'should not allow whitespace in the name' do
+ expect {
+ @exchange[:name] = 'b r'
+ }.to raise_error(Puppet::Error, /Valid values match/)
end
- it 'does not allow names without @' do
- expect do
- exchange[:name] = 'b_r'
- end.to raise_error(Puppet::Error, %r{Valid values match})
+ it 'should not allow names without @' do
+ expect {
+ @exchange[:name] = 'b_r'
+ }.to raise_error(Puppet::Error, /Valid values match/)
end
- it 'accepts an exchange type' do
- exchange[:type] = :direct
- expect(exchange[:type]).to eq(:direct)
+ it 'should accept an exchange type' do
+ @exchange[:type] = :direct
+ @exchange[:type].should == :direct
end
- it 'requires a type' do
- expect do
- Puppet::Type.type(:rabbitmq_exchange).new(name: 'foo@bar')
- end.to raise_error(%r{.*must set type when creating exchange.*})
+ it 'should require a type' do
+ expect {
+ Puppet::Type.type(:rabbitmq_exchange).new(:name => 'foo@bar')
+ }.to raise_error(/.*must set type when creating exchange.*/)
end
- it 'does not require a type when destroying' do
- expect do
- Puppet::Type.type(:rabbitmq_exchange).new(name: 'foo@bar', ensure: :absent)
- end.not_to raise_error
+ it 'should not require a type when destroying' do
+ expect {
+ Puppet::Type.type(:rabbitmq_exchange).new(:name => 'foo@bar', :ensure => :absent)
+ }.to_not raise_error
end
- it 'accepts a user' do
- exchange[:user] = :root
- expect(exchange[:user]).to eq(:root)
+ it 'should accept a user' do
+ @exchange[:user] = :root
+ @exchange[:user].should == :root
end
- it 'accepts a password' do
- exchange[:password] = :PaSsw0rD
- expect(exchange[:password]).to eq(:PaSsw0rD)
+ it 'should accept a password' do
+ @exchange[:password] = :PaSsw0rD
+ @exchange[:password].should == :PaSsw0rD
end
end