Skip to content
This repository
Browse code

Test that require and load raise LoadError if file not found

  • Loading branch information...
commit 0531e26daa01d619386bc8df9518a987a1295b87 1 parent 9effced
Sam Umbach authored December 03, 2011

Showing 1 changed file with 16 additions and 0 deletions. Show diff stats Hide diff stats

  1. 16  activesupport/test/dependencies_test.rb
16  activesupport/test/dependencies_test.rb
@@ -306,6 +306,14 @@ def test_require_returns_false_when_file_already_required
306 306
     $:.replace(original_path)
307 307
   end
308 308
 
  309
+  def test_require_raises_load_error_when_file_not_found
  310
+    with_loading do
  311
+      assert_raise(LoadError) { require 'this_file_dont_exist_dude' }
  312
+    end
  313
+  ensure
  314
+    remove_constants(:LoadedConstant)
  315
+  end
  316
+
309 317
   def test_load_returns_true_when_file_found
310 318
     path = File.expand_path("../autoloading_fixtures/load_path", __FILE__)
311 319
     original_path = $:.dup
@@ -322,6 +330,14 @@ def test_load_returns_true_when_file_found
322 330
     $:.replace(original_path)
323 331
   end
324 332
 
  333
+  def test_load_raises_load_error_when_file_not_found
  334
+    with_loading do
  335
+      assert_raise(LoadError) { load 'this_file_dont_exist_dude.rb' }
  336
+    end
  337
+  ensure
  338
+    remove_constants(:LoadedConstant)
  339
+  end
  340
+
325 341
   def failing_test_access_thru_and_upwards_fails
326 342
     with_autoloading_fixtures do
327 343
       assert ! defined?(ModuleFolder)

0 notes on commit 0531e26

Please sign in to comment.
Something went wrong with that request. Please try again.