Skip to content

Commit

Permalink
Unify error message for invalid option.
Browse files Browse the repository at this point in the history
No need to `puts` part of it and `abort` with the rest.
  • Loading branch information
myronmarston committed Oct 1, 2012
1 parent 94fd7a8 commit 45f23ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/rspec/core/option_parser.rb
Expand Up @@ -20,8 +20,7 @@ def parse!(args)
begin
parser(options).parse!(args)
rescue OptionParser::InvalidOption => e
puts e.message
abort "please use --help for documentation on the options available"
abort "#{e.message}\n\nPlease use --help for a listing of valid options"
end

options
Expand Down
9 changes: 7 additions & 2 deletions spec/rspec/core/option_parser_spec.rb
Expand Up @@ -17,8 +17,13 @@ module RSpec::Core

it "proposes you to use --help and returns an error on incorrect argument" do
parser = Parser.new
parser.should_receive(:abort).with(/use --help/)
parser.parse!(%w[--my_very_wrong_argument_ein])
option = "--my_wrong_arg"

parser.should_receive(:abort) do |msg|
expect(msg).to include('use --help', option)
end

parser.parse!([option])
end

describe "--formatter" do
Expand Down

0 comments on commit 45f23ab

Please sign in to comment.