X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Frabbitmq%2Fspec%2Funit%2Fpuppet%2Ftype%2Frabbitmq_binding_spec.rb;fp=3rdparty%2Fmodules%2Frabbitmq%2Fspec%2Funit%2Fpuppet%2Ftype%2Frabbitmq_binding_spec.rb;h=14b8824871b3fe7ef4495b7ffea72ff8fa504a12;hb=94a8783f522bbf2996cb8a59b977dea583e8b0c7;hp=b0671e7c27a1addf2addce82393e2e07b177bc53;hpb=e107504bce7d9b21cc301124fc7c39fdb0762374;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_binding_spec.rb b/3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_binding_spec.rb index b0671e7c2..14b882487 100644 --- a/3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_binding_spec.rb +++ b/3rdparty/modules/rabbitmq/spec/unit/puppet/type/rabbitmq_binding_spec.rb @@ -1,50 +1,47 @@ -require 'puppet' -require 'puppet/type/rabbitmq_binding' +require 'spec_helper' describe Puppet::Type.type(:rabbitmq_binding) do - before :each do - @binding = Puppet::Type.type(:rabbitmq_binding).new( - :name => 'foo@blub@bar', - :destination_type => :queue + let(:binding) do + Puppet::Type.type(:rabbitmq_binding).new( + name: 'foo@blub@bar', + destination_type: :queue ) end - it 'should accept an queue name' do - @binding[:name] = 'dan@dude@pl' - @binding[:name].should == 'dan@dude@pl' - end - it 'should require a name' do - expect { - Puppet::Type.type(:rabbitmq_binding).new({}) - }.to raise_error(Puppet::Error, 'Title or name must be provided') - end - it 'should not allow whitespace in the name' do - expect { - @binding[:name] = 'b r' - }.to raise_error(Puppet::Error, /Valid values match/) - end - it 'should not allow names without one @' do - expect { - @binding[:name] = 'b_r' - }.to raise_error(Puppet::Error, /Valid values match/) - end - it 'should not allow names without two @' do - expect { - @binding[:name] = 'b@r' - }.to raise_error(Puppet::Error, /Valid values match/) + it 'accepts an queue name' do + binding[:name] = 'dan@dude@pl' + expect(binding[:name]).to eq('dan@dude@pl') end - - it 'should accept an binding destination_type' do - @binding[:destination_type] = :exchange - @binding[:destination_type].should == :exchange - end - - it 'should accept a user' do - @binding[:user] = :root - @binding[:user].should == :root - end - - it 'should accept a password' do - @binding[:password] = :PaSsw0rD - @binding[:password].should == :PaSsw0rD + it 'requires a name' do + expect do + Puppet::Type.type(:rabbitmq_binding).new({}) + end.to raise_error(Puppet::Error, 'Title or name must be provided') + end + it 'errors when missing source' do + expect do + Puppet::Type.type(:rabbitmq_binding).new( + name: 'test binding', + destination: 'foobar' + ) + end.to raise_error(Puppet::Error, %r{`source` must be defined}) + end + it 'errors when missing destination' do + expect do + Puppet::Type.type(:rabbitmq_binding).new( + name: 'test binding', + source: 'foobar' + ) + end.to raise_error(Puppet::Error, %r{`destination` must be defined}) + end + it 'accepts an binding destination_type' do + binding[:destination_type] = :exchange + expect(binding[:destination_type]).to eq(:exchange) + end + it 'accepts a user' do + binding[:user] = :root + expect(binding[:user]).to eq(:root) + end + it 'accepts a password' do + binding[:password] = :PaSsw0rD + expect(binding[:password]).to eq(:PaSsw0rD) end end