Sha256: 20668842358a7631c1925211b4ba9c366b046febdbbdf3295adca15ad274ec36

Contents?: true

Size: 1.54 KB

Versions: 17

Compression:

Stored size: 1.54 KB

Contents

# encoding: utf-8

class Nanoc::Helpers::BreadcrumbsTest < MiniTest::Unit::TestCase

  include Nanoc::TestHelpers

  include Nanoc::Helpers::Breadcrumbs

  def test_breadcrumbs_trail_at_root
    # Mock item
    @item = mock
    @item.stubs(:identifier).returns('/')
    @items = [ @item ]

    # Build trail
    trail = breadcrumbs_trail

    # Check
    assert_equal(
      [ @item ],
      trail
    )
  end

  def test_breadcrumbs_trail_with_1_parent
    # Mock item
    parent = mock
    parent.stubs(:identifier).returns('/')
    @item = mock
    @item.stubs(:identifier).returns('/foo/')
    @items = [ parent, @item ]

    # Build trail
    trail = breadcrumbs_trail

    # Check
    assert_equal(
      [ parent, @item ],
      trail
    )
  end

  def test_breadcrumbs_trail_with_many_parents
    # Mock item
    grandparent = mock
    grandparent.stubs(:identifier).returns('/')
    parent = mock
    parent.stubs(:identifier).returns('/foo/')
    @item = mock
    @item.stubs(:identifier).returns('/foo/bar/')
    @items = [ grandparent, parent, @item ]

    # Build trail
    trail = breadcrumbs_trail

    # Check
    assert_equal(
      [ grandparent, parent, @item ],
      trail
    )
  end

  def test_breadcrumbs_trail_with_nils
    # Mock item
    grandparent = mock
    grandparent.stubs(:identifier).returns('/')
    @item = mock
    @item.stubs(:identifier).returns('/foo/bar/')
    @items = [ grandparent, @item ]

    # Build trail
    trail = breadcrumbs_trail

    # Check
    assert_equal(
      [ grandparent, nil, @item ],
      trail
    )
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
nanoc-3.6.1 test/helpers/test_breadcrumbs.rb
nanoc-3.6.0 test/helpers/test_breadcrumbs.rb
nanoc-3.5.0 test/helpers/test_breadcrumbs.rb
nanoc-3.5.0b2 test/helpers/test_breadcrumbs.rb
nanoc-3.5.0b1 test/helpers/test_breadcrumbs.rb
nanoc-3.4.3 test/helpers/test_breadcrumbs.rb
nanoc-3.4.2 test/helpers/test_breadcrumbs.rb
nanoc-3.4.1 test/helpers/test_breadcrumbs.rb
nanoc-3.4.0 test/helpers/test_breadcrumbs.rb
nanoc-3.3.7 test/helpers/test_breadcrumbs.rb
nanoc-3.3.6 test/helpers/test_breadcrumbs.rb
nanoc-3.3.5 test/helpers/test_breadcrumbs.rb
nanoc-3.3.4 test/helpers/test_breadcrumbs.rb
nanoc-3.3.3 test/helpers/test_breadcrumbs.rb
nanoc-3.3.2 test/helpers/test_breadcrumbs.rb
nanoc-3.3.1 test/helpers/test_breadcrumbs.rb
nanoc-3.3.0 test/helpers/test_breadcrumbs.rb