From e9c300abb3846002306534aa562c26e8e261c3ee Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Mon, 19 Jul 2010 15:56:49 -0700 Subject: Remove the call to lock from Runtime#initialize --- lib/bundler/cli.rb | 4 ++++ lib/bundler/runtime.rb | 4 +++- spec/cache/gems_spec.rb | 24 +++++++++++++++++++++++- spec/other/check_spec.rb | 13 +++++++++++++ spec/other/show_spec.rb | 16 ++++++++++++++++ spec/runtime/setup_spec.rb | 14 ++++++++++++++ 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 3a26a3be9d..2b205eed06 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -67,6 +67,7 @@ module Bundler Bundler.ui.warn "Install missing gems with `bundle install`" exit 1 else + Bundler.load.lock Bundler.ui.info "The Gemfile's dependencies are satisfied" end end @@ -161,6 +162,8 @@ module Bundler Calling show with [GEM] will list the exact location of that gem on your machine. D def show(gem_name = nil) + Bundler.load.lock + if gem_name Bundler.ui.info locate_gem(gem_name) else @@ -177,6 +180,7 @@ module Bundler def cache Bundler.load.cache Bundler.load.prune_cache unless options[:no_prune] + Bundler.load.lock rescue GemNotFound => e Bundler.ui.error(e.message) Bundler.ui.warn "Run `bundle install` to install missing gems." diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index a3cbac1cf6..4d952aca2b 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -6,7 +6,6 @@ module Bundler def initialize(*) super - lock end def setup(*groups) @@ -35,6 +34,9 @@ module Bundler load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)} $LOAD_PATH.unshift(*load_paths) end + + lock + self end diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb index 088a34709d..5f31f45cc2 100644 --- a/spec/cache/gems_spec.rb +++ b/spec/cache/gems_spec.rb @@ -49,10 +49,22 @@ describe "bundle cache" do bundle "install --local" should_be_installed("rack 1.0.0") end + + it "creates a lockfile" do + cache_gems "rack-1.0.0" + + gemfile <<-G + gem "rack" + G + + bundle "cache" + + bundled_app("Gemfile.lock").should exist + end end describe "when there are also git sources" do - it "still works" do + before do build_git "foo" system_gems "rack-1.0.0" @@ -63,7 +75,9 @@ describe "bundle cache" do end gem 'rack' G + end + it "still works" do bundle :cache system_gems [] @@ -71,6 +85,14 @@ describe "bundle cache" do should_be_installed("rack 1.0.0", "foo 1.0") end + + it "should not explode if the lockfile is not present" do + FileUtils.rm(bundled_app("Gemfile.lock")) + + bundle :cache + + bundled_app("Gemfile.lock").should exist + end end describe "when previously cached" do diff --git a/spec/other/check_spec.rb b/spec/other/check_spec.rb index 056af50ad6..188351a35a 100644 --- a/spec/other/check_spec.rb +++ b/spec/other/check_spec.rb @@ -12,6 +12,19 @@ describe "bundle check" do out.should == "The Gemfile's dependencies are satisfied" end + it "creates a Gemfile.lock if one did not exist" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rails" + G + + FileUtils.rm("Gemfile.lock") + + bundle "check" + + bundled_app("Gemfile.lock").should exist + end + it "shows what is missing with the current Gemfile if it is not satisfied" do gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/other/show_spec.rb b/spec/other/show_spec.rb index a90a14bee5..352b607f09 100644 --- a/spec/other/show_spec.rb +++ b/spec/other/show_spec.rb @@ -8,6 +8,22 @@ describe "bundle show" do G end + it "creates a Gemfile.lock if one did not exist" do + FileUtils.rm("Gemfile.lock") + + bundle "show" + + bundled_app("Gemfile.lock").should exist + end + + it "creates a Gemfile.lock if one did not exist and we're doing bundle show rails" do + FileUtils.rm("Gemfile.lock") + + bundle "show rails" + + bundled_app("Gemfile.lock").should exist + end + it "prints path if gem exists in bundle" do bundle "show rails" out.should == default_bundle_path('gems', 'rails-2.3.2').to_s diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 62b37c4018..d614412f99 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -62,6 +62,20 @@ describe "Bundler.setup" do File.read(bundled_app("Gemfile.lock")).should == lockfile end + it "makes a Gemfile.lock if setup succeeds" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + lockfile = File.read(bundled_app("Gemfile.lock")) + + FileUtils.rm(bundled_app("Gemfile.lock")) + + run "1" + bundled_app("Gemfile.lock").should exist + end + it "uses BUNDLE_GEMFILE to locate the gemfile if present" do gemfile <<-G source "file://#{gem_repo1}" -- cgit v1.2.1