# -*- coding: utf-8 -*- $LOAD_PATH.unshift File.dirname(__FILE__) require 'helper' class MustacheTest < Test::Unit::TestCase def test_instance_render klass = Class.new(Mustache) klass.template = "Hi {{thing}}!" assert_equal "Hi world!", klass.render(:thing => :world) assert_equal "Nice.", klass.render("{{compliment}}.", :compliment => "Nice") assert_equal <<-end_simple, Simple.new.render(:name => "yo", :in_ca => false) Hello yo You have just won $10000! end_simple end def test_passenger assert_equal <<-end_passenger, Passenger.to_text ServerName example.com DocumentRoot /var/www/example.com RailsEnv production end_passenger end def test_complex_view assert_equal <<-end_complex, ComplexView.render

Colors

end_complex end def test_nested_objects assert_equal <<-end_complex, NestedObjects.render

Colors

end_complex end def test_single_line_sections html = %(

) instance = Mustache.new instance.template = html instance[:no_flash] = true assert_equal %Q'

{{contact}}
{{/contact}}" assert_equal "
Call 1-888-FLOWERS\nAsk for Johnson.
", instance.render end def test_sassy_single_line_sections instance = Mustache.new instance[:full_time] = true instance.template = "\n {{#full_time}}full time{{/full_time}}\n" assert_equal "\n full time\n", instance.render end def test_sassier_single_line_sections instance = Mustache.new instance.template = "\t{{#list}}\r\n\t{{/list}}" assert_equal "", instance.render end def test_padding_before_section instance = Mustache.new instance.template = "\t{{#list}}a{{/list}}" assert_equal "\taa", instance.render(:list => [1, 2]) end def test_padding_before_section_on_eos instance = Mustache.new instance.template = "{{#list}}\n\t{{/list}}" assert_equal "", instance.render(:list => [1, 2]) end def test_two_line_sections html = %(

) instance = Mustache.new instance.template = html instance[:no_flash] = true assert_equal %Q'