inspec/docs/resources/cran.md.erb
Markus Grobelin 2251270929 cran resource: check for R module installation (#2255)
* Added CRAN resource to check R modules

control 'cran-1' do
  impact 1.0
  desc '
    Ensure R module DBI is installed.
  '

  describe cpan('DBI') do
    it { should be_installed }
    its('version') { should cmp >= '3.0' }
  end
end

Signed-off-by: Markus Grobelin <grobi@koppzu.de>

* cran resource: made lint happy, added negative unit test, removed unused arg perl_lib_path

Signed-off-by: Markus Grobelin <grobi@koppzu.de>
2017-10-25 16:14:29 +02:00

54 lines
No EOL
1.1 KiB
Text

---
title: About the cran Resource
---
# cran
Use the `cran` InSpec audit resource to test R modules that are installed from CRAN package repository.
## Syntax
A `cran` resource block declares a package and (optionally) a package version:
describe cran('package_name') do
it { should be_installed }
end
where
* `'package_name'` is the name of the package, such as `'DBI'`
* `be_installed` tests to see if the package described above is installed
## Matchers
This InSpec audit resource has the following matchers:
### be_installed
The `be_installed` matcher tests if the named package is installed on the system:
it { should be_installed }
### version
The `version` matcher tests if the named package version is on the system:
its('version') { should eq '1.2.3' }
## Examples
The following examples show how to use this InSpec audit resource.
### Test if DBI is installed on the system
describe cran('DBI') do
it { should be_installed }
end
### Test if DBI 0.5.1 is installed on the system
describe cran('DBI') do
it { should be_installed }
its('version') { should eq '0.5.1' }
end