2012-05-01 12:09:15 -03:00
|
|
|
require 'test_helper'
|
2009-03-25 21:42:22 -07:00
|
|
|
|
2014-05-19 20:47:18 -06:00
|
|
|
class UtilTest < Haml::TestCase
|
2009-03-25 21:42:22 -07:00
|
|
|
include Haml::Util
|
|
|
|
|
2009-11-11 14:30:11 -08:00
|
|
|
def test_silence_warnings
|
|
|
|
old_stderr, $stderr = $stderr, StringIO.new
|
|
|
|
warn "Out"
|
|
|
|
assert_equal("Out\n", $stderr.string)
|
|
|
|
silence_warnings {warn "In"}
|
2010-03-29 20:01:16 -07:00
|
|
|
assert_equal("Out\n", $stderr.string)
|
|
|
|
ensure
|
|
|
|
$stderr = old_stderr
|
|
|
|
end
|
|
|
|
|
2013-02-09 00:23:34 +09:00
|
|
|
def test_check_encoding_does_not_destoy_the_given_string
|
2013-05-22 22:33:39 -06:00
|
|
|
string_with_bom = File.read(File.dirname(__FILE__) + '/templates/with_bom.haml', :encoding => Encoding::UTF_8)
|
2013-02-09 00:23:34 +09:00
|
|
|
original = string_with_bom.dup
|
|
|
|
check_encoding(string_with_bom)
|
|
|
|
assert_equal(original, string_with_bom)
|
|
|
|
end
|
2009-03-25 21:42:22 -07:00
|
|
|
end
|