From 477231ea21b01d14fdc3088346f6da3bf4be8ccb Mon Sep 17 00:00:00 2001 From: Geoff Hubbard Date: Mon, 15 May 2017 15:25:33 +0100 Subject: [PATCH 1/4] Make sure the error message has the slug in it. --- test/generator/command_line/generator_optparser_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/generator/command_line/generator_optparser_test.rb b/test/generator/command_line/generator_optparser_test.rb index 4b84bdcc2a..710cff24ec 100644 --- a/test/generator/command_line/generator_optparser_test.rb +++ b/test/generator/command_line/generator_optparser_test.rb @@ -111,9 +111,9 @@ def test_validate_slug end def test_validate_missing_generator - args = %w(nonexistent) + args = %w(non-existent) Files::GeneratorCases.stub :available, [] do - assert_output(nil, /A generator does not currently exist fo/) do + assert_output(nil, /A generator does not currently exist for non-existent/) do refute GeneratorOptparser.new(args, FixturePaths).options_valid? end end From 0de1529667337a47af8fb9d1aa24adf99ac760a3 Mon Sep 17 00:00:00 2001 From: Geoff Hubbard Date: Mon, 15 May 2017 11:27:54 +0100 Subject: [PATCH 2/4] Add expected file location message. Improve error output by providing information about where it expects to find the generator cases file. --- lib/generator/command_line/generator_optparser.rb | 4 +++- test/generator/command_line/generator_optparser_test.rb | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/generator/command_line/generator_optparser.rb b/lib/generator/command_line/generator_optparser.rb index d52496c177..54fb5a200d 100644 --- a/lib/generator/command_line/generator_optparser.rb +++ b/lib/generator/command_line/generator_optparser.rb @@ -83,7 +83,9 @@ def validate_exercise def validate_cases return true if available_generators.include?(options[:slug]) - $stderr.puts "A generator does not currently exist for #{options[:slug]}!" + error_message = "A generator does not currently exist for #{options[:slug]}!" + expected_locations = "Expecting it to be at: #{Files::GeneratorCases.source_filepath(@paths.track, options[:slug])}" + $stderr.puts [error_message, expected_locations].join("\n") false end end diff --git a/test/generator/command_line/generator_optparser_test.rb b/test/generator/command_line/generator_optparser_test.rb index 710cff24ec..fc7785df69 100644 --- a/test/generator/command_line/generator_optparser_test.rb +++ b/test/generator/command_line/generator_optparser_test.rb @@ -118,5 +118,14 @@ def test_validate_missing_generator end end end + + def test_missing_generator_tells_you_where_it_looked + args = %w(non-existent) + Files::GeneratorCases.stub :available, [] do + assert_output(nil, %r{exercises/non-existent/\.meta/generator/non_existent_case\.rb}) do + refute GeneratorOptparser.new(args, FixturePaths).options_valid? + end + end + end end end From 5de05077e1464bc4bb8f06d8a2cc8dc7f4f177db Mon Sep 17 00:00:00 2001 From: Geoff Hubbard Date: Sun, 21 May 2017 22:28:15 +0100 Subject: [PATCH 3/4] Rename error_message to warning Since we're not actually raising an error, just outputting a warning message to $stderr. --- lib/generator/command_line/generator_optparser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generator/command_line/generator_optparser.rb b/lib/generator/command_line/generator_optparser.rb index 54fb5a200d..364c0a1c94 100644 --- a/lib/generator/command_line/generator_optparser.rb +++ b/lib/generator/command_line/generator_optparser.rb @@ -83,9 +83,9 @@ def validate_exercise def validate_cases return true if available_generators.include?(options[:slug]) - error_message = "A generator does not currently exist for #{options[:slug]}!" + warning = "A generator does not currently exist for #{options[:slug]}!" expected_locations = "Expecting it to be at: #{Files::GeneratorCases.source_filepath(@paths.track, options[:slug])}" - $stderr.puts [error_message, expected_locations].join("\n") + $stderr.puts [warning, expected_locations].join("\n") false end end From 9b6ede998d205f84d41630d924b52fbee46f3e8f Mon Sep 17 00:00:00 2001 From: Geoff Hubbard Date: Sun, 21 May 2017 22:38:45 +0100 Subject: [PATCH 4/4] s/locations/location/ - There is only one location. --- lib/generator/command_line/generator_optparser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generator/command_line/generator_optparser.rb b/lib/generator/command_line/generator_optparser.rb index 364c0a1c94..1fc9571024 100644 --- a/lib/generator/command_line/generator_optparser.rb +++ b/lib/generator/command_line/generator_optparser.rb @@ -84,8 +84,8 @@ def validate_exercise def validate_cases return true if available_generators.include?(options[:slug]) warning = "A generator does not currently exist for #{options[:slug]}!" - expected_locations = "Expecting it to be at: #{Files::GeneratorCases.source_filepath(@paths.track, options[:slug])}" - $stderr.puts [warning, expected_locations].join("\n") + expected_location = "Expecting it to be at: #{Files::GeneratorCases.source_filepath(@paths.track, options[:slug])}" + $stderr.puts [warning, expected_location].join("\n") false end end