Sha256: f893044487d617efb35549d9645f542998feacdfa55b6ed3350d3ece91e16e2c

Contents?: true

Size: 956 Bytes

Versions: 2

Compression:

Stored size: 956 Bytes

Contents

require 'test_helper'

MODULES_DIR = File.join(File.dirname(__FILE__), 'modules')

class ModulesTest < Test::Unit::TestCase
  def setup
    @shell = RVC::Shell.new
    @shell.cmds = RVC::Namespace.new 'root', @shell, nil
    @shell.load_module_dir MODULES_DIR, @shell.cmds, false
  end

  def teardown
    @shell = nil
  end

  def test_modules
    foo = @shell.cmds.foo
    assert_equal 42, foo.foo

    cmd = @shell.cmds[:foo]
    assert_equal @shell.cmds.foo, cmd

    cmd = @shell.cmds.lookup [:foo]
    assert_equal @shell.cmds.foo.commands[:foo], cmd

    assert_equal 13, foo.bar.bar

    ns = @shell.cmds.lookup [:foo], RVC::Namespace
    assert_equal @shell.cmds[:foo], ns

    ns = @shell.cmds.lookup [:foo, :bar], RVC::Namespace
    assert_equal @shell.cmds.foo.bar, ns

    cmd = @shell.cmds.lookup [:foo, :bar, :bar]
    assert_equal @shell.cmds.foo.bar.commands[:bar], cmd
    assert_equal cmd, @shell.cmds[:foo].bar.commands[:bar]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rvc-1.8.0 test/test_modules.rb
rvc-1.7.0 test/test_modules.rb