PageRenderTime 333ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/Ruby/lib/ruby/gems/1.8/gems/rake-0.9.2/test/test_rake_dsl.rb

http://github.com/agross/netopenspace
Ruby | 73 lines | 65 code | 8 blank | 0 comment | 0 complexity | 6c52bc8d59496ee436a188c2dd468da5 MD5 | raw file
Possible License(s): MIT, LGPL-3.0
  1. require File.expand_path('../helper', __FILE__)
  2. class TestRakeDsl < Rake::TestCase
  3. def setup
  4. super
  5. Rake::Task.clear
  6. end
  7. def test_namespace_command
  8. namespace "n" do
  9. task "t"
  10. end
  11. refute_nil Rake::Task["n:t"]
  12. end
  13. def test_namespace_command_with_bad_name
  14. ex = assert_raises(ArgumentError) do
  15. namespace 1 do end
  16. end
  17. assert_match(/string/i, ex.message)
  18. assert_match(/symbol/i, ex.message)
  19. end
  20. def test_namespace_command_with_a_string_like_object
  21. name = Object.new
  22. def name.to_str
  23. "bob"
  24. end
  25. namespace name do
  26. task "t"
  27. end
  28. refute_nil Rake::Task["bob:t"]
  29. end
  30. class Foo
  31. def initialize
  32. task :foo_deprecated_a => "foo_deprecated_b" do
  33. print "a"
  34. end
  35. file "foo_deprecated_b" do
  36. print "b"
  37. end
  38. end
  39. end
  40. def test_deprecated_object_dsl
  41. out, err = capture_io do
  42. Foo.new
  43. Rake.application.invoke_task :foo_deprecated_a
  44. end
  45. assert_equal("ba", out)
  46. assert_match(/deprecated/, err)
  47. assert_match(/Foo\#task/, err)
  48. assert_match(/Foo\#file/, err)
  49. assert_match(/test_rake_dsl\.rb:\d+/, err)
  50. end
  51. def test_deprecated_object_dsl_with_suppressed_warnings
  52. Rake.application.options.ignore_deprecate = true
  53. out, err = capture_io do
  54. Foo.new
  55. Rake.application.invoke_task :foo_deprecated_a
  56. end
  57. assert_equal("ba", out)
  58. refute_match(/deprecated/, err)
  59. refute_match(/Foo\#task/, err)
  60. refute_match(/Foo\#file/, err)
  61. refute_match(/test_rake_dsl\.rb:\d+/, err)
  62. ensure
  63. Rake.application.options.ignore_deprecate = false
  64. end
  65. end