summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2010-04-02 12:48:29 -0700
committerAndre Arko <andre@arko.net>2010-04-02 12:53:07 -0700
commitb4958b53485f37bd1f595e7e9e222195ef252273 (patch)
treeac8376e9e76cb1402eb5a661d948353d0f633802
parentb9ed78c664966a4f7756d18d67ebaf8bd3e6dc65 (diff)
downloadbundler-b4958b53485f37bd1f595e7e9e222195ef252273.tar.gz
Fix check, show, and open commands while locked. Closes #237.
-rw-r--r--lib/bundler/cli.rb10
-rw-r--r--spec/other/check_spec.rb18
-rw-r--r--spec/other/open_spec.rb16
-rw-r--r--spec/other/show_spec.rb19
-rw-r--r--spec/spec_helper.rb2
5 files changed, 55 insertions, 10 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 7e859dfdc5..9364923b3c 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -44,7 +44,7 @@ module Bundler
desc "check", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
def check
- env = Bundler.load
+ env = Bundler.runtime
# Check top level dependencies
missing = env.dependencies.select { |d| env.index.search(d).empty? }
if missing.any?
@@ -103,8 +103,7 @@ module Bundler
remove_lockfiles
end
- environment = Bundler.load
- environment.lock
+ Bundler.runtime.lock
rescue GemNotFound, VersionConflict => e
Bundler.ui.error(e.message)
Bundler.ui.info "Run `bundle install` to install missing gems"
@@ -126,9 +125,8 @@ module Bundler
if gem_name
Bundler.ui.info locate_gem(gem_name)
else
- environment = Bundler.load
Bundler.ui.info "Gems included by the bundle:"
- environment.specs.sort_by { |s| s.name }.each do |s|
+ Bundler.runtime.specs.sort_by { |s| s.name }.each do |s|
Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})"
end
end
@@ -203,7 +201,7 @@ module Bundler
end
def locate_gem(name)
- spec = Bundler.load.specs.find{|s| s.name == name }
+ spec = Bundler.runtime.specs.find{|s| s.name == name }
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
spec.full_gem_path
end
diff --git a/spec/other/check_spec.rb b/spec/other/check_spec.rb
index 8e92c1f83f..6d20e44401 100644
--- a/spec/other/check_spec.rb
+++ b/spec/other/check_spec.rb
@@ -97,9 +97,9 @@ describe "bundle check" do
system_gems "rack-1.0.0"
gemfile <<-G
source "file://#{gem_repo1}"
- gem "rack"
+ gem "rack", "1.0"
G
- bundle "lock"
+ bundle :lock
end
it "rebuilds .bundle/environment.rb " do
@@ -107,5 +107,19 @@ describe "bundle check" do
bundle :check
bundled_app('.bundle/environment.rb').should exist
end
+
+ it "returns success when the Gemfile is satisfied" do
+ bundle :install
+ bundle :check, :exit_status => true
+ @out.should == "The Gemfile's dependencies are satisfied"
+ @exitstatus.should == 0
+ end
+
+ it "shows what is missing with the current Gemfile if it is not satisfied" do
+ simulate_new_machine
+ bundle :check, :exit_status => true
+ @out.should include("rack (= 1.0.0, runtime)")
+ @exitstatus.should == 7
+ end
end
end
diff --git a/spec/other/open_spec.rb b/spec/other/open_spec.rb
index 8fc4534e9a..59d5eb7b01 100644
--- a/spec/other/open_spec.rb
+++ b/spec/other/open_spec.rb
@@ -22,4 +22,20 @@ describe "bundle open" do
bundle "open missing", :env => {"EDITOR" => "echo editor", "VISUAL" => ''}
out.should match(/could not find gem 'missing'/i)
end
+
+ describe "while locked" do
+ before :each do
+ bundle :lock
+ end
+
+ it "opens the gem with EDITOR if set" do
+ bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => ''}
+ out.should == "editor #{default_bundle_path('gems', 'rails-2.3.2')}"
+ end
+
+ it "complains if gem not in bundle" do
+ bundle "open missing", :env => {"EDITOR" => "echo editor", "VISUAL" => ''}
+ out.should match(/could not find gem 'missing'/i)
+ end
+ end
end
diff --git a/spec/other/show_spec.rb b/spec/other/show_spec.rb
index b69c298f58..548c28bf8a 100644
--- a/spec/other/show_spec.rb
+++ b/spec/other/show_spec.rb
@@ -17,4 +17,21 @@ describe "bundle show" do
bundle "show missing"
out.should =~ /could not find gem 'missing'/i
end
-end
+
+ describe "while locked" do
+ before :each do
+ bundle :lock
+ 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
+ end
+
+ it "complains if gem not in bundle" do
+ bundle "show missing"
+ out.should =~ /could not find gem 'missing'/i
+ end
+ end
+
+end \ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9a3099d169..8c66e1817c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -14,7 +14,7 @@ $debug = false
$show_err = true
Spec::Rubygems.setup
-FileUtils.rm_rf(Spec::Path.gem_repo1)
+Spec::Path.gem_repo1.rmtree
Spec::Runner.configure do |config|
config.include Spec::Builders