mirror of
https://github.com/inspec/inspec
synced 2024-11-14 17:07:09 +00:00
Merge pull request #1650 from chef/adamleff/fix-gem-on-windows
Fix gem resource on Windows
This commit is contained in:
commit
510bc17bf8
3 changed files with 6 additions and 3 deletions
|
@ -23,7 +23,7 @@ module Inspec::Resources
|
|||
'gem'
|
||||
when :chef
|
||||
if inspec.os.windows?
|
||||
'c:\opscode\chef\embedded\bin\gem'
|
||||
'c:\opscode\chef\embedded\bin\gem.bat'
|
||||
else
|
||||
'/opt/chef/embedded/bin/gem'
|
||||
end
|
||||
|
@ -32,6 +32,7 @@ module Inspec::Resources
|
|||
else
|
||||
gem_binary
|
||||
end
|
||||
skip_resource 'Unable to retrieve gem information' if info.empty?
|
||||
end
|
||||
|
||||
def info
|
||||
|
@ -47,6 +48,8 @@ module Inspec::Resources
|
|||
# extract package name and version
|
||||
# parses data like winrm (1.3.4, 1.3.3)
|
||||
params = /^\s*([^\(]*?)\s*\((.*?)\)\s*$/.match(cmd.stdout.chomp)
|
||||
return {} if params.nil?
|
||||
|
||||
versions = params[2].split(',')
|
||||
@info[:name] = params[1]
|
||||
@info[:version] = versions[0]
|
||||
|
|
|
@ -175,7 +175,7 @@ class MockLoader
|
|||
'gem list --local -a -q ^rubocop$' => cmd.call('gem-list-local-a-q-rubocop'),
|
||||
'/opt/ruby-2.3.1/embedded/bin/gem list --local -a -q ^pry$' => cmd.call('gem-list-local-a-q-pry'),
|
||||
'/opt/chef/embedded/bin/gem list --local -a -q ^chef-sugar$' => cmd.call('gem-list-local-a-q-chef-sugar'),
|
||||
'c:\opscode\chef\embedded\bin\gem list --local -a -q ^json$' => cmd.call('gem-list-local-a-q-json'),
|
||||
'c:\opscode\chef\embedded\bin\gem.bat list --local -a -q ^json$' => cmd.call('gem-list-local-a-q-json'),
|
||||
'/opt/opscode/embedded/bin/gem list --local -a -q ^knife-backup$' => cmd.call('gem-list-local-a-q-knife-backup'),
|
||||
'npm ls -g --json bower' => cmd.call('npm-ls-g--json-bower'),
|
||||
'pip show jinja2' => cmd.call('pip-show-jinja2'),
|
||||
|
|
|
@ -56,7 +56,7 @@ describe 'Inspec::Resources::Gem' do
|
|||
}
|
||||
_(resource.installed?).must_equal true
|
||||
_(resource.info).must_equal pkg
|
||||
_(resource.gem_binary).must_equal 'c:\opscode\chef\embedded\bin\gem'
|
||||
_(resource.gem_binary).must_equal 'c:\opscode\chef\embedded\bin\gem.bat'
|
||||
end
|
||||
|
||||
it 'verify gem in :chef_server' do
|
||||
|
|
Loading…
Reference in a new issue