@@ -72,19 +72,6 @@ def render_erb(string)
72
72
end
73
73
end
74
74
75
- class RoutedRackApp
76
- attr_reader :routes
77
-
78
- def initialize ( routes , &blk )
79
- @routes = routes
80
- @stack = ActionDispatch ::MiddlewareStack . new ( &blk ) . build ( @routes )
81
- end
82
-
83
- def call ( env )
84
- @stack . call ( env )
85
- end
86
- end
87
-
88
75
class BasicController
89
76
attr_accessor :request , :response
90
77
@@ -102,30 +89,13 @@ def config
102
89
end
103
90
104
91
class ActionDispatch ::IntegrationTest < ActiveSupport ::TestCase
105
- def self . build_app ( routes = nil )
106
- routes ||= ActionDispatch ::Routing ::RouteSet . new . tap { |rs |
107
- rs . draw { }
108
- }
109
- RoutedRackApp . new ( routes ) do |middleware |
110
- middleware . use ActionDispatch ::ShowExceptions , ActionDispatch ::PublicExceptions . new ( "#{ FIXTURE_LOAD_PATH } /public" )
111
- middleware . use ActionDispatch ::DebugExceptions
112
- middleware . use ActionDispatch ::Callbacks
113
- middleware . use ActionDispatch ::Cookies
114
- middleware . use ActionDispatch ::Flash
115
- middleware . use Rack ::Head
116
- yield ( middleware ) if block_given?
117
- end
118
- end
119
-
120
- self . app = build_app
121
-
122
- def with_routing ( &block )
123
- temporary_routes = ActionDispatch ::Routing ::RouteSet . new
124
- old_app , self . class . app = self . class . app , self . class . build_app ( temporary_routes )
125
-
126
- yield temporary_routes
127
- ensure
128
- self . class . app = old_app
92
+ self . app = ActionDispatch ::MiddlewareStack . new do |middleware |
93
+ middleware . use ActionDispatch ::ShowExceptions , ActionDispatch ::PublicExceptions . new ( "#{ FIXTURE_LOAD_PATH } /public" )
94
+ middleware . use ActionDispatch ::DebugExceptions
95
+ middleware . use ActionDispatch ::Callbacks
96
+ middleware . use ActionDispatch ::Cookies
97
+ middleware . use ActionDispatch ::Flash
98
+ middleware . use Rack ::Head
129
99
end
130
100
end
131
101
@@ -147,22 +117,12 @@ class TestCase
147
117
include ActionDispatch ::TestProcess
148
118
149
119
def self . with_routes ( &block )
150
- routes = ActionDispatch ::Routing ::RouteSet . new
151
- routes . draw ( &block )
152
- include Module . new {
153
- define_method ( :setup ) do
154
- super ( )
155
- @routes = routes
156
- @controller . singleton_class . include @routes . url_helpers if @controller
157
- end
158
- }
159
- routes
160
- end
120
+ setup do
121
+ @routes = ActionDispatch ::Routing ::RouteSet . new
122
+ @routes . draw ( &block )
161
123
162
- def with_routes ( &block )
163
- @routes = ActionDispatch ::Routing ::RouteSet . new
164
- @routes . draw ( &block )
165
- @routes
124
+ @controller . singleton_class . include @routes . url_helpers if @controller
125
+ end
166
126
end
167
127
end
168
128
end
0 commit comments