#!/usr/bin/env ruby require 'test/unit' require File.dirname(__FILE__) + '/../lib/haml/engine' class EngineTest < Test::Unit::TestCase def render(text, options = {}) Haml::Engine.new(text, options).to_html end def test_empty_render_should_remain_empty assert_equal('', render('')) end def test_stop_eval assert_equal("", render("= 'Hello'", :suppress_eval => true)) end def test_attr_wrapper assert_equal("
\n
\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*')) assert_equal("\n
\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"')) end # This is ugly because Hashes are unordered; we don't always know the order # in which attributes will be returned. # There is probably a better way to do this. def test_attributes_should_render_correctly assert_equal("foo
", render("%p{:class => 1+2} foo").chomp) end def test_nil_should_render_empty_tag assert_equal("Hello
", render('%p Hello').chomp) end def test_long_liner_should_not_print_on_one_line assert_equal("