2019-06-11 22:24:35 +00:00
|
|
|
require "minitest/autorun"
|
2018-08-17 00:22:28 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
require_relative "../../../../lib/inspec/plugin/v2"
|
2018-08-17 00:22:28 +00:00
|
|
|
|
2019-04-24 00:21:31 +00:00
|
|
|
class CliCommandSuperclassTests < Minitest::Test
|
2018-08-17 00:22:28 +00:00
|
|
|
# you can call Inspec.plugin(2, :cli_command) and get the plugin base class
|
|
|
|
def test_calling_Inspec_dot_plugin_with_cli_returns_the_cli_base_class
|
|
|
|
klass = Inspec.plugin(2, :cli_command)
|
|
|
|
assert_kind_of Class, klass
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_equal "Inspec::Plugin::V2::PluginType::CliCommand", klass.name
|
2018-08-17 00:22:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_plugin_type_base_classes_can_be_accessed_by_name
|
|
|
|
klass = Inspec::Plugin::V2::PluginBase.base_class_for_type(:cli_command)
|
|
|
|
assert_kind_of Class, klass
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_equal "Inspec::Plugin::V2::PluginType::CliCommand", klass.name
|
2018-08-17 00:22:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_plugin_type_registers_an_activation_dsl_method
|
|
|
|
klass = Inspec::Plugin::V2::PluginBase
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_respond_to klass, :cli_command, "Activation method for cli_command"
|
2018-08-17 00:22:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_cli_plugin_type_inherits_from_thor
|
|
|
|
klass = Inspec.plugin(2, :cli_command)
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes klass.ancestors, ::Thor, "Cli Command plugin type should inherit from Thor"
|
2018-08-17 00:22:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-24 00:21:31 +00:00
|
|
|
class CliCommandPluginV2API < Minitest::Test
|
2018-08-17 00:22:28 +00:00
|
|
|
def test_cli_command_api_methods_present
|
|
|
|
# instance methods
|
|
|
|
[
|
|
|
|
:invoke,
|
|
|
|
].each do |method_name|
|
|
|
|
klass = Inspec::Plugin::V2::PluginType::CliCommand
|
|
|
|
assert klass.method_defined?(method_name), "CliCommand api instance method: #{method_name}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|