# -*- encoding: utf-8 -*- require 'test/unit' require 'webgen/page' class TestBlock < Test::Unit::TestCase def test_render block = Webgen::Page::Block.new('content', 'some content', {'pipeline' => 'test'}) context = {:processors => {}} assert_raise(RuntimeError) { block.render(context) } context[:processors]['test'] = lambda {|context| context[:content] = context[:content].reverse + context[:block].name } assert_equal('some content'.reverse + 'content', block.render(context)[:content]) end end class TestPage < Test::Unit::TestCase VALID = < {1 => { 'name' => 'other1'}, 2 => { 'name' => 'block7'}}) assert_equal({'key' => 'value'}, d.meta_info) assert_equal('other1', d.blocks[1].name) assert_equal('block7', d.blocks[2].name) end def test_eol_encodings d = Webgen::Page.from_data("---\ntitle: test\r---\r\ncontent") assert_equal({'title' => 'test'}, d.meta_info) assert_equal('content', d.blocks['content'].content) end def test_meta_info_dupped mi = {'key' => 'value'} d = Webgen::Page.from_data("---\ntitle: test\n---\ncontent", mi) assert_equal({'title' => 'test', 'key' => 'value'}, d.meta_info) assert_not_same(mi, d.meta_info) d = Webgen::Page.from_data("content", mi) assert_equal({'key' => 'value'}, d.meta_info) assert_not_same(mi, d.meta_info) end end