require 'helper' class TestSlimCodeStructure < TestSlim def test_render_with_conditional source = %q{ div - if show_first? p The first paragraph - else p The second paragraph } assert_html '
The second paragraph
A
B
C
', source end def test_render_with_consecutive_conditionals source = %q{ div - if show_first? true p The first paragraph - if show_first? true p The second paragraph } assert_html 'The first paragraph
The second paragraph
The second paragraph
The first paragraph
42Hello World from @env
', source end def test_render_with_case source = %q{ p - case 42 - when 41 | 41 - when 42 | 42 | is the answer p - case 41 - when 41 | 41 - when 42 | 42 | is the answer p - case 42 when 41 | 41 - when 42 | 42 | is the answer p - case 41 when 41 | 41 - when 42 | 42 | is the answer } assert_html '42 is the answer
41 is the answer
42 is the answer
41 is the answer
', source end def test_render_with_slim_comments source = %q{ p Hello / This is a comment Another comment p World } assert_html 'Hello
World
', source end def test_render_with_yield source = %q{ div == yield :menu } assert_html 'Begin
After
', source end def test_render_with_begin_rescue_exception source = %q{ - begin p Begin - raise 'Boom' p After Boom - rescue => ex p = ex.message p After } assert_html 'Begin
Boom
After
', source end def test_render_with_begin_rescue_ensure source = %q{ - begin p Begin - raise 'Boom' p After Boom - rescue => ex p = ex.message - ensure p Ensure p After } assert_html 'Begin
Boom
Ensure
After
', source end end