summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMyron Marston <myron.marston@gmail.com>2010-07-08 08:26:03 -0700
committerwycats <wycats@gmail.com>2010-07-09 14:14:02 -0700
commit5e6b09469afd16719cdc9a0856c6f0da0489f55f (patch)
tree18f8ca0aa0c9137afbfb3fe408762502820146a8
parenteda732430189d638a8a6cfd9e26031b74be228d4 (diff)
downloadbundler-5e6b09469afd16719cdc9a0856c6f0da0489f55f.tar.gz
Raise an appropriate error when a gem is specified using a symbol.
Previously, bundler would raise an error like "Could not find gem 'foo' in any of the gem sources", which was misleading and confusing. This closes #434.
-rw-r--r--lib/bundler/dsl.rb4
-rw-r--r--spec/install/gems/simple_case_spec.rb8
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 9be847d583..e2994e4b26 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -44,6 +44,10 @@ module Bundler
end
def gem(name, *args)
+ if name.is_a?(Symbol)
+ raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.}
+ end
+
options = Hash === args.last ? args.pop : {}
version = args.last || ">= 0"
if group = options[:groups] || options[:group]
diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb
index 77444f2dad..b9dc7d05f7 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -21,6 +21,14 @@ describe "bundle install with gem sources" do
should_be_installed("rack 1.0.0")
end
+ it "raises an appropriate error when gems are specified using symbols" do
+ status = install_gemfile(<<-G, :exit_status => true)
+ source "file://#{gem_repo1}"
+ gem :rack
+ G
+ status.should == 4
+ end
+
it "pulls in dependencies" do
install_gemfile <<-G
source "file://#{gem_repo1}"