1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Improved filter test coverage

This commit is contained in:
Norman Clarke 2012-05-22 16:05:48 -03:00
parent 93d68afc07
commit 2c998ad8ef
2 changed files with 32 additions and 4 deletions

View file

@ -155,10 +155,10 @@ RUBY
rendered = Haml::Helpers::find_and_preserve(filter.render_with_options(text, compiler.options), compiler.options[:preserve])
if !options[:ugly]
push_text(rendered.rstrip.gsub("\n", "\n#{' ' * @output_tabs}"))
else
if options[:ugly]
push_text(rendered.rstrip)
else
push_text(rendered.rstrip.gsub("\n", "\n#{' ' * @output_tabs}"))
end
end
end

View file

@ -11,6 +11,18 @@ class FiltersTest < MiniTest::Unit::TestCase
end
end
test "should raise error when attempting to register a defined Tilt filter" do
begin
assert_raises RuntimeError do
2.times do
Haml::Filters.register_tilt_filter "Foo"
end
end
ensure
Haml::Filters.defined.delete "foo"
end
end
test "ERB filter with multiline expressions" do
html = "foobarbaz\n"
haml = %Q{:erb\n <%= "foo" +\n "bar" +\n "baz" %>}
@ -29,7 +41,7 @@ class FiltersTest < MiniTest::Unit::TestCase
test "should be compatible with ugly mode" do
expectation = "foo\n"
assert_equal(expectation, render(":plain\n foo"), :ugly => true)
assert_equal(expectation, render(":plain\n foo", :ugly => true))
end
end
@ -76,3 +88,19 @@ class CSSFilterTest < MiniTest::Unit::TestCase
assert_equal(html, render(haml, :format => :html5))
end
end
class CDATAFilterTest < MiniTest::Unit::TestCase
test "should wrap output in CDATA tag" do
html = "<![CDATA[\n foo\n]]>\n"
haml = ":cdata\n foo"
assert_equal(html, render(haml))
end
end
class EscapedFilterTest < MiniTest::Unit::TestCase
test "should escape ampersands" do
html = "&amp;\n"
haml = ":escaped\n &"
assert_equal(html, render(haml))
end
end