Module: Avm::Sources::Base::Testing

Defined in:
lib/avm/sources/base/testing.rb

Constant Summary collapse

DEFAULT_TEST_COMMANDS =
{}.freeze
TEST_KEY =
'test'
TEST_COMMAND_KEY =
"#{TEST_KEY}.command"
TEST_COMMANDS_KEY =
"#{TEST_KEY}.commands"

Instance Method Summary collapse

Instance Method Details

#configured_test_commandObject



15
16
17
# File 'lib/avm/sources/base/testing.rb', line 15

def configured_test_command
  read_configuration_as_env_command(TEST_COMMAND_KEY)
end

#configured_test_commandsHash<String, EacRubyUtils::Envs::Command>?

Returns:

  • (Hash<String, EacRubyUtils::Envs::Command>, nil)


20
21
22
# File 'lib/avm/sources/base/testing.rb', line 20

def configured_test_commands
  configured_value_as_test_commands(configuration_entry(TEST_COMMANDS_KEY).value)
end

#configured_value_as_test_commands(value) ⇒ Hash<String, EacRubyUtils::Envs::Command>?

Returns:

  • (Hash<String, EacRubyUtils::Envs::Command>, nil)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/avm/sources/base/testing.rb', line 25

def configured_value_as_test_commands(value)
  return nil if value.nil?

  [::EacRubyUtils::Envs::Command, ::Hash, ::Enumerable].each do |type|
    next unless value.is_a?(type)

    return send(
      "configured_#{type.name.demodulize.variableize}_value_as_test_commands",
      value
    )
  end

  raise "Value for test commands should be a Hash or a Enumerable (Actual: #{value})"
end

#default_test_commandsHash<String, EacRubyUtils::Envs::Command>

Returns:

  • (Hash<String, EacRubyUtils::Envs::Command>)


41
42
43
# File 'lib/avm/sources/base/testing.rb', line 41

def default_test_commands
  DEFAULT_TEST_COMMANDS
end

#test_commandsEnumerable<EacRubyUtils::Envs::Command>

Returns:

  • (Enumerable<EacRubyUtils::Envs::Command>)


46
47
48
49
50
# File 'lib/avm/sources/base/testing.rb', line 46

def test_commands
  configured_test_commands ||
    configured_value_as_test_commands(configured_test_command) ||
    default_test_commands
end