From bad30ed46c64593f83ecccf10604c73667e12e2b Mon Sep 17 00:00:00 2001 From: Valentine Valyaeff Date: Tue, 19 May 2015 01:21:20 +0300 Subject: ActionDispatch::Journey::Routes#empty? test cases --- actionpack/lib/action_dispatch/journey/routes.rb | 2 +- actionpack/test/dispatch/routing/route_set_test.rb | 14 ++++++++++++++ actionpack/test/journey/routes_test.rb | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/journey/routes.rb b/actionpack/lib/action_dispatch/journey/routes.rb index f4330a16a7..6325dfa3dd 100644 --- a/actionpack/lib/action_dispatch/journey/routes.rb +++ b/actionpack/lib/action_dispatch/journey/routes.rb @@ -15,7 +15,7 @@ module ActionDispatch @custom_routes = [] @simulator = nil end - + def empty? routes.empty? end diff --git a/actionpack/test/dispatch/routing/route_set_test.rb b/actionpack/test/dispatch/routing/route_set_test.rb index fe52c50336..0c770a4406 100644 --- a/actionpack/test/dispatch/routing/route_set_test.rb +++ b/actionpack/test/dispatch/routing/route_set_test.rb @@ -17,6 +17,16 @@ module ActionDispatch @set = RouteSet.new end + test "not being empty when route is added" do + assert empty? + + draw do + get 'foo', to: SimpleApp.new('foo#index') + end + + refute empty? + end + test "url helpers are added when route is added" do draw do get 'foo', to: SimpleApp.new('foo#index') @@ -136,6 +146,10 @@ module ActionDispatch def url_helpers @set.url_helpers end + + def empty? + @set.empty? + end end end end diff --git a/actionpack/test/journey/routes_test.rb b/actionpack/test/journey/routes_test.rb index b54d961f66..5e3b30dcfe 100644 --- a/actionpack/test/journey/routes_test.rb +++ b/actionpack/test/journey/routes_test.rb @@ -14,9 +14,11 @@ module ActionDispatch requirements = { :hello => /world/ } routes.add_route nil, path, requirements, {:id => nil}, {} + refute routes.empty? assert_equal 1, routes.length routes.clear + assert routes.empty? assert_equal 0, routes.length end -- cgit v1.2.3