diff options
author | Andre Arko <andre@arko.net> | 2010-04-01 14:22:35 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2010-04-02 00:46:58 -0700 |
commit | 76c6bb7d627d2a954e8151a54c9c16b893b4cdb5 (patch) | |
tree | 8715f37f37aa373e92fcc91040374e9778362ee4 /spec | |
parent | 4c9a157fd36739c5f21ffeeb93068ca968f26ef0 (diff) | |
download | bundler-76c6bb7d627d2a954e8151a54c9c16b893b4cdb5.tar.gz |
Bundler.setup now loads .bundle/environment.rb if it is current
Diffstat (limited to 'spec')
-rw-r--r-- | spec/other/exec_spec.rb | 1 | ||||
-rw-r--r-- | spec/runtime/environment_rb_spec.rb | 35 | ||||
-rw-r--r-- | spec/support/helpers.rb | 12 |
3 files changed, 47 insertions, 1 deletions
diff --git a/spec/other/exec_spec.rb b/spec/other/exec_spec.rb index 2102598566..3977e3d51f 100644 --- a/spec/other/exec_spec.rb +++ b/spec/other/exec_spec.rb @@ -133,6 +133,7 @@ describe "bundle exec" do it "works when locked" do bundle "lock" should_be_locked + bundle "exec fizz" out.should == "1.0" end diff --git a/spec/runtime/environment_rb_spec.rb b/spec/runtime/environment_rb_spec.rb index f9395f2f3b..8be2415d50 100644 --- a/spec/runtime/environment_rb_spec.rb +++ b/spec/runtime/environment_rb_spec.rb @@ -135,4 +135,39 @@ describe "environment.rb file" do end end + it "get regenerated when out of date" do + system_gems "rack-1.0.0" + install_gemfile %|gem "rack"| + bundle :lock + should_be_locked + + env_file <<-E + # Generated by Bundler 0.8 + puts "noo" + E + + ruby <<-R + require "rubygems" + require "bundler" + Bundler.setup + R + out.should_not include("noo") + env_file.read.should include("Generated by Bundler #{Bundler::VERSION}") + end + + it "gets used in Bundler.setup when up to date" do + system_gems "rack-1.0.0" + install_gemfile %|gem "rack"| + bundle :lock + should_be_locked + + File.open(env_file, 'a'){|f| f.puts "puts 'using environment.rb'" } + ruby <<-R + require "rubygems" + require "bundler" + Bundler.setup + R + out.should include("using environment.rb") + end + end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 4bd42dae02..f69740d4cb 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -79,12 +79,22 @@ module Spec path = bundled_app("Gemfile") path = args.shift if Pathname === args.first str = args.shift || "" - FileUtils.mkdir_p(path.dirname.to_s) + path.dirname.mkpath File.open(path.to_s, 'w') do |f| f.puts str end end + def env_file(*args) + path = bundled_app(".bundle/environment.rb") + if args.empty? + path + else + str = args.shift || "" + File.open(path, 'w'){|f| f.puts str } + end + end + def install_gemfile(*args) gemfile(*args) opts = args.last.is_a?(Hash) ? args.last : {} |