PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/bundle/ruby/1.8/gems/rake-0.8.7/test/test_invocation_chain.rb

https://bitbucket.org/jstanco/tweetsearch
Ruby | 81 lines | 59 code | 18 blank | 4 comment | 0 complexity | 6c707e7fefa3762e85141482c42e04b9 MD5 | raw file
Possible License(s): ISC, GPL-2.0
  1. #!/usr/bin/env ruby
  2. require 'test/unit'
  3. require 'rake'
  4. require 'test/rake_test_setup'
  5. ######################################################################
  6. class TestAnEmptyInvocationChain < Test::Unit::TestCase
  7. include TestMethods
  8. def setup
  9. @empty = Rake::InvocationChain::EMPTY
  10. end
  11. def test_should_be_able_to_add_members
  12. assert_nothing_raised do
  13. @empty.append("A")
  14. end
  15. end
  16. def test_to_s
  17. assert_equal "TOP", @empty.to_s
  18. end
  19. end
  20. ######################################################################
  21. class TestAnInvocationChainWithOneMember < Test::Unit::TestCase
  22. include TestMethods
  23. def setup
  24. @empty = Rake::InvocationChain::EMPTY
  25. @first_member = "A"
  26. @chain = @empty.append(@first_member)
  27. end
  28. def test_should_report_first_member_as_a_member
  29. assert @chain.member?(@first_member)
  30. end
  31. def test_should_fail_when_adding_original_member
  32. ex = assert_exception RuntimeError do
  33. @chain.append(@first_member)
  34. end
  35. assert_match(/circular +dependency/i, ex.message)
  36. assert_match(/A.*=>.*A/, ex.message)
  37. end
  38. def test_to_s
  39. assert_equal "TOP => A", @chain.to_s
  40. end
  41. end
  42. ######################################################################
  43. class TestAnInvocationChainWithMultipleMember < Test::Unit::TestCase
  44. include TestMethods
  45. def setup
  46. @first_member = "A"
  47. @second_member = "B"
  48. ch = Rake::InvocationChain::EMPTY.append(@first_member)
  49. @chain = ch.append(@second_member)
  50. end
  51. def test_should_report_first_member_as_a_member
  52. assert @chain.member?(@first_member)
  53. end
  54. def test_should_report_second_member_as_a_member
  55. assert @chain.member?(@second_member)
  56. end
  57. def test_should_fail_when_adding_original_member
  58. ex = assert_exception RuntimeError do
  59. @chain.append(@first_member)
  60. end
  61. assert_match(/A.*=>.*B.*=>.*A/, ex.message)
  62. end
  63. end