Skip to content

Commit

Permalink
Merge pull request #303 from tmatilai/app-name-in-error
Browse files Browse the repository at this point in the history
Use the application's name in error message if a task is not found
colby-swandale authored Jan 31, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9d9b431 + d28957d commit 67ced2f
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rake/task_manager.rb
Original file line number Diff line number Diff line change
@@ -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

10 changes: 10 additions & 0 deletions test/test_rake_task_manager.rb
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 67ced2f

Please sign in to comment.