Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix check, show, and open commands while locked. Closes #237.

  • Loading branch information...
commit b4958b53485f37bd1f595e7e9e222195ef252273 1 parent b9ed78c
André Arko indirect authored
10 lib/bundler/cli.rb
View
@@ -44,7 +44,7 @@ def initialize(*)
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 @@ def lock
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 @@ def show(gem_name = nil)
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 @@ def remove_lockfiles
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
18 spec/other/check_spec.rb
View
@@ -97,9 +97,9 @@
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 @@
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
16 spec/other/open_spec.rb
View
@@ -22,4 +22,20 @@
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
19 spec/other/show_spec.rb
View
@@ -17,4 +17,21 @@
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
2  spec/spec_helper.rb
View
@@ -14,7 +14,7 @@
$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
Please sign in to comment.
Something went wrong with that request. Please try again.