2015-09-08 22:11:42 +00:00
|
|
|
# encoding: utf-8
|
2015-10-06 16:55:44 +00:00
|
|
|
# author: Christoph Hartmann
|
|
|
|
# author: Dominik Richter
|
2017-03-25 05:28:42 +00:00
|
|
|
# author: Joe Nuspl
|
2015-09-08 22:11:42 +00:00
|
|
|
|
|
|
|
require 'helper'
|
2015-10-26 03:04:18 +00:00
|
|
|
require 'inspec/resource'
|
2015-09-08 22:11:42 +00:00
|
|
|
|
2015-10-26 03:04:18 +00:00
|
|
|
describe 'Inspec::Resources::Gem' do
|
2015-09-22 16:33:05 +00:00
|
|
|
it 'verify gem package detail parsing' do
|
2015-10-12 11:21:50 +00:00
|
|
|
resource = load_resource('gem', 'rubocop')
|
2015-09-22 16:33:05 +00:00
|
|
|
pkg = {
|
|
|
|
name: 'rubocop',
|
|
|
|
version: '0.33.0',
|
|
|
|
type: 'gem',
|
|
|
|
installed: true,
|
|
|
|
}
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.info).must_equal pkg
|
2017-03-25 05:28:42 +00:00
|
|
|
_(resource.gem_binary).must_equal 'gem'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'specifying gem binary' do
|
|
|
|
resource = load_resource('gem', 'pry', '/opt/ruby-2.3.1/embedded/bin/gem')
|
|
|
|
pkg = {
|
|
|
|
name: 'pry',
|
|
|
|
version: '0.10.4',
|
|
|
|
type: 'gem',
|
|
|
|
installed: true,
|
|
|
|
}
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.info).must_equal pkg
|
|
|
|
_(resource.gem_binary).must_equal '/opt/ruby-2.3.1/embedded/bin/gem'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'verify gem in :chef' do
|
|
|
|
resource = load_resource('gem', 'chef-sugar', :chef)
|
|
|
|
pkg = {
|
|
|
|
name: 'chef-sugar',
|
|
|
|
version: '3.4.0',
|
|
|
|
type: 'gem',
|
|
|
|
installed: true,
|
|
|
|
}
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.info).must_equal pkg
|
|
|
|
_(resource.gem_binary).must_equal '/opt/chef/embedded/bin/gem'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'verify gem in :chef on windows' do
|
|
|
|
resource = MockLoader.new(:windows).load_resource('gem', 'json', :chef)
|
|
|
|
pkg = {
|
|
|
|
name: 'json',
|
|
|
|
version: '1.8.3',
|
|
|
|
type: 'gem',
|
|
|
|
installed: true,
|
|
|
|
}
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.info).must_equal pkg
|
2017-04-12 15:22:58 +00:00
|
|
|
_(resource.gem_binary).must_equal 'c:\opscode\chef\embedded\bin\gem.bat'
|
2017-03-25 05:28:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'verify gem in :chef_server' do
|
|
|
|
resource = load_resource('gem', 'knife-backup', :chef_server)
|
|
|
|
pkg = {
|
|
|
|
name: 'knife-backup',
|
|
|
|
version: '0.0.12',
|
|
|
|
type: 'gem',
|
|
|
|
installed: true,
|
|
|
|
}
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.info).must_equal pkg
|
|
|
|
_(resource.gem_binary).must_equal '/opt/opscode/embedded/bin/gem'
|
2015-09-08 22:11:42 +00:00
|
|
|
end
|
|
|
|
end
|