test/helper_test.rb in haml-4.0.3 vs test/helper_test.rb in haml-4.0.4

- old
+ new

@@ -401,10 +401,22 @@ def test_capture_with_string_block assert_equal("foo\n", render("= capture { 'foo' }", :action_view)) end + def test_capture_with_non_string_value_reurns_nil + Haml::Helpers.module_eval do + def check_capture_returns_nil(&block) + contents = capture(&block) + + contents << "ERROR" if contents + end + end + + assert_equal("\n", render("= check_capture_returns_nil { 2 }", :action_view)) + end + def test_find_and_preserve_with_block assert_equal("<pre>Foo&#x000A;Bar</pre>\nFoo\nBar\n", render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar")) end @@ -537,9 +549,17 @@ string = "\"><&\u00e9 &nbsp;" assert_equal "&quot;&gt;&lt;&amp;\u00e9 &nbsp;", Haml::Helpers.escape_once(string) assert $stderr.string == "", "html_escape shouldn't generate warnings with UTF-8 strings: #{$stderr.string}" ensure $stderr = old_stderr + end + + def test_escape_once_should_work_on_frozen_strings + begin + Haml::Helpers.escape_once('foo'.freeze) + rescue => e + flunk e.message + end end end