mirror of
https://github.com/inspec/inspec
synced 2024-11-15 09:27:20 +00:00
73 lines
1.3 KiB
Text
73 lines
1.3 KiB
Text
---
|
|
title: About the gem Resource
|
|
---
|
|
|
|
# gem
|
|
|
|
Use the `gem` InSpec audit resource to test if a global Gem package is installed.
|
|
|
|
# Syntax
|
|
|
|
A `gem` resource block declares a package and (optionally) a package version:
|
|
|
|
describe gem('gem_package_name') do
|
|
it { should be_installed }
|
|
end
|
|
|
|
where
|
|
|
|
* `('gem_package_name')` must specify a Gem package, such as `'rubocop'`
|
|
* `be_installed` is a valid matcher for this resource
|
|
|
|
# Matchers
|
|
|
|
This InSpec audit resource has the following matchers:
|
|
|
|
## be
|
|
|
|
<%= partial "/shared/matcher_be" %>
|
|
|
|
## be_installed
|
|
|
|
The `be_installed` matcher tests if the named Gem package is installed:
|
|
|
|
it { should be_installed }
|
|
|
|
## cmp
|
|
|
|
<%= partial "/shared/matcher_cmp" %>
|
|
|
|
## eq
|
|
|
|
<%= partial "/shared/matcher_eq" %>
|
|
|
|
## include
|
|
|
|
<%= partial "/shared/matcher_include" %>
|
|
|
|
## match
|
|
|
|
<%= partial "/shared/matcher_match" %>
|
|
|
|
## version
|
|
|
|
The `version` matcher tests if the named package version is on the system:
|
|
|
|
its('version') { should eq '0.33.0' }
|
|
|
|
# Examples
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
## Verify that a gem package is installed, with a specific version
|
|
|
|
describe gem('rubocop') do
|
|
it { should be_installed }
|
|
its('version') { should eq '0.33.0' }
|
|
end
|
|
|
|
## Verify that a gem package is not installed
|
|
|
|
describe gem('rubocop') do
|
|
it { should_not be_installed }
|
|
end
|