test/test_command.rb in rubikon-0.5.3 vs test/test_command.rb in rubikon-0.6.0
- old
+ new
@@ -1,9 +1,9 @@
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
-# Copyright (c) 2009-2010, Sebastian Staudt
+# Copyright (c) 2009-2011, Sebastian Staudt
require 'test_parameter'
class TestCommand < Test::Unit::TestCase
@@ -35,43 +35,9 @@
command = Command.new @app, name do end
command.description = description
assert_equal name, command.name
assert_equal description, command.description
end
- end
-
- should 'correctly parse given parameters' do
- command = Command.new @app, :command, [:cmd_arg] do end
- option = Option.new(@app, :test, [:opt_arg])
- command.send(:add_param, option)
- flag = Flag.new(@app, :t)
- command.send(:add_param, flag)
- command.send(:run, *%w{--test arg -t test})
- assert option.active?
- assert flag.active?
- assert_equal %w{test}, command.arguments
- assert_equal 'test', command[0]
- assert_equal 'test', command.cmd_arg
- assert_equal %w{arg}, command.parameters[:test].args
- assert_equal 'arg', command.test[0]
- assert_equal 'arg', command.test.opt_arg
-
- assert_raise UnknownParameterError do
- command.send(:run, *%w{--unknown})
- end
- end
-
- should 'allow parameter aliases' do
- command = Command.new @app, :command do end
- command.send(:add_param, { :t => :test })
- flag1 = Flag.new(@app, :test)
- command.send(:add_param, flag1)
- flag2 = Flag.new(@app, :test2)
- command.send(:add_param, flag2)
- command.send(:add_param, { :t2 => :test2 })
- command.send(:run, *%w{-t --t2})
- assert flag1.send(:active?)
- assert flag2.send(:active?)
end
should 'run the code supplied inside its block' do
block_run = false
command = Command.new @app, :command do