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:
José Valim
2011-06-20 14:35:30 -07:00
3 changed files with 0 additions and 12 deletions

View File

@@ -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

View File

@@ -1,3 +0,0 @@
# Old generator version
class WrongGenerator < Rails::Generator::NamedBase
end

View File

@@ -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"], {})