Sha256: b2c6ba954a532c29709e584bf52efe06f402b006059358e521758f9218d98559

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

require File.expand_path('../../helper', __FILE__)

class PageTest < TestCase
  setup do
    @path = fixture('one')
    @project = Project.new(@path)
    Dir.chdir @path
  end

  test "root" do
    @page = Page['/']
    assert @page.index?
    assert @page.root?
  end

  test "breadcrumbs" do
    assert_equal %w(/index.html /about/index.css), Page['/about/index.css'].breadcrumbs.paths
    assert_equal %w(/index.html /about/index.css /about/us.html), Page['/about/us.html'].breadcrumbs.paths
    assert_equal %w(/index.html /css/style.css), Page['/css/style.css'].breadcrumbs.paths
    assert_equal %w(/index.html), Page['/'].breadcrumbs.paths
  end

  test "parent" do
    assert Page['/'].parent.nil?
    assert Page['/css/style.css'].parent.path == '/index.html'
  end

  test "siblings" do
    # Because it has no parent, technically
    page = Page['/about/index.css']
    assert page.siblings.empty?

    page = Page['/hello.html']
    assert_equal %w(/cheers.html /hello.html /hi.html), page.siblings.paths
  end

  test "mimes" do
    assert !Page['/css/style.css'].html?
    assert Page['/'].html?
    assert_equal 'text/css',  Page['/css/style.css'].mime_type
    assert_equal 'text/html', Page['/about/us.html'].mime_type
    assert_equal 'html', Page['/about/us.html'].default_ext
    assert_equal 'css',  Page['/css/style.css'].default_ext
  end
  
  test "no layout" do
    page = Page['/hi.html']
    assert_equal false, page.meta.layout
    assert_equal nil, page.layout
    assert_equal false, page.layout?
    assert_equal page.to_html, page.content
  end

  test "html pages should be intact" do
    page = Page['/hi']
    assert_equal page.markup, page.content
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hydeweb-0.1.9 test/unit/page_test.rb
hydeweb-0.1.8 test/unit/page_test.rb
hydeweb-0.1.7 test/unit/page_test.rb
hydeweb-0.1.6 test/unit/page_test.rb