PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/more/test_command.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 69 lines | 37 code | 23 blank | 9 comment | 0 complexity | 1f68c73fc6860298ab276c4afec2916c MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. require 'facets/command'
  2. require 'test/unit'
  3. class TC_Command_Simple < Test::Unit::TestCase
  4. #
  5. # Test simple, single funciton command.
  6. #
  7. class SimpleCommand < CLI::Command
  8. def call
  9. "hello"
  10. end
  11. end
  12. def test_simple
  13. assert_equal("hello", SimpleCommand.start)
  14. end
  15. end
  16. #
  17. # Test dispatching commands (aka Master Commands).
  18. #
  19. class TC_Command_Dispatch < Test::Unit::TestCase
  20. class ComplexCommand < CLI::Command
  21. def sink
  22. "sink"
  23. end
  24. def swim
  25. "swim"
  26. end
  27. end
  28. def test_complex
  29. assert_equal("swim", ComplexCommand.start(['swim']))
  30. end
  31. end
  32. #
  33. # Test subcommand convenience method.
  34. #
  35. class TC_Command_Subcommand < Test::Unit::TestCase
  36. include Console
  37. class SubCommand < CLI::Command
  38. def call ; 'submarine' ; end
  39. end
  40. class ComplexCommand < CLI::Command
  41. subcommand :submariner, SubCommand
  42. end
  43. def test_complex
  44. assert_equal("submarine", ComplexCommand.start(['submariner']))
  45. end
  46. end