Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the application's name in error message if a task is not found #303

Merged
merged 1 commit into from Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rake/task_manager.rb
Expand Up @@ -60,7 +60,8 @@ def [](task_name, scopes=nil)
end

def generate_message_for_undefined_task(task_name)
message = "Don't know how to build task '#{task_name}' (See the list of available tasks with `rake --tasks`)"
message = "Don't know how to build task '#{task_name}' "\
"(See the list of available tasks with `#{Rake.application.name} --tasks`)"
message + generate_did_you_mean_suggestions(task_name)
end

Expand Down
10 changes: 10 additions & 0 deletions test/test_rake_task_manager.rb
Expand Up @@ -28,6 +28,16 @@ def test_index
assert_equal "Don't know how to build task 'bad' (See the list of available tasks with `rake --tasks`)", e.message
end

def test_undefined_task_with_custom_application
Rake.application.init("myrake", nil)

e = assert_raises RuntimeError do
@tm["bad"]
end

assert_equal "Don't know how to build task 'bad' (See the list of available tasks with `myrake --tasks`)", e.message
end

def test_name_lookup
t = @tm.define_task(Rake::Task, :t)
assert_equal t, @tm[:t]
Expand Down