inspec/test/unit/resources/cpan_test.rb
Markus Grobelin c626dfdbd9 cpan resource: check for Perl module installation (#2254)
* Added CPAN resource to check Perl modules

control 'cpan-1' do
  impact 1.0
  desc '
    Ensure Perl modules DBI and DBD::Pg are installed.
  '

  describe cpan('DBI') do
    it { should be_installed }
  end

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

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

* cpan resource: fixed unit test for non-installed module

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

25 lines
842 B
Ruby

# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter
# author: Markus Grobelin
require 'helper'
require 'inspec/resource'
describe 'Inspec::Resources::Cpan' do
it 'verify cpan package detail parsing' do
resource = load_resource('cpan', 'DBD::Pg')
pkg = {type: 'cpan', name: 'DBD::Pg', version: '3.7.0', installed: true}
_(resource.installed?).must_equal true
_(resource.info).must_equal pkg
end
it 'verify info for non-installed packages' do
resource = load_resource('cpan', 'DOES::Not::Exist')
pkg = {type: 'cpan', name: 'DOES::Not::Exist', installed: false}
_(resource.installed?).must_equal false
_(resource.version).must_be_nil
_(resource.info[:name]).must_equal 'DOES::Not::Exist'
_(resource.info[:type]).must_equal 'cpan'
_(resource.info).must_equal pkg
end
end