diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 31f86d2ddef14c8a7411d1c74e2c61839c6126d9..fc85b01394a84dbc016b58fa4ed155e55d4cdab2 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -52,11 +52,17 @@ def test_route_generation_allows_passing_non_string_values_to_generated_helper end class MockController - def url_for(options) - options[:protocol] ||= "http" - options[:host] ||= "test.host" + def self.build(helpers) + Class.new do + def url_for(options) + options[:protocol] ||= "http" + options[:host] ||= "test.host" - super(options) + super(options) + end + + include helpers + end end end @@ -250,9 +256,7 @@ def test_optimised_named_route_with_host end def setup_for_named_route - inst = MockController.clone.new - inst.class.send(:include, rs.url_helpers) - inst + MockController.build(rs.url_helpers).new end def test_named_route_without_hash @@ -741,7 +745,7 @@ def setup_named_route_test map.users '/admin/users', :controller => 'admin/users', :action => 'index' end - MockController.clone.new.tap { |inst| inst.class.send(:include, set.url_helpers)} + MockController.build(set.url_helpers).new end def test_named_route_hash_access_method