/vendor/daemon_kit/test/test_amqp_generator.rb

http://github.com/mperham/qanat · Ruby · 48 lines · 27 code · 8 blank · 13 comment · 0 complexity · 9a9cf727173efa1fdbb0b66d561caa32 MD5 · raw file

  1. require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
  2. class TestAmqpGenerator < Test::Unit::TestCase
  3. include RubiGen::GeneratorTestHelper
  4. def setup
  5. bare_setup
  6. end
  7. def teardown
  8. bare_teardown
  9. end
  10. # Some generator-related assertions:
  11. # assert_generated_file(name, &block) # block passed the file contents
  12. # assert_directory_exists(name)
  13. # assert_generated_class(name, &block)
  14. # assert_generated_module(name, &block)
  15. # assert_generated_test_for(name, &block)
  16. # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
  17. # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
  18. #
  19. # Other helper methods are:
  20. # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
  21. # bare_setup - place this in setup method to create the APP_ROOT folder for each test
  22. # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
  23. def test_generator_without_options
  24. name = "myapp"
  25. run_generator('amqp', [name], sources)
  26. assert_directory_exists "config"
  27. assert_directory_exists "config/initializers"
  28. assert_generated_file "config/amqp.yml"
  29. assert_generated_file "config/initializers/myapp.rb"
  30. assert_generated_file "libexec/myapp-daemon.rb"
  31. end
  32. private
  33. def sources
  34. [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
  35. ]
  36. end
  37. def generator_path
  38. "daemon_generators"
  39. end
  40. end