@@ -101,7 +101,7 @@ def setup
101
101
end
102
102
103
103
test "it is possible to add a path that should be autoloaded only once" do
104
- File . stub ( :exist ? , true ) do
104
+ File . stub ( :directory ? , true ) do
105
105
@root . add "app" , with : "/app"
106
106
@root [ "app" ] . autoload_once!
107
107
assert_predicate @root [ "app" ] , :autoload_once?
@@ -120,15 +120,15 @@ def setup
120
120
end
121
121
122
122
test "it is possible to add a path without assignment and specify it should be loaded only once" do
123
- File . stub ( :exist ? , true ) do
123
+ File . stub ( :directory ? , true ) do
124
124
@root . add "app" , with : "/app" , autoload_once : true
125
125
assert_predicate @root [ "app" ] , :autoload_once?
126
126
assert_includes @root . autoload_once , "/app"
127
127
end
128
128
end
129
129
130
130
test "it is possible to add multiple paths without assignment and specify it should be loaded only once" do
131
- File . stub ( :exist ? , true ) do
131
+ File . stub ( :directory ? , true ) do
132
132
@root . add "app" , with : [ "/app" , "/app2" ] , autoload_once : true
133
133
assert_predicate @root [ "app" ] , :autoload_once?
134
134
assert_includes @root . autoload_once , "/app"
@@ -137,7 +137,7 @@ def setup
137
137
end
138
138
139
139
test "making a path autoload_once more than once only includes it once in @root.load_once" do
140
- File . stub ( :exist ? , true ) do
140
+ File . stub ( :directory ? , true ) do
141
141
@root [ "app" ] = "/app"
142
142
@root [ "app" ] . autoload_once!
143
143
@root [ "app" ] . autoload_once!
@@ -146,7 +146,7 @@ def setup
146
146
end
147
147
148
148
test "paths added to a load_once path should be added to the autoload_once collection" do
149
- File . stub ( :exist ? , true ) do
149
+ File . stub ( :directory ? , true ) do
150
150
@root [ "app" ] = "/app"
151
151
@root [ "app" ] . autoload_once!
152
152
@root [ "app" ] << "/app2"
@@ -155,7 +155,7 @@ def setup
155
155
end
156
156
157
157
test "it is possible to mark a path as eager loaded" do
158
- File . stub ( :exist ? , true ) do
158
+ File . stub ( :directory ? , true ) do
159
159
@root [ "app" ] = "/app"
160
160
@root [ "app" ] . eager_load!
161
161
assert_predicate @root [ "app" ] , :eager_load?
@@ -174,15 +174,15 @@ def setup
174
174
end
175
175
176
176
test "it is possible to add a path without assignment and mark it as eager" do
177
- File . stub ( :exist ? , true ) do
177
+ File . stub ( :directory ? , true ) do
178
178
@root . add "app" , with : "/app" , eager_load : true
179
179
assert_predicate @root [ "app" ] , :eager_load?
180
180
assert_includes @root . eager_load , "/app"
181
181
end
182
182
end
183
183
184
184
test "it is possible to add multiple paths without assignment and mark them as eager" do
185
- File . stub ( :exist ? , true ) do
185
+ File . stub ( :directory ? , true ) do
186
186
@root . add "app" , with : [ "/app" , "/app2" ] , eager_load : true
187
187
assert_predicate @root [ "app" ] , :eager_load?
188
188
assert_includes @root . eager_load , "/app"
@@ -191,7 +191,7 @@ def setup
191
191
end
192
192
193
193
test "it is possible to create a path without assignment and mark it both as eager and load once" do
194
- File . stub ( :exist ? , true ) do
194
+ File . stub ( :directory ? , true ) do
195
195
@root . add "app" , with : "/app" , eager_load : true , autoload_once : true
196
196
assert_predicate @root [ "app" ] , :eager_load?
197
197
assert_predicate @root [ "app" ] , :autoload_once?
@@ -201,7 +201,7 @@ def setup
201
201
end
202
202
203
203
test "making a path eager more than once only includes it once in @root.eager_paths" do
204
- File . stub ( :exist ? , true ) do
204
+ File . stub ( :directory ? , true ) do
205
205
@root [ "app" ] = "/app"
206
206
@root [ "app" ] . eager_load!
207
207
@root [ "app" ] . eager_load!
@@ -210,7 +210,7 @@ def setup
210
210
end
211
211
212
212
test "paths added to an eager_load path should be added to the eager_load collection" do
213
- File . stub ( :exist ? , true ) do
213
+ File . stub ( :directory ? , true ) do
214
214
@root [ "app" ] = "/app"
215
215
@root [ "app" ] . eager_load!
216
216
@root [ "app" ] << "/app2"
@@ -243,7 +243,7 @@ def setup
243
243
end
244
244
245
245
test "a path can be added to the load path" do
246
- File . stub ( :exist ? , true ) do
246
+ File . stub ( :directory ? , true ) do
247
247
@root [ "app" ] = "app"
248
248
@root [ "app" ] . load_path!
249
249
@root [ "app/models" ] = "app/models"
@@ -252,15 +252,15 @@ def setup
252
252
end
253
253
254
254
test "a path can be added to the load path on creation" do
255
- File . stub ( :exist ? , true ) do
255
+ File . stub ( :directory ? , true ) do
256
256
@root . add "app" , with : "/app" , load_path : true
257
257
assert_predicate @root [ "app" ] , :load_path?
258
258
assert_equal [ "/app" ] , @root . load_paths
259
259
end
260
260
end
261
261
262
262
test "a path can be marked as autoload path" do
263
- File . stub ( :exist ? , true ) do
263
+ File . stub ( :directory ? , true ) do
264
264
@root [ "app" ] = "app"
265
265
@root [ "app" ] . autoload!
266
266
@root [ "app/models" ] = "app/models"
@@ -269,12 +269,32 @@ def setup
269
269
end
270
270
271
271
test "a path can be marked as autoload on creation" do
272
- File . stub ( :exist ? , true ) do
272
+ File . stub ( :directory ? , true ) do
273
273
@root . add "app" , with : "/app" , autoload : true
274
274
assert_predicate @root [ "app" ] , :autoload?
275
275
assert_equal [ "/app" ] , @root . autoload_paths
276
276
end
277
277
end
278
+
279
+ test "load paths does NOT include files" do
280
+ File . stub ( :directory? , false ) do
281
+ @root . add "app/README.md" , autoload_once : true , eager_load : true , autoload : true , load_path : true
282
+ assert_equal [ ] , @root . autoload_once
283
+ assert_equal [ ] , @root . eager_load
284
+ assert_equal [ ] , @root . autoload_paths
285
+ assert_equal [ ] , @root . load_paths
286
+ end
287
+ end
288
+
289
+ test "load paths does include directories" do
290
+ File . stub ( :directory? , true ) do
291
+ @root . add "app/special" , autoload_once : true , eager_load : true , autoload : true , load_path : true
292
+ assert_equal [ "/foo/bar/app/special" ] , @root . autoload_once
293
+ assert_equal [ "/foo/bar/app/special" ] , @root . eager_load
294
+ assert_equal [ "/foo/bar/app/special" ] , @root . autoload_paths
295
+ assert_equal [ "/foo/bar/app/special" ] , @root . load_paths
296
+ end
297
+ end
278
298
end
279
299
280
300
class PathsIntegrationTest < ActiveSupport ::TestCase
0 commit comments