test/unit/menu_test.rb in menu_helper-0.2.0 vs test/unit/menu_test.rb in menu_helper-0.3.0
- old
+ new
@@ -30,16 +30,20 @@
def test_should_attach_active_submenus
assert @menu.attach_active_submenus?
end
+ def test_should_not_be_selected
+ assert !@menu.selected?
+ end
+
def test_should_not_add_an_html_id
assert_nil @menu[:id]
end
- def test_should_not_be_selected
- assert !@menu.selected?
+ def test_should_set_css_classes
+ assert_equal 'ui-menubar-menu ui-menubar-menu-1', @menu[:class]
end
end
class MenuTest < Test::Unit::TestCase
def setup
@@ -56,31 +60,41 @@
end
assert in_block
end
+ def test_should_allow_menu_class_to_be_customized
+ @original_menu_class = MenuHelper::Menu.menu_class
+ MenuHelper::Menu.menu_class = 'ui-menubar-item'
+
+ @menu = MenuHelper::Menu.new(@menu_bar, :home)
+ assert_equal '<li class="ui-menubar-item ui-menubar-item-1"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html
+ ensure
+ MenuHelper::Menu.menu_class = @original_menu_class
+ end
+
def test_should_include_last_class_in_html_if_last_menu
- assert_equal '<li class="menubar-last"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html(true)
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1 ui-menubar-last"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html(true)
end
def test_should_append_last_class_if_class_attribute_already_exists
@menu[:class] = 'pretty'
- assert_equal '<li class="pretty menubar-last"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html(true)
+ assert_equal '<li class="pretty ui-menubar-last"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html(true)
end
def test_should_allow_last_class_to_be_customized
@original_last_class = MenuHelper::Menu.last_class
- MenuHelper::Menu.last_class = 'menubar-end'
+ MenuHelper::Menu.last_class = 'ui-menubar-end'
- assert_equal '<li class="menubar-end"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html(true)
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1 ui-menubar-end"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html(true)
ensure
MenuHelper::Menu.last_class = @original_last_class
end
def test_should_not_modify_html_options_after_building_html
@menu.html(true)
- assert_nil @menu[:class]
+ assert_equal @menu[:class], 'ui-menubar-menu ui-menubar-menu-1'
end
end
class MenuWithMatchingNamedRouteTest < Test::Unit::TestCase
def setup
@@ -187,11 +201,11 @@
@menu_bar = MenuHelper::MenuBar.new(@controller)
@menu = MenuHelper::Menu.new(@menu_bar, :home)
end
def test_should_use_titleized_version_of_name_as_content
- assert_equal '<li><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html
end
end
class MenuWithCustomContentTest < Test::Unit::TestCase
def setup
@@ -200,11 +214,11 @@
@menu_bar = MenuHelper::MenuBar.new(@controller)
@menu = MenuHelper::Menu.new(@menu_bar, :home, 'My Home')
end
def test_should_use_custom_content_as_content
- assert_equal '<li><a href="http://test.host/home"><span>My Home</span></a></li>', @menu.html
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1"><a href="http://test.host/home"><span>My Home</span></a></li>', @menu.html
end
end
class MenuWithoutLinkingTest < Test::Unit::TestCase
def setup
@@ -213,11 +227,11 @@
@menu_bar = MenuHelper::MenuBar.new(@controller)
@menu = MenuHelper::Menu.new(@menu_bar, :home, {}, :link => false)
end
def test_should_not_linkify_html
- assert_equal '<li><span>Home</span></li>', @menu.html
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1"><span>Home</span></li>', @menu.html
end
end
class MenuWithoutAutoIdSettingTest < Test::Unit::TestCase
def setup
@@ -243,11 +257,11 @@
def test_should_not_be_selected
assert !@menu.selected?
end
def test_should_not_include_selected_css_class_in_html
- assert_equal '<li><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html
end
end
class MenuWhenCurrentPageTest < Test::Unit::TestCase
def setup
@@ -260,22 +274,22 @@
def test_should_be_selected
assert @menu.selected?
end
def test_should_include_selected_css_class_in_html
- assert_equal '<li class="menubar-selected"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1 ui-state-active ui-menubar-selected"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
end
def test_should_append_selected_class_if_class_attribute_already_exists
@menu[:class] = 'pretty'
- assert_equal '<li class="pretty menubar-selected"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
+ assert_equal '<li class="pretty ui-state-active ui-menubar-selected"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
end
def test_should_allow_selected_class_to_be_customized
@original_selected_class = MenuHelper::Menu.selected_class
- MenuHelper::Menu.selected_class = 'menubar-active'
- assert_equal '<li class="menubar-active"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
+ MenuHelper::Menu.selected_class = 'ui-menubar-active'
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1 ui-menubar-active"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
ensure
MenuHelper::Menu.selected_class = @original_selected_class
end
end
@@ -286,11 +300,11 @@
@menu_bar = MenuHelper::MenuBar.new(@controller)
@menu = MenuHelper::Menu.new(@menu_bar, :home)
end
def test_should_not_render_a_menu_bar
- assert_equal '<li><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html
end
end
class MenuWithSubmenusTest < Test::Unit::TestCase
def setup
@@ -304,15 +318,15 @@
end
end
def test_should_render_a_menu_bar
expected = <<-eos
-<li><a href="http://test.host/home"><span>Home</span></a>
- <ul class="menubar menubar-2">
- <li class="menubar-last"><a href="http://test.host/about_us"><span>About Us</span></a>
- <ul class="menubar menubar-3">
- <li class="menubar-last"><a href="http://test.host/about_us/who_we_are"><span>Who We Are</span></a></li>
+<li class="ui-menubar-menu ui-menubar-menu-1"><a href="http://test.host/home"><span>Home</span></a>
+ <ul class="ui-menubar ui-menubar-2">
+ <li class="ui-menubar-menu ui-menubar-menu-2 ui-menubar-last"><a href="http://test.host/about_us"><span>About Us</span></a>
+ <ul class="ui-menubar ui-menubar-3">
+ <li class="ui-menubar-menu ui-menubar-menu-3 ui-menubar-last"><a href="http://test.host/about_us/who_we_are"><span>Who We Are</span></a></li>
</ul>
</li>
</ul>
</li>
eos
@@ -330,13 +344,13 @@
end
end
def test_should_render_a_menu_bar
expected = <<-eos
-<li><a href="http://test.host/home"><span>Home</span></a>
- <ul class="menubar menubar-2">
- <li class="menubar-last"><a href="http://test.host/about_us"><span>About Us</span></a></li>
+<li class="ui-menubar-menu ui-menubar-menu-1"><a href="http://test.host/home"><span>Home</span></a>
+ <ul class="ui-menubar ui-menubar-2">
+ <li class="ui-menubar-menu ui-menubar-menu-2 ui-menubar-last"><a href="http://test.host/about_us"><span>About Us</span></a></li>
</ul>
</li>
eos
assert_equal expected.gsub(/\n\s*/, ''), @menu.html
end
@@ -355,20 +369,20 @@
contact.menu :investors
end
end
def test_should_not_render_a_menu_bar
- assert_equal '<li class="menubar-selected"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
+ assert_equal '<li class="ui-menubar-menu ui-menubar-menu-1 ui-state-active ui-menubar-selected"><a href="http://test.host/contact"><span>Contact</span></a></li>', @menu.html
end
def test_should_store_a_menu_bar_in_content_variable
# Generate the html to store it in the variable
@menu.html
expected = <<-eos
-<ul class="menubar menubar-2">
- <li class="menubar-last"><a href="http://test.host/contact/investors"><span>Investors</span></a></li>
+<ul class="ui-menubar ui-menubar-2">
+ <li class="ui-menubar-menu ui-menubar-menu-2 ui-menubar-last"><a href="http://test.host/contact/investors"><span>Investors</span></a></li>
</ul>
eos
assert_equal expected.gsub(/\n\s*/, ''), @controller.instance_variable_get('@content_for_menu_bar_level_2')
end
end
@@ -387,12 +401,12 @@
assert @menu.selected?
end
def test_should_include_selected_css_class_in_html
expected = <<-eos
-<li class="menubar-selected"><a href="http://test.host/about_us"><span>About Us</span></a>
- <ul class="menubar menubar-2 menubar-selected">
- <li class="menubar-selected menubar-last"><a href="http://test.host/contact"><span>Contact</span></a></li>
+<li class="ui-menubar-menu ui-menubar-menu-1 ui-state-active ui-menubar-selected"><a href="http://test.host/about_us"><span>About Us</span></a>
+ <ul class="ui-menubar ui-menubar-2 ui-state-active ui-menubar-selected">
+ <li class="ui-menubar-menu ui-menubar-menu-2 ui-state-active ui-menubar-selected ui-menubar-last"><a href="http://test.host/contact"><span>Contact</span></a></li>
</ul>
</li>
eos
assert_equal expected.gsub(/\n\s*/, ''), @menu.html
end