test/controller_test.rb in menu_builder-0.3.3 vs test/controller_test.rb in menu_builder-0.4.0
- old
+ new
@@ -5,28 +5,37 @@
@routes = MenuBuilder::Routes
end
end
class BooksController < ApplicationController
- menu_item :home
+ menu_item :books
+ def index ; end
+end
- def index
+class SettingsController < ApplicationController
+ menu_items :settings, :home
+
+ def index ; end
+
+ def notifications
+ menu_item :notification
end
-
- def show
- menu_item :show
+end
+
+class BooksControllerTest < ActionController::TestCase
+ test "assigns the current tab" do
+ get :index
+ assert_equal([:books], assigns(:menu_items))
end
end
-class MenuBuilderTest < ActionController::TestCase
- tests BooksController
-
- test "should assigns the current tab in class level" do
+class SettingsControllerTest < ActionController::TestCase
+ test "ability to assign more than one current tab" do
get :index
- assert_equal(:home, assigns(:menu_item))
+ assert_equal([:settings, :home], assigns(:menu_items))
end
- test "should assigns the current tab in action level" do
- get :show
- assert_equal(:show, assigns(:menu_item))
+ test "that instance level menu_items override class level" do
+ get :notifications
+ assert_equal([:notification], assigns(:menu_items))
end
end
\ No newline at end of file