Skip to content

Commit 436308d

Browse files
committed
Define apache_name via a let block
Defining variables in rspec is dangerous since they end up being defined on classes. That means that in a for loop it may end up being defined as the last running version. A let block provides proper variable scoping. This wasn't a problem until fb0d078 where it ran spec tests on all operating systems. Then it became dependent on the order of the supported operating systems. Fixes: fb0d078
1 parent 1393439 commit 436308d

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

spec/defines/vhost_spec.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
describe 'apache::vhost', type: :define do
66
describe 'os-independent items' do
77
on_supported_os.each do |os, facts|
8-
apache_name = case facts[:os]['family']
9-
when 'RedHat'
10-
'httpd'
11-
when 'Debian'
12-
'apache2'
13-
else
14-
'apache2'
15-
end
8+
let(:apache_name) { facts[:os]['family'] == 'RedHat' ? 'httpd' : 'apache2' }
169

1710
let :pre_condition do
1811
"class {'apache': default_vhost => false, default_mods => false, vhost_enable_dir => '/etc/#{apache_name}/sites-enabled'}"

0 commit comments

Comments
 (0)