From 2a9f0630822f60adfb418c34ec9cea30a2a716ed Mon Sep 17 00:00:00 2001 From: Sam Umbach Date: Sat, 3 Dec 2011 13:08:18 -0500 Subject: Test that require and load raise LoadError if file not found --- activesupport/test/dependencies_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 94e7e118ff..3a7922d219 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -305,6 +305,14 @@ class DependenciesTest < Test::Unit::TestCase $:.replace(original_path) end + def test_require_raises_load_error_when_file_not_found + with_loading do + assert_raise(LoadError) { require 'this_file_dont_exist_dude' } + end + ensure + remove_constants(:LoadedConstant) + end + def test_load_returns_true_when_file_found path = File.expand_path("../autoloading_fixtures/load_path", __FILE__) original_path = $:.dup @@ -321,6 +329,14 @@ class DependenciesTest < Test::Unit::TestCase $:.replace(original_path) end + def test_load_raises_load_error_when_file_not_found + with_loading do + assert_raise(LoadError) { load 'this_file_dont_exist_dude.rb' } + end + ensure + remove_constants(:LoadedConstant) + end + def failing_test_access_thru_and_upwards_fails with_autoloading_fixtures do assert ! defined?(ModuleFolder) -- cgit v1.2.3