Module: Minitest

Defined in:
lib/minitest/log_level_plugin.rb,
lib/minitest/environment_plugin.rb

Overview

Add environment option to minitest

Constant Summary collapse

LEVEL_ALIASES =
{
  'debug'   => Logger::DEBUG,
  'info'    => Logger::INFO,
  'warning' => Logger::WARN,
  'error'   => Logger::ERROR,
}

Class Method Summary collapse

Class Method Details

.plugin_environment_init(options) ⇒ Object


27
28
29
30
# File 'lib/minitest/environment_plugin.rb', line 27

def self.plugin_environment_init(options)
  name = options[:environment]
  Cisco::Environment.default_environment_name = name unless name.nil?
end

.plugin_environment_options(opts, options) ⇒ Object


21
22
23
24
25
# File 'lib/minitest/environment_plugin.rb', line 21

def self.plugin_environment_options(opts, options)
  opts.on('-e', '--environment NAME', 'Select environment by name') do |name|
    options[:environment] = name
  end
end

.plugin_log_level_init(options) ⇒ Object


38
39
40
# File 'lib/minitest/log_level_plugin.rb', line 38

def self.plugin_log_level_init(options)
  Cisco::Logger.level = options[:log_level] if options[:log_level]
end

.plugin_log_level_options(opts, options) ⇒ Object


28
29
30
31
32
33
34
35
36
# File 'lib/minitest/log_level_plugin.rb', line 28

def self.plugin_log_level_options(opts, options)
  opts.on(
    '-l', '--log-level LEVEL', LEVEL_ALIASES,
    'Configure logging level for tests',
    "(#{LEVEL_ALIASES.keys.join(', ')})"
  ) do |level|
    options[:log_level] = level
  end
end