test/unit/menu_test.rb in menu_helper-0.1.0 vs test/unit/menu_test.rb in menu_helper-0.2.0

- old
+ new

@@ -2,12 +2,12 @@ class MenuByDefaultTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :home) end def test_should_have_a_name assert_equal 'home', @menu.name end @@ -43,17 +43,17 @@ class MenuTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :home) end def test_should_accept_a_block in_block = false - menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) do |menu| + menu = MenuHelper::Menu.new(@menu_bar, :home) do |menu| in_block = true end assert in_block end @@ -66,16 +66,16 @@ @menu[:class] = 'pretty' assert_equal '<li class="pretty 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 = PluginAWeek::MenuHelper::Menu.last_class - PluginAWeek::MenuHelper::Menu.last_class = 'menubar-end' + @original_last_class = MenuHelper::Menu.last_class + MenuHelper::Menu.last_class = 'menubar-end' assert_equal '<li class="menubar-end"><a href="http://test.host/home"><span>Home</span></a></li>', @menu.html(true) ensure - PluginAWeek::MenuHelper::Menu.last_class = @original_last_class + 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] @@ -88,12 +88,12 @@ ActionController::Routing::Routes.draw do |map| map.home '', :controller => 'home', :action => 'index' end - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :home) end def test_should_build_url_from_named_route expected = {:controller => 'home', :action => 'index', :only_path => false, :use_route => :home} assert_equal expected, @menu.url_options @@ -102,12 +102,12 @@ class MenuWithMatchingControllerTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :home) end def test_should_use_name_as_controller expected = {:controller => 'home', :only_path => false} assert_equal expected, @menu.url_options @@ -116,12 +116,12 @@ class MenuWithoutMatchingNamedRouteOrControllerTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :investors) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :investors) end def test_should_use_request_controller_as_controller_and_name_as_action expected = {:controller => 'contact', :action => 'investors', :only_path => false} assert_equal expected, @menu.url_options @@ -130,38 +130,38 @@ class MenuWithCustomUrlOptionsTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) + @menu_bar = MenuHelper::MenuBar.new(@controller) end def test_should_use_custom_controller_if_specified - menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :privacy_policy, :controller => 'home') + menu = MenuHelper::Menu.new(@menu_bar, :privacy_policy, :controller => 'home') expected = {:controller => 'home', :action => 'privacy_policy', :only_path => false} assert_equal expected, menu.url_options end def test_should_not_use_name_as_action_if_same_as_controller_name - menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :about_us, :controller => 'about_us') + menu = MenuHelper::Menu.new(@menu_bar, :about_us, :controller => 'about_us') expected = {:controller => 'about_us', :only_path => false} assert_equal expected, menu.url_options end def test_should_use_custom_action_if_specified - menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :privacy_policy, :controller => 'home', :action => 'privacy') + menu = MenuHelper::Menu.new(@menu_bar, :privacy_policy, :controller => 'home', :action => 'privacy') expected = {:controller => 'home', :action => 'privacy', :only_path => false} assert_equal expected, menu.url_options end end class MenuWithSpecificUrlTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :search, 'Search', 'http://www.google.com') + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :search, 'Search', 'http://www.google.com') end def test_should_use_exact_url assert_equal 'http://www.google.com', @menu.url_options end @@ -169,12 +169,12 @@ class MenuWithMenubarId < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller, {}, :id => 'menus') - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @menu_bar = MenuHelper::MenuBar.new(@controller, {}, :id => 'menus') + @menu = MenuHelper::Menu.new(@menu_bar, :home) end def test_should_prefix_menu_id_with_menu_bar_id assert_equal 'menus-home', @menu[:id] end @@ -182,12 +182,12 @@ class MenuWithoutContentTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @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 end @@ -195,12 +195,12 @@ class MenuWithCustomContentTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home, 'My Home') + @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 end @@ -208,12 +208,12 @@ class MenuWithoutLinkingTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home, {}, :link => false) + @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 end @@ -221,12 +221,12 @@ class MenuWithoutAutoIdSettingTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller, {:auto_set_ids => false}, :id => 'menus') - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @menu_bar = MenuHelper::MenuBar.new(@controller, {:auto_set_ids => false}, :id => 'menus') + @menu = MenuHelper::Menu.new(@menu_bar, :home) end def test_should_not_set_default_id assert_nil @menu[:id] end @@ -234,12 +234,12 @@ class MenuWhenNotCurrentPageTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :home) end def test_should_not_be_selected assert !@menu.selected? end @@ -251,12 +251,12 @@ class MenuWhenCurrentPageTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :contact) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :contact) end def test_should_be_selected assert @menu.selected? end @@ -269,24 +269,24 @@ @menu[:class] = 'pretty' assert_equal '<li class="pretty 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 = PluginAWeek::MenuHelper::Menu.selected_class - PluginAWeek::MenuHelper::Menu.selected_class = 'menubar-active' + @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 ensure - PluginAWeek::MenuHelper::Menu.selected_class = @original_selected_class + MenuHelper::Menu.selected_class = @original_selected_class end end class MenuWithoutSubmenusTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) + @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 end @@ -294,12 +294,12 @@ class MenuWithSubmenusTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) do |home| + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :home) do |home| home.menu :about_us do |about_us| about_us.menu :who_we_are end end end @@ -322,12 +322,12 @@ class MenuUnselectedWithDetachedActiveSubmenusTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller, :attach_active_submenus => false) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :home) do |home| + @menu_bar = MenuHelper::MenuBar.new(@controller, :attach_active_submenus => false) + @menu = MenuHelper::Menu.new(@menu_bar, :home) do |home| home.menu :about_us end end def test_should_render_a_menu_bar @@ -348,12 +348,12 @@ class MenuSelectedWithDetachedActiveSubmenusTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller, :attach_active_submenus => false) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :contact) do |contact| + @menu_bar = MenuHelper::MenuBar.new(@controller, :attach_active_submenus => false) + @menu = MenuHelper::Menu.new(@menu_bar, :contact) do |contact| contact.menu :investors end end def test_should_not_render_a_menu_bar @@ -375,12 +375,12 @@ class MenuWithSubmenuAsCurrentPageTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :about_us) do |about_us| + @menu_bar = MenuHelper::MenuBar.new(@controller) + @menu = MenuHelper::Menu.new(@menu_bar, :about_us) do |about_us| about_us.menu :contact end end def test_should_be_selected @@ -401,12 +401,12 @@ class MenuWithParentMenuTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @parent_menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :contact, {}, :id => 'contact') + @menu_bar = MenuHelper::MenuBar.new(@controller) + @parent_menu = MenuHelper::Menu.new(@menu_bar, :contact, {}, :id => 'contact') @menu = @parent_menu.menu :investors end def test_should_have_a_parent_menu assert_equal @parent_menu, @menu.parent_menu @@ -424,12 +424,12 @@ ActionController::Routing::Routes.draw do |map| map.contact_investors 'contact/investors', :controller => 'contact', :action => 'investors' map.connect ':controller/:action/:id' end - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @parent_menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :contact) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @parent_menu = MenuHelper::Menu.new(@menu_bar, :contact) @menu = @parent_menu.menu :investors end def test_should_build_url_from_named_route expected = {:controller => 'contact', :action => 'investors', :only_path => false, :use_route => :contact_investors} @@ -439,11 +439,11 @@ class MenuWithParentMenuAndMatchingControllerTest < Test::Unit::TestCase def setup super - @menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller) - @parent_menu = PluginAWeek::MenuHelper::Menu.new(@menu_bar, :contact) + @menu_bar = MenuHelper::MenuBar.new(@controller) + @parent_menu = MenuHelper::Menu.new(@menu_bar, :contact) @menu = @parent_menu.menu :investors end def test_should_use_parent_controller_as_controller expected = {:controller => 'contact', :action => 'investors', :only_path => false}