Skip to content

Commit 67ced2f

Browse files
author
Colby Swandale
authored
Merge pull request #303 from tmatilai/app-name-in-error
Use the application's name in error message if a task is not found
2 parents 9d9b431 + d28957d commit 67ced2f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rake/task_manager.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def [](task_name, scopes=nil)
6060
end
6161

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

test/test_rake_task_manager.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ def test_index
2828
assert_equal "Don't know how to build task 'bad' (See the list of available tasks with `rake --tasks`)", e.message
2929
end
3030

31+
def test_undefined_task_with_custom_application
32+
Rake.application.init("myrake", nil)
33+
34+
e = assert_raises RuntimeError do
35+
@tm["bad"]
36+
end
37+
38+
assert_equal "Don't know how to build task 'bad' (See the list of available tasks with `myrake --tasks`)", e.message
39+
end
40+
3141
def test_name_lookup
3242
t = @tm.define_task(Rake::Task, :t)
3343
assert_equal t, @tm[:t]

0 commit comments

Comments
 (0)