aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/dependencies.rb3
-rw-r--r--activesupport/test/dependencies_test.rb13
2 files changed, 15 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 5db06e0a56..c9071a73d8 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -305,7 +305,8 @@ module ActiveSupport #:nodoc:
require_or_load(path || file_name)
rescue LoadError => load_error
if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1]
- raise LoadError.new(message % file_name).copy_blame!(load_error)
+ load_error.message.replace(message % file_name)
+ load_error.copy_blame!(load_error)
end
raise
end
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb
index f622c6b43f..69829bcda5 100644
--- a/activesupport/test/dependencies_test.rb
+++ b/activesupport/test/dependencies_test.rb
@@ -39,6 +39,19 @@ class DependenciesTest < ActiveSupport::TestCase
with_loading 'autoloading_fixtures', &block
end
+ def test_depend_on_path
+ skip "LoadError#path does not exist" if RUBY_VERSION < '2.0.0'
+
+ expected = assert_raises(LoadError) do
+ Kernel.require 'omgwtfbbq'
+ end
+
+ e = assert_raises(LoadError) do
+ ActiveSupport::Dependencies.depend_on 'omgwtfbbq'
+ end
+ assert_equal expected.path, e.path
+ end
+
def test_tracking_loaded_files
require_dependency 'dependencies/service_one'
require_dependency 'dependencies/service_two'