Skip to content

Commit 5130510

Browse files
authored
Merge pull request #646 from Insti/Be_more_helpful_when_generator_can_not_be_found
Be more helpful when generator can not be found
2 parents 70dd104 + 9b6ede9 commit 5130510

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/generator/command_line/generator_optparser.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def validate_exercise
8383

8484
def validate_cases
8585
return true if available_generators.include?(options[:slug])
86-
$stderr.puts "A generator does not currently exist for #{options[:slug]}!"
86+
warning = "A generator does not currently exist for #{options[:slug]}!"
87+
expected_location = "Expecting it to be at: #{Files::GeneratorCases.source_filepath(@paths.track, options[:slug])}"
88+
$stderr.puts [warning, expected_location].join("\n")
8789
false
8890
end
8991
end

test/generator/command_line/generator_optparser_test.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,18 @@ def test_validate_slug
111111
end
112112

113113
def test_validate_missing_generator
114-
args = %w(nonexistent)
114+
args = %w(non-existent)
115115
Files::GeneratorCases.stub :available, [] do
116-
assert_output(nil, /A generator does not currently exist fo/) do
116+
assert_output(nil, /A generator does not currently exist for non-existent/) do
117+
refute GeneratorOptparser.new(args, FixturePaths).options_valid?
118+
end
119+
end
120+
end
121+
122+
def test_missing_generator_tells_you_where_it_looked
123+
args = %w(non-existent)
124+
Files::GeneratorCases.stub :available, [] do
125+
assert_output(nil, %r{exercises/non-existent/\.meta/generator/non_existent_case\.rb}) do
117126
refute GeneratorOptparser.new(args, FixturePaths).options_valid?
118127
end
119128
end

0 commit comments

Comments
 (0)