mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #1786 from gazay/3-1-stable-regexp-fix
Fix regexp in generators for right catching error message
This commit is contained in:
@@ -299,9 +299,6 @@ module Rails
|
||||
return
|
||||
rescue LoadError => e
|
||||
raise unless e.message =~ /#{Regexp.escape(path)}$/
|
||||
rescue NameError => e
|
||||
raise unless e.message =~ /Rails::Generator([\s(::)]|$)/
|
||||
warn "[WARNING] Could not load generator #{path.inspect} because it's a Rails 2.x generator, which is not supported anymore. Error: #{e.message}.\n#{e.backtrace.join("\n")}"
|
||||
rescue Exception => e
|
||||
warn "[WARNING] Could not load generator #{path.inspect}. Error: #{e.message}.\n#{e.backtrace.join("\n")}"
|
||||
end
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# Old generator version
|
||||
class WrongGenerator < Rails::Generator::NamedBase
|
||||
end
|
||||
@@ -88,12 +88,6 @@ class GeneratorsTest < Rails::Generators::TestCase
|
||||
assert Rails::Generators.find_by_namespace(:model)
|
||||
end
|
||||
|
||||
def test_find_by_namespace_show_warning_if_generator_cant_be_loaded
|
||||
output = capture(:stderr) { Rails::Generators.find_by_namespace(:wrong) }
|
||||
assert_match(/\[WARNING\] Could not load generator/, output)
|
||||
assert_match(/Rails 2\.x generator/, output)
|
||||
end
|
||||
|
||||
def test_invoke_with_nested_namespaces
|
||||
model_generator = mock('ModelGenerator') do
|
||||
expects(:start).with(["Account"], {})
|
||||
|
||||
Reference in New Issue
Block a user