Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better message when the command line arguments are incorrect #688

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rspec/core/option_parser.rb
Expand Up @@ -18,7 +18,11 @@ def parse!(args)
args[args.index("--formatter")] = "--format" args[args.index("--formatter")] = "--format"
end end
options = args.delete('--tty') ? {:tty => true} : {} options = args.delete('--tty') ? {:tty => true} : {}
parser(options).parse!(args) begin
parser(options).parse!(args)
rescue OptionParser::InvalidOption => e
abort(e.message + "\n" + "please use --help for documentation on the options available")
end
options options
end end


Expand Down
6 changes: 6 additions & 0 deletions spec/rspec/core/option_parser_spec.rb
Expand Up @@ -15,6 +15,12 @@ module RSpec::Core
parser.parse!([]) parser.parse!([])
end end


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])
end

describe "--formatter" do describe "--formatter" do
it "is deprecated" do it "is deprecated" do
RSpec.should_receive(:deprecate) RSpec.should_receive(:deprecate)
Expand Down