Skip to content

Commit cee76d9

Browse files
committed
Avoid shadowing the variables in tests
Rspec scoping is complicated matter. This avoids masking variables and methods.
1 parent b3be95f commit cee76d9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

spec/defines/foreman_proxy_plugin_spec.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
require 'spec_helper'
22

33
describe 'foreman_proxy::plugin' do
4-
on_supported_os.each do |os, facts|
4+
on_supported_os.each do |os, os_facts|
55
context "on #{os}" do
6-
let(:facts) { facts }
6+
let(:facts) { os_facts }
77
let(:title) { 'myplugin' }
88
let(:pre_condition) { 'include foreman_proxy::params' }
99

1010
context 'no parameters' do
11-
package = if facts[:osfamily] == 'Debian'
12-
'ruby-smart-proxy-myplugin'
13-
elsif facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '7'
14-
'tfm-rubygem-smart_proxy_myplugin'
15-
else
16-
'rubygem-smart_proxy_myplugin'
17-
end
11+
let(:package) do
12+
if facts[:osfamily] == 'Debian'
13+
'ruby-smart-proxy-myplugin'
14+
elsif facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '7'
15+
'tfm-rubygem-smart_proxy_myplugin'
16+
else
17+
'rubygem-smart_proxy_myplugin'
18+
end
19+
end
1820

1921
it 'should install the correct package' do
2022
should contain_package(package).with_ensure('installed')
@@ -47,7 +49,7 @@
4749
:package => 'my_fun_plugin',
4850
} end
4951

50-
case facts[:osfamily]
52+
case os_facts[:osfamily]
5153
when 'Debian'
5254
it 'should use hyphens' do
5355
should contain_package('my-fun-plugin').with_ensure('installed')

0 commit comments

Comments
 (0)