Sha256: 43fb649dbf5b75dce17f611c6b4c20ef5ed0efc57e8a7c1e1ac848eb1cd89aa1

Contents?: true

Size: 1.8 KB

Versions: 6

Compression:

Stored size: 1.8 KB

Contents

# -*- encoding: utf-8 -*-

require './spec/helper'

describe MenuBuilder do

  before :each do
    menu_test = %q{
    <ul id="menu">
      <li><a href="index.html">home</a></li>
      <li><a href="about.html">about</a></li>
      <li><a href="doc/index.html">doc</a></li>
      <li><a href="doc/a.html">doca</a></li>
      <li><a href="doc/b.html">docb</a></li>
      <li><a href="a/b/c1.html">abc1</a></li>
      <li><a href="a/b/c2.html">abc2</a></li>
      <li><a href="/absolute.html">absolute</a></li>
      <li><a href="http://www.truc.com/file.html">file</a></li>
    </ul>}
    @menu_doc = Nokogiri::XML.fragment menu_test
  end

  it "should set the menu for index.html page" do
    builder = MenuBuilder.new(@menu_doc)
    new_menu = builder.build_for_page('index.html')
    new_menu.css("ul#menu a#selected").size.should == 1
    new_menu.css("ul#menu a#selected").first['href'].should == 'index.html'
  end
  
  it "should set the menu for about.html page" do
    builder = MenuBuilder.new(@menu_doc)
    new_menu = builder.build_for_page('about.html')
    new_menu.css("ul#menu a#selected").size.should == 1
    new_menu.css("ul#menu a#selected").first['href'].should == 'about.html'
  end
  
  it "should set the menu for /absolute.html page" do
    builder = MenuBuilder.new(@menu_doc)
    new_menu = builder.build_for_page('/absolute.html')
    new_menu.css("ul#menu a#selected").size.should == 1
    new_menu.css("ul#menu a#selected").first['href'].should == '/absolute.html'
  end
  
  it "should set the menu for http://www.truc.com/file.html page" do
    builder = MenuBuilder.new(@menu_doc)
    new_menu = builder.build_for_page('http://www.truc.com/file.html')
    new_menu.css("ul#menu a#selected").size.should == 1
    new_menu.css("ul#menu a#selected").first['href'].should == 'http://www.truc.com/file.html'
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
genit-2.1 spec/menu_builder_spec.rb
genit-2.0 spec/menu_builder_spec.rb
genit-1.0.1 spec/menu_builder_spec.rb
genit-1.0 spec/menu_builder_spec.rb
genit-0.99 spec/menu_builder_spec.rb
genit-0.9 spec/menu_builder_spec.rb