^(Time.now)
^# overview^body
^title -- ^tagline. ^(Time.now.strftime("%d%b%Y").downcase)
EOF assert_equal template.expand(Blog.new), <#{Time.now}
some
again
chris blogs -- a blog by christian neukirchen. 13sep2004
EOF end def test_errors template = Kashmir.new('^foo') assert_raises(NoMethodError, "During template expansion: undefined method `foo' for nil:NilClass") { template.expand(nil) } end def test_output s = "" template = Kashmir.new('^bar') template.expand(TestHelper.new, s) assert_equal "BAR", s a = [] template = Kashmir.new('^bar ^quux') template.expand(TestHelper.new, a) assert_equal ["BAR", " ", "QUUUX"], a end def test_multiple_send template = Kashmir.new("^quux.reverse.to_s") assert_equal template.expand(TestHelper.new), "XUUUQ" template = Kashmir.new("^(quux).reverse") assert_equal template.expand(TestHelper.new), "QUUUX.reverse" end def test_xml_escape template = Kashmir.for_XML <^(Time.now)
^# overview^body
^title -- ^tagline. ^(Time.now.strftime("%d%b%Y").downcase)
EOF elusion = Elusion.new { |e| e.title "chris blogs" e.tagline "a blog by christian neukirchen" e.entries { |f| f.title "head" f.body "some#{Time.now}
some
again
chris blogs -- a blog by christian neukirchen. 13sep2004
EOF end def test_blog_with_elusion_dwim template = Kashmir.new <^(Time.now)
^# overview^body
^title -- ^tagline. ^(Time.now.strftime("%d%b%Y").downcase)
EOF expansion = template.expand { |e| e.title "chris blogs" e.tagline "a blog by christian neukirchen" e.entries { |f| f.title "head" f.body "some#{Time.now}
some
again
chris blogs -- a blog by christian neukirchen. 13sep2004
EOF end end