From e83ce84ef991f06d15d66dce27f06e01477b617e Mon Sep 17 00:00:00 2001 From: schneems Date: Sat, 24 May 2014 14:28:50 +0200 Subject: print generators on failed generate Let's say we just ran: ``` $ rails g migrate add_click_to_issue_assignment ``` We will get an error that looks like: ``` Could not find generator migrate. ``` This patch adds all existing migrations to the output to make it easier for a developer to find a valid migration. ``` Could not find generator "migrate". Please select a valid generator: Rails: assets controller generator helper integration_test mailer migration model resource scaffold scaffold_controller task ``` It would be nice to do some spelling detection and suggest alternatives, but for now this should help. --- railties/test/generators_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'railties/test') diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index eac28badfe..8d6dbf80c2 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -21,8 +21,10 @@ class GeneratorsTest < Rails::Generators::TestCase end def test_invoke_when_generator_is_not_found - output = capture(:stdout){ Rails::Generators.invoke :unknown } - assert_equal "Could not find generator unknown.\n", output + name = :unknown + output = capture(:stdout){ Rails::Generators.invoke name } + assert_match "Could not find generator '#{name}'", output + assert_match "scaffold", output end def test_help_when_a_generator_with_required_arguments_is_invoked_without_arguments -- cgit v1.2.3