require 'helper' class TestSlimEmbeddedEngines < TestSlim def test_render_with_erb source = %q{ p - text = 'before erb block' erb: Hello from <%= text.upcase %>! Second Line! <% if true %><%= true %><% end %> } assert_html "
Hello from BEFORE ERB BLOCK!\nSecond Line!\ntrue
", source end def test_render_with_markdown # Keep the trailing spaces. source = %q{ markdown: #Header Hello from #{"Markdown!"} #{1+2} * one * two } assert_html "Hello from Markdown!
\n\n3
\n\nHello from Markdown!
\n\n3
\n\nHello from Markdown!
\n\n3
\n\n\nHello
\n", source end def test_render_with_wiki source = %q{ wiki: = head1 == head2 } assert_html "Hi
}, source end def test_render_with_javascript_with_tabs # Keep the trailing space behind "javascript: "! source = "javascript:\n\t$(function() {});\n\talert('hello')\np Hi" assert_html "Hi
", source end def test_render_with_javascript_including_variable # Keep the trailing space behind "javascript: "! source = %q{ - func = "alert('hello');" javascript: $(function() { #{func} }); } assert_html %q||, source end def test_render_with_ruby source = %q{ ruby: variable = 1 + 2 = variable } assert_html '3', source end def test_render_with_scss source = %q{ scss: $color: #f00; body { color: $color; } } assert_html "", source end def test_disabled_embedded_engine source = %{ ruby: Embedded Ruby } assert_runtime_error 'Embedded engine ruby is disabled', source, :enable_engines => %w(javascript) source = %{ ruby: Embedded Ruby } assert_runtime_error 'Embedded engine ruby is disabled', source, :enable_engines => %w(javascript) source = %{ ruby: Embedded Ruby } assert_runtime_error 'Embedded engine ruby is disabled', source, :disable_engines => %w(ruby) end def test_enabled_embedded_engine source = %q{ javascript: $(function() {}); } assert_html '', source, :disable_engines => %w(ruby) source = %q{ javascript: $(function() {}); } assert_html '', source, :enable_engines => %w(javascript) end end