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
  • Loading branch information
colby-swandale authored Jan 31, 2019
2 parents 9d9b431 + d28957d commit 67ced2f
Show file tree
Hide file tree
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
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
Original file line number Diff line number Diff line change
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

0 comments on commit 67ced2f

Please sign in to comment.