inspec/test/unit/resources/virtualization_test.rb
Jerry Aldrich 4631306ef1 virtualization_resource: Fix NoMethodError on nil:NilClass (#2603)
* Move instance variable to avoid `NoMethodError`

Methods for `role` and `system` properties are dynamically generated and
return values from the `@virtualization_data` Mash. Therefor, we must
ensure `@virtualization_data` exists before calling these methods.

* Move supports logic to `supports platform: linux`

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2018-02-28 14:22:55 -05:00

18 lines
515 B
Ruby

# encoding: utf-8
require 'helper'
require 'inspec/resource'
describe 'Inspec::Resources::Virtualization' do
let(:resource) { MockLoader.new(:ubuntu).load_resource('virtualization') }
it 'skips the resource if OS is not Linux' do
resource = MockLoader.new(:windows).load_resource('virtualization')
resource.resource_skipped?.must_equal true
end
it 'returns nil for all properties if no virutalization platform is found' do
resource.system.must_be_nil
resource.role.must_be_nil
end
end