diff options
author | Andre Arko <andre@arko.net> | 2010-04-17 12:56:15 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2010-04-17 12:56:15 -0700 |
commit | 1183d4af2beed2481c0897381178fbe4302e9c61 (patch) | |
tree | 0f6289a9312af5e689673ecf7b9822408b868f2a /spec/runtime | |
parent | bd3cffbf2693cab48fb1d005948c2186abd59a4d (diff) | |
parent | 41c9dc681335f70aa0bc4d2d02621c85801e1155 (diff) | |
download | bundler-1183d4af2beed2481c0897381178fbe4302e9c61.tar.gz |
Merge in v0.9.21
Diffstat (limited to 'spec/runtime')
-rw-r--r-- | spec/runtime/environment_rb_spec.rb | 119 | ||||
-rw-r--r-- | spec/runtime/load_spec.rb | 39 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 24 |
3 files changed, 135 insertions, 47 deletions
diff --git a/spec/runtime/environment_rb_spec.rb b/spec/runtime/environment_rb_spec.rb index 6b030326..eeb396b8 100644 --- a/spec/runtime/environment_rb_spec.rb +++ b/spec/runtime/environment_rb_spec.rb @@ -109,7 +109,10 @@ describe "environment.rb file" do build_git "bar", :gemspec => false do |s| s.write "lib/bar/version.rb", %{BAR_VERSION = '1.0'} s.write "bar.gemspec", <<-G - require 'lib/bar/version' + lib = File.expand_path('../lib/', __FILE__) + $:.unshift lib unless $:.include?(lib) + require 'bar/version' + Gem::Specification.new do |s| s.name = 'bar' s.version = BAR_VERSION @@ -135,41 +138,91 @@ describe "environment.rb file" do out.should include("bar.gemspec") out.should include("require a relative path") end if RUBY_VERSION >= "1.9" - 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}") + it "evals each gemspec with a binding from the top level" do + ruby <<-RUBY + require 'bundler' + def Bundler.require(path) + raise "LOSE" + end + Bundler.load + RUBY + err.should be_empty + out.should be_empty + end 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") + describe "versioning" do + before :each do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + bundle :lock + should_be_locked + end + + it "loads if current" do + 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 + + it "tells you to install if lock is outdated" do + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack", "1.0" + G + run "puts 'lockfile current'", :lite_runtime => true, :expect_err => true + out.should_not include("lockfile current") + err.should include("Gemfile changed since you last locked.") + err.should include("Please run `bundle lock` to relock.") + end + + it "regenerates if from an old bundler" do + 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 "requests regeneration if it's out of sync" do + old_env = File.read(env_file) + install_gemfile <<-G, :relock => true + source "file://#{gem_repo1}" + gem "activesupport" + G + should_be_locked + + env_file(old_env) + run "puts 'fingerprints synced'", :lite_runtime => true, :expect_err => true + out.should_not include("fingerprints synced") + err.should include("out of date") + err.should include("`bundle install`") + end end + describe "when Bundler is bundled" do + it "doesn't blow up" do + install_gemfile <<-G + gem "bundler", :path => "#{File.expand_path("..", lib)}" + G + bundle :lock + + bundle %|exec ruby -e "require 'bundler'; Bundler.setup"| + err.should == "" + end + end end diff --git a/spec/runtime/load_spec.rb b/spec/runtime/load_spec.rb index 4adf12ce..46ab31e6 100644 --- a/spec/runtime/load_spec.rb +++ b/spec/runtime/load_spec.rb @@ -1,7 +1,6 @@ require File.expand_path('../../spec_helper', __FILE__) describe "Bundler.load" do - before :each do system_gems "rack-1.0.0" # clear memoized method results @@ -52,7 +51,7 @@ describe "Bundler.load" do gem "activesupport", :group => :test G - ruby <<-R + ruby <<-RUBY require "bundler" Bundler.setup :default Bundler.require :default @@ -62,20 +61,45 @@ describe "Bundler.load" do rescue LoadError puts "no activesupport" end - R + RUBY out.split("\n").should == ["1.0.0", "no activesupport"] end end - describe "not hurting brittle rubygems" do + describe "when locked" do before :each do - system_gems "activerecord-2.3.2", "activesupport-2.3.2" + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "activesupport" + G + bundle :lock + end + + it "loads env.rb instead of the runtime" do + ruby <<-RUBY + require 'bundler' + Bundler.load + puts Bundler.instance_eval{ @runtime }.inspect + RUBY + out.should == "nil" end + it "does not invoke setup inside env.rb" do + ruby <<-RUBY + require 'bundler' + Bundler.load + puts $LOAD_PATH.grep(/activesupport/i) + RUBY + + out.should == "" + end + end + + describe "not hurting brittle rubygems" do it "does not inject #source into the generated YAML of the gem specs" do + system_gems "activerecord-2.3.2", "activesupport-2.3.2" gemfile <<-G - source "file://#{gem_repo1}" gem "activerecord" G @@ -85,4 +109,5 @@ describe "Bundler.load" do end end end -end
\ No newline at end of file + +end diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index af248192..9dac7dda 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -145,17 +145,14 @@ describe "Bundler.setup" do gem "rack" G - ruby <<-R + ruby <<-R, :expect_err => true require 'rubygems' require 'bundler' - begin - Bundler.setup - rescue Bundler::BundlerError => e - puts e.message - end + Bundler.setup R - out.should == "rack-1.0 is not installed. Try running `bundle install`." + err.should include("rack-1.0 is cached, but not installed") + err.should include("Try running `bundle install`.") end end @@ -242,4 +239,17 @@ describe "Bundler.setup" do err.should be_empty end + it "doesn't throw a backtrace when gems are missing" do + gemfile <<-G + source "file://#{gem_repo1}" + gem "imaginary" + G + run <<-R, :expect_err => true + Bundler.setup + R + + err.should include("Could not find gem 'imaginary") + err.should include("Try running `bundle install`") + end + end |