Sha256: cf8d7c74fac900f674b9b5848a46ef033f1b44936f14fbbdca1ed0539cccb505

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

require 'test/helper'

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')

    error = assert_raises(RuntimeError) do
      layout.identifier.chop!
    end
    assert_equal "can't modify frozen string", error.message
  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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc3-3.1.9 test/base/test_layout.rb
nanoc3-3.1.8 test/base/test_layout.rb
nanoc3-3.2.0a4 test/base/test_layout.rb