inspec/test/unit/plugins/plugin_test.rb

45 lines
1 KiB
Ruby
Raw Normal View History

2016-02-05 11:40:57 +00:00
# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter
2016-02-05 15:57:51 +00:00
# TODO: do not use helper, since all plugins are loaded statically
require 'minitest/autorun'
require 'minitest/spec'
require 'mocha/setup'
require 'inspec/plugins/cli'
2016-02-05 11:40:57 +00:00
require 'thor'
describe 'plugin system' do
describe 'with an empty profile' do
let(:cli_reg) { Inspec::Plugins::CLI }
2016-02-05 15:57:51 +00:00
before do
# since the registry is a global singleton, clean it before using
cli_reg.subcommands.clear
2016-02-05 15:57:51 +00:00
end
2016-02-05 11:40:57 +00:00
it 'is empty' do
cli_reg.subcommands.must_equal({})
2016-02-05 11:40:57 +00:00
end
it 'stores one cli plugin' do
plugin = {
klass: Thor.new,
subcommand_name: 'my_cmd',
usage: 'usage my_cmd',
description: 'desc of my_cmd',
options: { test: 1 }
}
cli_reg.add_subcommand(
2016-02-05 11:40:57 +00:00
plugin[:klass],
plugin[:subcommand_name],
plugin[:usage],
plugin[:description],
plugin[:options]
)
cli_reg.subcommands['my_cmd'].must_equal(plugin)
2016-02-05 11:40:57 +00:00
end
end
end