Sha256: de642a2c57c95417e681494f17f1d0f382ce8f90a36338c2ddeeba61e9ba67cb
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
# encoding: utf-8 class Nanoc3::LayoutTest < MiniTest::Unit::TestCase include Nanoc3::TestHelpers def test_initialize # Make sure attributes are cleaned layout = Nanoc3::Layout.new("content", { 'foo' => 'bar' }, '/foo/') assert_equal({ :foo => 'bar' }, layout.attributes) # Make sure identifier is cleaned layout = Nanoc3::Layout.new("content", { 'foo' => 'bar' }, 'foo') assert_equal('/foo/', layout.identifier) end def test_frozen_identifier layout = Nanoc3::Layout.new("foo", {}, '/foo') raised = false begin layout.identifier.chop! rescue => error raised = true assert_match /^can't modify frozen [Ss]tring$/, error.message end assert raised, 'Should have raised when trying to modify a frozen string' end def test_lookup_with_known_attribute # Create layout layout = Nanoc3::Layout.new("content", { 'foo' => 'bar' }, '/foo/') # Check attributes assert_equal('bar', layout[:foo]) end def test_lookup_with_unknown_attribute # Create layout layout = Nanoc3::Layout.new("content", { 'foo' => 'bar' }, '/foo/') # Check attributes assert_equal(nil, layout[:filter]) end def test_dump_and_load layout = Nanoc3::Layout.new( "foobar", { :a => { :b => 123 }}, '/foo/') layout = Marshal.load(Marshal.dump(layout)) assert_equal '/foo/', layout.identifier assert_equal 'foobar', layout.raw_content assert_equal({ :a => { :b => 123 }}, layout.attributes) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc3-3.2.4 | test/base/test_layout.rb |
nanoc3-3.2.3 | test/base/test_layout.rb |