Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

check only needs Environment (not Runtime)

Benefit 1) check doesn't change local file contents via loading Runtime
Benefit 2) Get an actual good output for check returning not-found errors

lock_contents can raise an exception. Should not open file until content is generated without error
More clear about what is being checked for in out.should
Test of 3x check causing error on last run
Multiple calls to check should give the same output
  • Loading branch information...
commit 36878435b5f0be75fc6f2e07cebd7f15aaddadf0 1 parent a388b0e
@kevmoo kevmoo authored
View
4 lib/bundler.rb
@@ -103,6 +103,10 @@ def load
@load ||= Runtime.new(root, definition)
end
+ def environment
+ Bundler::Environment.new(root, definition)
+ end
+
def definition
@definition ||= begin
configure
View
2  lib/bundler/cli.rb
@@ -46,7 +46,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.environment
# Check top level dependencies
missing = env.dependencies.select { |d| env.index.search(d).empty? }
if missing.any?
View
5 lib/bundler/environment.rb
@@ -48,8 +48,9 @@ def specs_for(groups)
# ==== Locking
def write_yml_lock
- File.open("#{root}/Gemfile.lock", 'w') do |f|
- f.puts lock_content
+ contents = lock_content
+ File.open(root.join('Gemfile.lock'), 'w') do |f|
+ f.puts contents
end
end
View
29 spec/other/check_spec.rb
@@ -92,6 +92,34 @@
out.should include("Could not locate Gemfile")
end
+ it "should not crash when called multiple times on a new machine" do
+ gemfile <<-G
+ gem 'rails', '3.0.0.beta3'
+ gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
+ G
+
+ simulate_new_machine
+ bundle :check
+ @err.should == ""
+ bundle :check
+ @err.should == ""
+ bundle :check
+ @err.should == ""
+ end
+
+ it "should return the same result when called multiple times on a new machine" do
+ gemfile <<-G
+ gem 'rails', '3.0.0.beta3'
+ gem 'haml'
+ G
+
+ simulate_new_machine
+ bundle :check
+ last_out = @out
+ bundle :check
+ @out.should == last_out
+ end
+
describe "when locked" do
before :each do
system_gems "rack-1.0.0"
@@ -111,6 +139,7 @@
it "shows what is missing with the current Gemfile if it is not satisfied" do
simulate_new_machine
bundle :check
+ should be_true out.start_with?("The following dependencies are missing")
out.should include("rack (= 1.0")
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.