require 'test/unit' require 'engine/command' require 'models/entity' class TCCommand < Command def initialize(executor) super(executor,"command","command ", "prints the passed to the command") end def execute(params) raise UsageException if params.empty? "#{self.executor} goes #{params}!" end end class CommandTest < Test::Unit::TestCase def setup @char = Entity.new @char.oid = 1 @char.name = 'Hero' end def test_command c = Command.new(Entity.new,"name","usage","description") assert_raises(NoMethodError){c.execute({})} end def test_simple_command c = TCCommand.new(@char) assert_equal("Hero goes boom!",c.execute("boom")) assert_raises(UsageException) { c.execute('') } end end