Skip to content

Commit

Permalink
Merge pull request #594 from wyardley/multiple_expectations1
Browse files Browse the repository at this point in the history
Remove redundant specs, rework others to avoid multiple expectation warnings
  • Loading branch information
wyardley authored Sep 4, 2017
2 parents 1985f15 + 22b9c5e commit 3370f18
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions spec/unit/puppet/provider/rabbitmq_user/rabbitmqctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
foo [administrator]
EOT
expect(provider.admin).to eq(:true)
end
it 'is able to retrieve correct admin value when there are multiple results' do
provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
one [administrator]
foo []
Expand Down
8 changes: 5 additions & 3 deletions spec/unit/puppet/type/rabbitmq_parameter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@
expect(parameter[:value]).to eq(value)
end

it 'does not accept invalid hash for definition' do
it 'does not accept an empty string for definition' do
expect do
parameter[:value] = ''
end.to raise_error(Puppet::Error, %r{Invalid value})
end

it 'does not accept a string for definition' do
expect do
parameter[:value] = 'guest'
end.to raise_error(Puppet::Error, %r{Invalid value})
end

it 'does not accept an array for definition' do
expect do
parameter[:value] = { 'message-ttl' => %w[999 100] }
end.to raise_error(Puppet::Error, %r{Invalid value})
Expand All @@ -64,14 +68,12 @@
it 'accepts string as myparameter' do
value = { 'myparameter' => 'mystring' }
parameter[:value] = value
expect(parameter[:value]['myparameter']).to be_a(String)
expect(parameter[:value]['myparameter']).to eq('mystring')
end

it 'converts to integer when string only contains numbers' do
value = { 'myparameter' => '1800000' }
parameter[:value] = value
expect(parameter[:value]['myparameter']).to be_a(Integer)
expect(parameter[:value]['myparameter']).to eq(1_800_000)
end
end
1 change: 0 additions & 1 deletion spec/unit/puppet/type/rabbitmq_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
it 'accepts an arguments with numbers value' do
queue[:arguments] = { 'x-message-ttl' => 30 }
expect(queue[:arguments].to_json).to eq('{"x-message-ttl":30}')
expect(queue[:arguments]['x-message-ttl']).to eq(30)
end

it 'accepts an arguments with string value' do
Expand Down
3 changes: 3 additions & 0 deletions spec/unit/puppet/type/rabbitmq_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
it 'accepts a user name' do
user[:name] = 'dan'
expect(user[:name]).to eq('dan')
end
it 'admin is false when :admin is not set' do
user[:name] = 'dan'
expect(user[:admin]).to eq(:false)
end
it 'accepts a password' do
Expand Down

0 comments on commit 3370f18

Please sign in to comment.