mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
replace use of MissingSourceFile with LoadError
This commit is contained in:
parent
bb38df89bf
commit
370bfda55f
3 changed files with 4 additions and 19 deletions
|
@ -169,7 +169,7 @@ module AbstractController
|
|||
module_name = name.sub(/Controller$/, '')
|
||||
module_path = module_name.underscore
|
||||
helper module_path
|
||||
rescue MissingSourceFile => e
|
||||
rescue LoadError => e
|
||||
raise e unless e.is_missing? "helpers/#{module_path}_helper"
|
||||
rescue NameError => e
|
||||
raise e unless e.missing_name? "#{module_name}Helper"
|
||||
|
|
|
@ -1,21 +1,6 @@
|
|||
require 'abstract_unit'
|
||||
require 'active_support/core_ext/load_error'
|
||||
|
||||
class TestMissingSourceFile < ActiveSupport::TestCase
|
||||
def test_with_require
|
||||
assert_raise(MissingSourceFile) { require 'no_this_file_don\'t_exist' }
|
||||
end
|
||||
def test_with_load
|
||||
assert_raise(MissingSourceFile) { load 'nor_does_this_one' }
|
||||
end
|
||||
def test_path
|
||||
begin load 'nor/this/one.rb'
|
||||
rescue MissingSourceFile => e
|
||||
assert_equal 'nor/this/one.rb', e.path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TestLoadError < ActiveSupport::TestCase
|
||||
def test_with_require
|
||||
assert_raise(LoadError) { require 'no_this_file_don\'t_exist' }
|
||||
|
@ -29,4 +14,4 @@ class TestLoadError < ActiveSupport::TestCase
|
|||
assert_equal 'nor/this/one.rb', e.path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ class DependenciesTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_missing_dependency_raises_missing_source_file
|
||||
assert_raise(MissingSourceFile) { require_dependency("missing_service") }
|
||||
assert_raise(LoadError) { require_dependency("missing_service") }
|
||||
end
|
||||
|
||||
def test_dependency_which_raises_exception_isnt_added_to_loaded_set
|
||||
|
@ -576,7 +576,7 @@ class DependenciesTest < ActiveSupport::TestCase
|
|||
|
||||
def test_nested_load_error_isnt_rescued
|
||||
with_loading 'dependencies' do
|
||||
assert_raise(MissingSourceFile) do
|
||||
assert_raise(LoadError) do
|
||||
RequiresNonexistent1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue