|
97 | 97 | end
|
98 | 98 | end
|
99 | 99 | end
|
| 100 | + |
| 101 | + describe "#pkg_config_path" do |
| 102 | + it { expect(@run_mode.pkg_config_path).to eq('/opt/puppetlabs/puppet/lib/pkgconfig') } |
| 103 | + end |
| 104 | + |
| 105 | + describe "#gem_cmd" do |
| 106 | + it { expect(@run_mode.gem_cmd).to eq('/opt/puppetlabs/puppet/bin/gem') } |
| 107 | + end |
| 108 | + |
| 109 | + describe "#common_module_dir" do |
| 110 | + it { expect(@run_mode.common_module_dir).to eq('/opt/puppetlabs/puppet/modules') } |
| 111 | + end |
| 112 | + |
| 113 | + describe "#vendor_module_dir" do |
| 114 | + it { expect(@run_mode.vendor_module_dir).to eq('/opt/puppetlabs/puppet/vendor_modules') } |
| 115 | + end |
100 | 116 | end
|
101 | 117 |
|
102 | 118 | describe Puppet::Util::WindowsRunMode, :if => Puppet::Util::Platform.windows? do
|
|
171 | 187 | end
|
172 | 188 | end
|
173 | 189 | end
|
| 190 | + |
| 191 | + describe '#gem_cmd' do |
| 192 | + before do |
| 193 | + allow(ENV).to receive(:fetch).and_call_original |
| 194 | + allow(ENV).to receive(:fetch).with('PUPPET_DIR').and_return(puppetdir) |
| 195 | + end |
| 196 | + |
| 197 | + context 'when PUPPET_DIR is not set' do |
| 198 | + let(:puppetdir) { nil } |
| 199 | + |
| 200 | + before do |
| 201 | + allow(Gem).to receive(:default_bindir).and_return('default_gem_bin') |
| 202 | + end |
| 203 | + |
| 204 | + it 'uses Gem.default_bindir' do |
| 205 | + expected_path = File.join('default_gem_bin', 'gem.bat') |
| 206 | + expect(@run_mode.gem_cmd).to eql(expected_path) |
| 207 | + end |
| 208 | + end |
| 209 | + |
| 210 | + context 'when PUPPET_DIR is set' do |
| 211 | + let(:puppetdir) { 'puppet_dir' } |
| 212 | + |
| 213 | + it 'uses Gem.default_bindir' do |
| 214 | + expected_path = File.join('puppet_dir', 'bin', 'gem.bat') |
| 215 | + expect(@run_mode.gem_cmd).to eql(expected_path) |
| 216 | + end |
| 217 | + end |
| 218 | + end |
| 219 | + |
| 220 | + describe '#common_module_dir' do |
| 221 | + before do |
| 222 | + allow(ENV).to receive(:fetch).and_call_original |
| 223 | + allow(ENV).to receive(:fetch).with('FACTER_env_windows_installdir', nil).and_return(installdir) |
| 224 | + end |
| 225 | + |
| 226 | + context 'when installdir is not set' do |
| 227 | + let(:installdir) { nil } |
| 228 | + |
| 229 | + it 'returns nil' do |
| 230 | + expect(@run_mode.common_module_dir).to be(nil) |
| 231 | + end |
| 232 | + end |
| 233 | + |
| 234 | + context 'with installdir' do |
| 235 | + let(:installdir) { 'C:\Program Files\Puppet Labs\Puppet' } |
| 236 | + |
| 237 | + it 'returns INSTALLDIR/puppet/modules' do |
| 238 | + expect(@run_mode.common_module_dir).to eq('C:\Program Files\Puppet Labs\Puppet/puppet/modules') |
| 239 | + end |
| 240 | + end |
| 241 | + end |
| 242 | + |
| 243 | + describe '#vendor_module_dir' do |
| 244 | + before do |
| 245 | + allow(ENV).to receive(:fetch).and_call_original |
| 246 | + allow(ENV).to receive(:fetch).with('FACTER_env_windows_installdir', nil).and_return(installdir) |
| 247 | + end |
| 248 | + |
| 249 | + context 'when installdir is not set' do |
| 250 | + let(:installdir) { nil } |
| 251 | + |
| 252 | + it 'returns nil' do |
| 253 | + expect(@run_mode.vendor_module_dir).to be(nil) |
| 254 | + end |
| 255 | + end |
| 256 | + |
| 257 | + context 'with installdir' do |
| 258 | + let(:installdir) { 'C:\Program Files\Puppet Labs\Puppet' } |
| 259 | + |
| 260 | + it 'returns INSTALLDIR\puppet\vendor_modules' do |
| 261 | + expect(@run_mode.vendor_module_dir).to eq('C:\Program Files\Puppet Labs\Puppet\puppet\vendor_modules') |
| 262 | + end |
| 263 | + end |
| 264 | + end |
174 | 265 | end
|
175 | 266 |
|
176 | 267 | def as_root
|
|
0 commit comments