Browse files

ruby version check for bundle#cache

  • Loading branch information...
1 parent 07c3e48 commit eb2e9c01e6054563ba31109cd543dca7a6358f35 @hone hone committed Apr 22, 2012
Showing with 57 additions and 0 deletions.
  1. +1 −0 lib/bundler/cli.rb
  2. +56 −0 spec/other/ruby_spec.rb
View
1 lib/bundler/cli.rb
@@ -377,6 +377,7 @@ def outdated(*gems)
method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
def cache
+ Bundler.definition.validate_ruby!
Bundler.definition.resolve_with_cache!
setup_cache_all
Bundler.load.cache
View
56 spec/other/ruby_spec.rb
@@ -372,4 +372,60 @@ def should_be_engine_version_incorrect
end
end
end
+
+ context "bundle cache" do
+ before do
+ gemfile <<-G
+ gem 'rack'
+ G
+
+ system_gems "rack-1.0.0"
+ end
+
+ it "copies the .gem file to vendor/cache when ruby version matches" do
+ gemfile <<-G
+ gem 'rack'
+
+ #{ruby_version_correct}
+ G
+
+ bundle :cache
+ bundled_app("vendor/cache/rack-1.0.0.gem").should exist
+ end
+
+ it "fails if the ruby version doesn't match" do
+ gemfile <<-G
+ gem 'rack'
+
+ #{ruby_version_incorrect}
+ G
+
+ bundle :cache, :exitstatus => true
+ should_be_ruby_version_incorrect
+ end
+
+ it "fails if the engine doesn't match" do
+ gemfile <<-G
+ gem 'rack'
+
+ #{engine_incorrect}
+ G
+
+ bundle :cache, :exitstatus => true
+ should_be_engine_incorrect
+ end
+
+ it "fails if the engine version doesn't match" do
+ simulate_ruby_engine "jruby" do
+ gemfile <<-G
+ gem 'rack'
+
+ #{engine_version_incorrect}
+ G
+
+ bundle :cache, :exitstatus => true
+ should_be_engine_version_incorrect
+ end
+ end
+ end
end

0 comments on commit eb2e9c0

Please sign in to comment.