inspec/test/unit/plugin/v1/plugin_test.rb

40 lines
961 B
Ruby
Raw Normal View History

2016-02-05 15:57:51 +00:00
# TODO: do not use helper, since all plugins are loaded statically
require "minitest/autorun"
require "mocha/minitest"
2016-02-05 15:57:51 +00:00
require "inspec/plugin/v1/plugin_types/cli"
require "thor"
2016-02-05 11:40:57 +00:00
describe "plugin system" do
describe "with an empty profile" do
2016-02-05 11:40:57 +00:00
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
it "is empty" do
_(cli_reg.subcommands).must_equal({})
2016-02-05 11:40:57 +00:00
end
it "stores one cli plugin" do
2016-02-05 11:40:57 +00:00
plugin = {
klass: Thor.new,
subcommand_name: "my_cmd",
usage: "usage my_cmd",
description: "desc of my_cmd",
options: { test: 1 },
2016-02-05 11:40:57 +00:00
}
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