require 'helper' class TestEngine include Slim::Compiler def initialize(template) @template = template compile end def compiled @compiled end end class TestSlimEngine < MiniTest::Unit::TestCase def test_simple_html string = <";_buf << "";_buf << "";_buf << "Simple Test Title";_buf << "";_buf << "";_buf << "";_buf << "

";_buf << "Hello World, meet Slim.";_buf << "

";_buf << "";_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_html_with_empty_lines string = <";_buf << "

";_buf << "Hello World, meet Slim.";_buf << "

";_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_html_with_wraparound_text string = <";_buf << "";_buf << "";_buf << "Simple Test Title";_buf << "";_buf << "";_buf << "";_buf << "

";_buf << "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean gravida porta neque eu tincidunt. Aenean auctor blandit est sed consectetur. Quisque feugiat massa quis diam vestibulum accumsan. Morbi pharetra accumsan augue, in imperdiet sapien viverra non. Suspendisse molestie metus in sapien hendrerit dictum sit amet et leo. Donec accumsan, justo id porttitor luctus, velit erat tincidunt lorem, eu euismod enim nisl quis justo. Aliquam orci odio, ultricies sed ultrices nec, ultrices at mi. Vestibulum vel lacus eu massa mattis venenatis. In porta, quam ut dignissim varius, neque lectus laoreet felis, eget scelerisque odio lacus sed massa. Donec fringilla laoreet mi in dignissim. Curabitur porttitor ullamcorper ultrices. Quisque hendrerit odio ut ipsum blandit quis molestie diam vehicula. Suspendisse diam nibh, sollicitudin id faucibus et, pharetra sit amet massa. Mauris molestie elit id nulla euismod tempus.";_buf << "

";_buf << "";_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_html_with_doctype string = <";_buf << "";_buf << "";_buf << "

";_buf << "Hello World, meet Slim.";_buf << "

";_buf << "";_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_html_with_params string = <";_buf << "";_buf << "";_buf << "Simple Test Title";_buf << "";_buf << "";_buf << "";_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_html_with_params_meta_first string = <";_buf << "";_buf << "";_buf << "";_buf << "Simple Test Title";_buf << "";_buf << "";_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_nested_content string = <";_buf << "

";_buf << "Hello World, meet Slim.";_buf << "

";_buf << "

";_buf << "Hello World, meet Slim again.";_buf << "

";_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_closing_tag_without_content_or_attributes string = <";_buf << "

";_buf << "Hello World, meet Slim.";_buf << "

";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_closing_tag_without_content string = <";_buf << "

";_buf << "Hello World, meet Slim.";_buf << "

";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_text_that_starts_with_tag_name string = <";_buf << "another one bites the dust";_buf << "

";_buf << "

";_buf << "i am iron man";_buf << "

";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_if_code_block string = <";if something;_buf << "

";_buf << "another one bites the dust";_buf << "

";else;_buf << "

";_buf << "i am iron man";_buf << "

";end;_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_consecutive_if_code_blocks string = <";if something;_buf << "

";_buf << "another one bites the dust";_buf << "

";end;if something_else;_buf << "

";_buf << "i am iron man";_buf << "

";end;_buf << "";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_output_code string = <";_buf << Slim.escape_html(hello_world);_buf << "

";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_output_code_with_params string = <";_buf << Slim.escape_html(hello_world(params[:key]));_buf << "

";_buf.join;| assert_equal expected, TestEngine.new(string).compiled end def test_simple_html_with_params_and_content_on_same_line string = <