2017-10-25 14:14:29 +00:00
|
|
|
---
|
|
|
|
title: About the cran Resource
|
2018-02-16 00:28:15 +00:00
|
|
|
platform: linux
|
2017-10-25 14:14:29 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# cran
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
Use the `cran` Chef InSpec audit resource to test R modules that are installed from CRAN package repository.
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-16 00:28:15 +00:00
|
|
|
<br>
|
2018-02-02 12:36:36 +00:00
|
|
|
|
2018-08-09 12:34:49 +00:00
|
|
|
## Availability
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
This resource is distributed along with Chef InSpec itself. You can use it automatically.
|
2018-08-09 12:34:49 +00:00
|
|
|
|
|
|
|
### Version
|
|
|
|
|
|
|
|
This resource first became available in v1.43.5 of InSpec.
|
|
|
|
|
2017-10-25 14:14:29 +00:00
|
|
|
## 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
|
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
<br>
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-15 14:33:22 +00:00
|
|
|
## Examples
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
The following examples show how to use this Chef InSpec audit resource.
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
### Test if DBI is installed on the system
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
describe cran('DBI') do
|
|
|
|
it { should be_installed }
|
|
|
|
end
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
### 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
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
## Property Examples
|
2017-10-25 14:14:29 +00:00
|
|
|
|
|
|
|
### version
|
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
The `version` property tests if the named package version is on the system:
|
2017-10-25 14:14:29 +00:00
|
|
|
|
|
|
|
its('version') { should eq '1.2.3' }
|
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
<br>
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
## Matchers
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
This Chef InSpec audit resource has the following matchers:
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
### be_installed
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
The `be_installed` matcher tests if the named package is installed on the system:
|
2017-10-25 14:14:29 +00:00
|
|
|
|
2018-02-02 12:36:36 +00:00
|
|
|
it { should be_installed }
|