summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2010-07-06 14:48:28 -0700
committerAndre Arko <andre@arko.net>2010-07-06 14:54:50 -0700
commit05222b1f327e95f1b32fd6187855b850eeb9841b (patch)
treeacb8648f14c729c76c8b4f6fc196fef85fcbf884
parent485ec3339d7c44bae222432bf4dab13ac2b0e66e (diff)
downloadbundler-05222b1f327e95f1b32fd6187855b850eeb9841b.tar.gz
Remove old .bundle/environment.rb while locking
Closes #408
-rw-r--r--lib/bundler/environment.rb3
-rw-r--r--spec/install/upgrade_spec.rb26
-rw-r--r--spec/other/open_spec.rb6
3 files changed, 32 insertions, 3 deletions
diff --git a/lib/bundler/environment.rb b/lib/bundler/environment.rb
index 4a6243139e..72ed082f32 100644
--- a/lib/bundler/environment.rb
+++ b/lib/bundler/environment.rb
@@ -29,6 +29,9 @@ module Bundler
end
def lock
+ env_file = root.join('.bundle/environment.rb')
+ env_file.rmtree if env_file.exist?
+
File.open(root.join('Gemfile.lock'), 'w') do |f|
f.puts @definition.to_lock
end
diff --git a/spec/install/upgrade_spec.rb b/spec/install/upgrade_spec.rb
new file mode 100644
index 0000000000..67d8eebf54
--- /dev/null
+++ b/spec/install/upgrade_spec.rb
@@ -0,0 +1,26 @@
+require "spec_helper"
+
+describe "bundle install for the first time with v1.0" do
+ before :each do
+ in_app_root
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ it "removes lockfiles in 0.9 YAML format" do
+ File.open("Gemfile.lock", "w"){|f| YAML.dump({}, f) }
+ bundle :install
+ File.read("Gemfile.lock").should_not =~ /^---/
+ end
+
+ it "removes env.rb if it exists" do
+ bundled_app.join(".bundle").mkdir
+ bundled_app.join(".bundle/environment.rb").open("w"){|f| f.write("raise 'nooo'") }
+ bundle :install
+ bundled_app.join(".bundle/environment.rb").should_not exist
+ end
+
+end
diff --git a/spec/other/open_spec.rb b/spec/other/open_spec.rb
index 79a41fbaaa..d440482140 100644
--- a/spec/other/open_spec.rb
+++ b/spec/other/open_spec.rb
@@ -7,7 +7,7 @@ describe "bundle open" do
gem "rails"
G
end
-
+
it "opens the gem with BUNDLER_EDITOR as highest priority" do
bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor"}
out.should == "bundler_editor #{default_bundle_path('gems', 'rails-2.3.2')}"
@@ -22,12 +22,12 @@ describe "bundle open" do
bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
out.should == "editor #{default_bundle_path('gems', 'rails-2.3.2')}"
end
-
+
it "complains if no EDITOR is set" do
bundle "open rails", :env => {"EDITOR" => "", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
out.should == "To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR"
end
-
+
it "complains if gem not in bundle" do
bundle "open missing", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
out.should match(/could not find gem 'missing'/i)