Sha256: d90dab038b187382c5b3c304981589e408122ce532e90eca342e698022fbb0e6

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8

class Nanoc::Helpers::BreadcrumbsTest < Nanoc::TestCase
  include Nanoc::Helpers::Breadcrumbs

  def test_breadcrumbs_trail_at_root
    @items = Nanoc::Int::IdentifiableCollection.new({})
    item = Nanoc::Int::Item.new('root', {}, '/')
    @items << item
    @item = item

    assert_equal [item], breadcrumbs_trail
  end

  def test_breadcrumbs_trail_with_1_parent
    @items = Nanoc::Int::IdentifiableCollection.new({})
    parent_item = Nanoc::Int::Item.new('parent', {}, '/')
    child_item  = Nanoc::Int::Item.new('child',  {}, '/foo/')
    @items << parent_item
    @items << child_item
    @item = child_item

    assert_equal [parent_item, child_item], breadcrumbs_trail
  end

  def test_breadcrumbs_trail_with_many_parents
    @items = Nanoc::Int::IdentifiableCollection.new({})
    grandparent_item = Nanoc::Int::Item.new('grandparent', {}, '/')
    parent_item      = Nanoc::Int::Item.new('parent',      {}, '/foo/')
    child_item       = Nanoc::Int::Item.new('child',       {}, '/foo/bar/')
    @items << grandparent_item
    @items << parent_item
    @items << child_item
    @item = child_item

    assert_equal [grandparent_item, parent_item, child_item], breadcrumbs_trail
  end

  def test_breadcrumbs_trail_with_nils
    @items = Nanoc::Int::IdentifiableCollection.new({})
    grandparent_item = Nanoc::Int::Item.new('grandparent', {}, '/')
    child_item       = Nanoc::Int::Item.new('child',       {}, '/foo/bar/')
    @items << grandparent_item
    @items << child_item
    @item = child_item

    assert_equal [grandparent_item, nil, child_item], breadcrumbs_trail
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-4.0.0b2 test/helpers/test_breadcrumbs.rb