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

/s4t-utils/test/test-util-tests.rb

https://bitbucket.org/redricko/pragprog-scripting
Ruby | 50 lines | 33 code | 10 blank | 7 comment | 0 complexity | d5cebbe5ad82f4bc53d6d4cb60739c04 MD5 | raw file
  1. #---
  2. # Excerpted from "Everyday Scripting in Ruby"
  3. # We make no guarantees that this code is fit for any purpose.
  4. # Visit http://www.pragmaticprogrammer.com/titles/bmsft for more book information.
  5. #---
  6. # This file should be copied into a test ending in 'tests.rb' so that
  7. # the Rakefile knows it's a test.
  8. require "set-standalone-test-paths.rb" unless $started_from_rakefile
  9. require 'test/unit'
  10. require 's4t-utils'
  11. include S4tUtils
  12. class TestUtilTestsNoInclude < Test::Unit::TestCase
  13. def test_test_method_finds_test_directory
  14. assert_equal(["test found me\n"],
  15. IO.readlines(TestUtil.test("test-location-file")))
  16. end
  17. def test_test_data_method_finds_test_data_directory
  18. assert_equal(["test_data found me\n"],
  19. IO.readlines(TestUtil.test_data("test-data-location-file")))
  20. end
  21. def test_script_method_finds_test_data_directory
  22. assert_equal("script found me\n",
  23. `ruby #{TestUtil.script("script-location-file")}`)
  24. end
  25. end
  26. class TestUtilTestsWithInclude < Test::Unit::TestCase
  27. include S4tUtils::TestUtil
  28. def test_test_method_finds_test_directory
  29. assert_equal(["test found me\n"],
  30. IO.readlines(test("test-location-file")))
  31. end
  32. def test_test_data_method_finds_test_data_directory
  33. assert_equal(["test_data found me\n"],
  34. IO.readlines(test_data("test-data-location-file")))
  35. end
  36. def test_script_method_finds_test_data_directory
  37. assert_equal("script found me\n",
  38. `ruby #{script("script-location-file")}`)
  39. end
  40. end