Skip to content

Commit

Permalink
Merge pull request voxpupuli#593 from wyardley/switch_more_lets
Browse files Browse the repository at this point in the history
move these tests to a context block, and use 'let(:foo)' syntax
  • Loading branch information
alexjfisher committed Sep 4, 2017
2 parents fc414f9 + 5fc6f45 commit 2c082d7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 29 deletions.
39 changes: 23 additions & 16 deletions spec/unit/puppet/provider/rabbitmq_parameter/rabbitmqctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,35 @@
provider: described_class.name
)
end

let(:provider) { resource.provider }

after do
described_class.instance_variable_set(:@parameters, nil)
end

it 'accepts @ in parameter name' do
resource = Puppet::Type.type(:rabbitmq_parameter).new(
name: 'documentumShovel@/',
component_name: 'shovel',
value: {
'src-uri' => 'amqp://',
'src-queue' => 'my-queue',
'dest-uri' => 'amqp://remote-server',
'dest-queue' => 'another-queue'
},
provider: described_class.name
)
provider = described_class.new(resource)
expect(provider.should_parameter).to eq('documentumShovel')
expect(provider.should_vhost).to eq('/')
context 'has "@" in parameter name' do
let(:resource) do
Puppet::Type.type(:rabbitmq_parameter).new(
name: 'documentumShovel@/',
component_name: 'shovel',
value: {
'src-uri' => 'amqp://',
'src-queue' => 'my-queue',
'dest-uri' => 'amqp://remote-server',
'dest-queue' => 'another-queue'
},
provider: described_class.name
)
end
let(:provider) { described_class.new(resource) }

it do
expect(provider.should_parameter).to eq('documentumShovel')
end

it do
expect(provider.should_vhost).to eq('/')
end
end

it 'fails with invalid output from list' do
Expand Down
33 changes: 20 additions & 13 deletions spec/unit/puppet/provider/rabbitmq_policy/rabbitmqctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,32 @@
provider: described_class.name
)
end

let(:provider) { resource.provider }

after do
described_class.instance_variable_set(:@policies, nil)
end

it 'accepts @ in policy name' do
resource = Puppet::Type.type(:rabbitmq_policy).new(
name: 'ha@home@/',
pattern: '.*',
definition: {
'ha-mode' => 'all'
},
provider: described_class.name
)
provider = described_class.new(resource)
expect(provider.should_policy).to eq('ha@home')
expect(provider.should_vhost).to eq('/')
context 'has "@" in policy name' do
let(:resource) do
Puppet::Type.type(:rabbitmq_policy).new(
name: 'ha@home@/',
pattern: '.*',
definition: {
'ha-mode' => 'all'
},
provider: described_class.name
)
end
let(:provider) { described_class.new(resource) }

it do
expect(provider.should_policy).to eq('ha@home')
end

it do
expect(provider.should_vhost).to eq('/')
end
end

it 'fails with invalid output from list' do
Expand Down

0 comments on commit 2c082d7

Please sign in to comment.