From d7cfb636367f2f929d07ade9060d35a2cf7ad20b Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 26 Dec 2011 11:31:22 +0100 Subject: Correctly display rack apps with dynamic constraints in RoutesInspector If you used dynamic constraint like that: scope :constraint => MyConstraint.new do mount RackApp => "/foo" end routes were not displayed correctly when using `rake routes`. This commit fixes it. If you want nice display of dynamic constraints in `rake routes` output, please just override to_s method in your constraint's class. --- railties/test/application/route_inspect_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'railties/test/application') diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb index 2ad5ee6c4c..6503251b9f 100644 --- a/railties/test/application/route_inspect_test.rb +++ b/railties/test/application/route_inspect_test.rb @@ -127,5 +127,22 @@ module ApplicationTests output = @inspector.format @set.routes assert_equal [" /foo/:id(.:format) #{RackApp.name} {:id=>/[A-Z]\\d{5}/}"], output end + + def test_rake_routes_shows_route_with_rack_app_nested_with_dynamic_constraints + constraint = Class.new do + def to_s + "( my custom constraint )" + end + end + + @set.draw do + scope :constraint => constraint.new do + mount RackApp => '/foo' + end + end + + output = @inspector.format @set.routes + assert_equal [" /foo #{RackApp.name} {:constraint=>( my custom constraint )}"], output + end end end -- cgit v1.2.3