/vendor/gems/facets-2.4.5/test/more/test_buildable.rb
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
- # Test facets/buildable.rb
- require 'facets/buildable.rb'
- require 'test/unit'
- class TestBuildable < Test::Unit::TestCase
- module M
- include Buildable
- extend self
- def m(n,*m) ; "#{n}{#{m}}"; end
- def t(n) ; "#{n}"; end
- alias :build :m
- end
- def test_01
- str = M.build do
- html do
- head do
- title "Test"
- end
- body do
- i "Hello"
- build! :not
- t "Test"
- t "Hey"
- end
- end
- end
- r = "html{head{title{Test}}body{i{Hello}not{}TestHey}}"
- assert_equal( r, M.builder.to_s )
- end
- end
- #
- class TestBuildingBlock < Test::Unit::TestCase
- module M
- extend self
- def m(n,*m) ; "#{n}{#{m}}"; end
- def t(n) ; "#{n}"; end
- end
- def test_01
- build = BuildingBlock.new(M, :m)
- build.html do
- head do
- title "Test"
- end
- body do
- i "Hello"
- build! :not
- t "Test"
- t "Hey"
- end
- end
- r = "html{head{title{Test}}body{i{Hello}not{}TestHey}}"
- assert_equal( r, build.to_s )
- end
- end