PageRenderTime 53ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 73 lines | 51 code | 20 blank | 2 comment | 0 complexity | 4009c3db9a83298d1972aae5c672a519 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. # Test facets/buildable.rb
  2. require 'facets/buildable.rb'
  3. require 'test/unit'
  4. class TestBuildable < Test::Unit::TestCase
  5. module M
  6. include Buildable
  7. extend self
  8. def m(n,*m) ; "#{n}{#{m}}"; end
  9. def t(n) ; "#{n}"; end
  10. alias :build :m
  11. end
  12. def test_01
  13. str = M.build do
  14. html do
  15. head do
  16. title "Test"
  17. end
  18. body do
  19. i "Hello"
  20. build! :not
  21. t "Test"
  22. t "Hey"
  23. end
  24. end
  25. end
  26. r = "html{head{title{Test}}body{i{Hello}not{}TestHey}}"
  27. assert_equal( r, M.builder.to_s )
  28. end
  29. end
  30. #
  31. class TestBuildingBlock < Test::Unit::TestCase
  32. module M
  33. extend self
  34. def m(n,*m) ; "#{n}{#{m}}"; end
  35. def t(n) ; "#{n}"; end
  36. end
  37. def test_01
  38. build = BuildingBlock.new(M, :m)
  39. build.html do
  40. head do
  41. title "Test"
  42. end
  43. body do
  44. i "Hello"
  45. build! :not
  46. t "Test"
  47. t "Hey"
  48. end
  49. end
  50. r = "html{head{title{Test}}body{i{Hello}not{}TestHey}}"
  51. assert_equal( r, build.to_s )
  52. end
  53. end