Permalink
Browse files

prefix abort messages with executable name to have more explicit errors

  • Loading branch information...
1 parent 24dd618 commit e879210d807f275d1056e08fe9f8e6abf56717a1 @cldwalker committed Mar 18, 2012
Showing with 9 additions and 5 deletions.
  1. +4 −0 lib/boson/runner.rb
  2. +5 −5 test/runner_test.rb
View
@@ -56,6 +56,10 @@ def self.app_name
File.basename($0).split(' ').first
end
+ def self.abort_with(msg)
+ super "#{app_name}: #{msg}"
+ end
+
private
def self.load_options
{force: true}
View
@@ -122,7 +122,7 @@ def default_usage
it 'prints error for invalid command' do
Boson::DefaultCommandsRunner.expects(:abort).
- with("Could not find command \"invalid\"")
+ with("my_command: Could not find command \"invalid\"")
my_command('help invalid')
end
end
@@ -186,7 +186,7 @@ def default_usage
it "calls command with too many args" do
MyRunner.expects(:abort).with <<-STR.chomp
-'medium' was called incorrectly.
+my_command: 'medium' was called incorrectly.
Usage: medium [ARG]
STR
my_command('medium 1 2 3')
@@ -213,12 +213,12 @@ def default_usage
end
it "prints error message for internal public method" do
- MyRunner.expects(:abort).with %[Could not find command "to_s"]
+ MyRunner.expects(:abort).with %[my_command: Could not find command "to_s"]
my_command('to_s').should == ''
end
it "prints error message for nonexistant command" do
- MyRunner.expects(:abort).with %[Could not find command "blarg"]
+ MyRunner.expects(:abort).with %[my_command: Could not find command "blarg"]
my_command('blarg').should == ''
end
@@ -231,7 +231,7 @@ def default_usage
end
it "prints error message for private method" do
- MyRunner.expects(:abort).with %[Could not find command "no_run"]
+ MyRunner.expects(:abort).with %[my_command: Could not find command "no_run"]
my_command('no_run').should == ''
end

0 comments on commit e879210

Please sign in to comment.