Permalink
Browse files

If an option is invalid, don't fail silently

  • Loading branch information...
1 parent a4a88af commit ffef5a173501ae140b3b3342de747d6158935140 @wycats wycats committed with indirect Apr 2, 2010
Showing with 26 additions and 0 deletions.
  1. +1 −0 lib/bundler.rb
  2. +8 −0 lib/bundler/dsl.rb
  3. +17 −0 spec/install/invalid_spec.rb
View
@@ -42,6 +42,7 @@ class PathError < BundlerError; status_code(13) ; end
class GitError < BundlerError; status_code(11) ; end
class DeprecatedMethod < BundlerError; status_code(12) ; end
class DeprecatedOption < BundlerError; status_code(12) ; end
+ class InvalidOption < BundlerError; status_code(15) ; end
class << self
attr_writer :ui, :bundle_path
View
@@ -98,6 +98,14 @@ def _normalize_hash(opts)
def _normalize_options(name, version, opts)
_normalize_hash(opts)
+ invalid_keys = opts.keys - %w(group git path name branch ref tag require)
+ if invalid_keys.any?
+ plural = invalid_keys.size > 1
+ raise InvalidOption, "You passed #{invalid_keys.join(", ")} " \
+ "#{plural ? 'as options, but they are' : 'as an option, but it is'}" \
+ " invalid"
+ end
+
group = opts.delete("group") || @group
# Normalize git and path options
@@ -0,0 +1,17 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe "bundle install with deprecated features" do
+ before :each do
+ in_app_root
+ end
+
+ it "reports that lib is an invalid option" do
+ gemfile <<-G
+ gem "rack", :lib => "rack"
+ G
+
+ bundle :install
+ out.should =~ /You passed lib as an option, but it is invalid/
+ end
+
+end

0 comments on commit ffef5a1

Please sign in to comment.