test/haml/util_test.rb in haml-edge-3.1.73 vs test/haml/util_test.rb in haml-edge-3.1.74

- old
+ new

@@ -3,10 +3,23 @@ require 'pathname' class UtilTest < Test::Unit::TestCase include Haml::Util + class Dumpable + attr_reader :arr + def initialize; @arr = []; end + def _before_dump; @arr << :before; end + def _after_dump; @arr << :after; end + def _around_dump + @arr << :around_before + yield + @arr << :around_after + end + def _after_load; @arr << :loaded; end + end + def test_scope assert(File.exist?(scope("Rakefile"))) end def test_to_hash @@ -236,9 +249,28 @@ end def assert_version_eq(v1, v2) assert(!version_gt(v1, v2), "Expected #{v1} = #{v2}") assert(!version_gt(v2, v1), "Expected #{v2} = #{v1}") + end + + def test_dump_and_load + obj = Dumpable.new + data = dump(obj) + assert_equal([:before, :around_before, :around_after, :after], obj.arr) + obj2 = load(data) + assert_equal([:before, :around_before, :loaded], obj2.arr) + end + + class FooBar + def foo + Haml::Util.abstract(self) + end + end + + def test_abstract + assert_raise_message(NotImplementedError, + "UtilTest::FooBar must implement #foo") {FooBar.new.foo} end def test_def_static_method klass = Class.new def_static_method(klass, :static_method, [:arg1, :arg2],