bundler 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (64) hide show
  1. data/.gitignore +10 -3
  2. data/CHANGELOG.md +31 -0
  3. data/ISSUES.md +16 -1
  4. data/LICENSE +2 -1
  5. data/Rakefile +39 -13
  6. data/bin/bundle +1 -1
  7. data/lib/bundler.rb +7 -19
  8. data/lib/bundler/capistrano.rb +0 -1
  9. data/lib/bundler/cli.rb +10 -6
  10. data/lib/bundler/definition.rb +23 -9
  11. data/lib/bundler/dependency.rb +7 -2
  12. data/lib/bundler/deployment.rb +25 -9
  13. data/lib/bundler/dsl.rb +3 -2
  14. data/lib/bundler/gem_helper.rb +25 -26
  15. data/lib/bundler/installer.rb +1 -0
  16. data/lib/bundler/resolver.rb +27 -14
  17. data/lib/bundler/rubygems_ext.rb +9 -6
  18. data/lib/bundler/runtime.rb +1 -1
  19. data/lib/bundler/setup.rb +1 -0
  20. data/lib/bundler/shared_helpers.rb +11 -4
  21. data/lib/bundler/source.rb +24 -15
  22. data/lib/bundler/ui.rb +11 -1
  23. data/lib/bundler/version.rb +1 -1
  24. data/lib/bundler/vlad.rb +1 -1
  25. data/man/bundle-exec.ronn +13 -0
  26. data/man/bundle-install.ronn +6 -3
  27. data/man/bundle.ronn +4 -1
  28. data/spec/cache/gems_spec.rb +14 -0
  29. data/spec/cache/git_spec.rb +1 -1
  30. data/spec/install/deploy_spec.rb +23 -4
  31. data/spec/install/gems/flex_spec.rb +41 -0
  32. data/spec/install/gems/groups_spec.rb +1 -1
  33. data/spec/install/gems/platform_spec.rb +4 -21
  34. data/spec/install/gems/simple_case_spec.rb +21 -14
  35. data/spec/install/gems/sudo_spec.rb +2 -2
  36. data/spec/install/gems/win32_spec.rb +1 -1
  37. data/spec/install/git_spec.rb +23 -5
  38. data/spec/install/path_spec.rb +31 -7
  39. data/spec/lock/{flex_spec.rb → lockfile_spec.rb} +33 -0
  40. data/spec/other/check_spec.rb +7 -7
  41. data/spec/other/config_spec.rb +2 -2
  42. data/spec/other/exec_spec.rb +6 -6
  43. data/spec/other/ext_spec.rb +2 -2
  44. data/spec/other/gem_helper_spec.rb +18 -6
  45. data/spec/other/help_spec.rb +1 -1
  46. data/spec/other/init_spec.rb +3 -3
  47. data/spec/quality_spec.rb +3 -0
  48. data/spec/resolver/platform_spec.rb +29 -4
  49. data/spec/runtime/load_spec.rb +47 -42
  50. data/spec/runtime/require_spec.rb +1 -1
  51. data/spec/runtime/setup_spec.rb +168 -2
  52. data/spec/spec_helper.rb +2 -1
  53. data/spec/support/builders.rb +18 -10
  54. data/spec/support/helpers.rb +7 -11
  55. data/spec/support/indexes.rb +3 -4
  56. data/spec/support/matchers.rb +1 -1
  57. data/spec/support/path.rb +1 -1
  58. data/spec/support/platforms.rb +5 -1
  59. data/spec/support/sudo.rb +1 -1
  60. data/spec/update/gems_spec.rb +26 -0
  61. data/spec/update/git_spec.rb +25 -2
  62. data/spec/update/source_spec.rb +2 -1
  63. metadata +6 -8
  64. data/spec/runtime/environment_rb_spec.rb +0 -162
@@ -12,37 +12,58 @@ describe "Bundler.load" do
12
12
  end
13
13
  end
14
14
 
15
- it "provides a list of the env dependencies" do
16
- gemfile <<-G
17
- source "file://#{gem_repo1}"
18
- gem "rack"
19
- G
20
-
21
- env = Bundler.load
22
- env.dependencies.should have_dep("rack", ">= 0")
23
- end
15
+ describe "with a gemfile" do
16
+ before(:each) do
17
+ gemfile <<-G
18
+ source "file://#{gem_repo1}"
19
+ gem "rack"
20
+ G
21
+ end
24
22
 
25
- it "provides a list of the resolved gems" do
26
- gemfile <<-G
27
- source "file://#{gem_repo1}"
28
- gem "rack"
29
- G
23
+ it "provides a list of the env dependencies" do
24
+ Bundler.load.dependencies.should have_dep("rack", ">= 0")
25
+ end
30
26
 
31
- env = Bundler.load
32
- env.gems.should have_gem("rack-1.0.0", "bundler-#{Bundler::VERSION}")
33
- end
27
+ it "provides a list of the resolved gems" do
28
+ Bundler.load.gems.should have_gem("rack-1.0.0", "bundler-#{Bundler::VERSION}")
29
+ end
30
+
31
+ it "ignores blank BUNDLE_GEMFILEs" do
32
+ lambda {
33
+ ENV['BUNDLE_GEMFILE'] = ""
34
+ Bundler.load
35
+ }.should_not raise_error(Bundler::GemfileNotFound)
36
+ end
34
37
 
35
- it "raises an exception if the default gemfile is not found" do
36
- lambda {
37
- Bundler.load
38
- }.should raise_error(Bundler::GemfileNotFound, /could not locate gemfile/i)
39
38
  end
40
39
 
41
- it "raises an exception if a specified gemfile is not found" do
42
- lambda {
43
- ENV['BUNDLE_GEMFILE'] = "omg.rb"
44
- Bundler.load
45
- }.should raise_error(Bundler::GemfileNotFound, /omg\.rb/)
40
+ describe "without a gemfile" do
41
+ it "raises an exception if the default gemfile is not found" do
42
+ lambda {
43
+ Bundler.load
44
+ }.should raise_error(Bundler::GemfileNotFound, /could not locate gemfile/i)
45
+ end
46
+
47
+ it "raises an exception if a specified gemfile is not found" do
48
+ lambda {
49
+ ENV['BUNDLE_GEMFILE'] = "omg.rb"
50
+ Bundler.load
51
+ }.should raise_error(Bundler::GemfileNotFound, /omg\.rb/)
52
+ end
53
+
54
+ it "does not find a Gemfile above the testing directory" do
55
+ bundler_gemfile = tmp.join("../Gemfile")
56
+ unless File.exists?(bundler_gemfile)
57
+ FileUtils.touch(bundler_gemfile)
58
+ @remove_bundler_gemfile = true
59
+ end
60
+ begin
61
+ lambda { Bundler.load }.should raise_error(Bundler::GemfileNotFound)
62
+ ensure
63
+ bundler_gemfile.rmtree if @remove_bundler_gemfile
64
+ end
65
+ end
66
+
46
67
  end
47
68
 
48
69
  describe "when called twice" do
@@ -69,22 +90,6 @@ describe "Bundler.load" do
69
90
  end
70
91
  end
71
92
 
72
- # This is obviously not true on 1.9 thanks to the AWEOME! gem prelude :'(
73
- it "does not invoke setup inside env.rb" do
74
- install_gemfile <<-G
75
- source "file://#{gem_repo1}"
76
- gem "activesupport"
77
- G
78
-
79
- ruby <<-RUBY
80
- require 'bundler'
81
- Bundler.load
82
- puts $LOAD_PATH.grep(/activesupport/i)
83
- RUBY
84
-
85
- out.should == ""
86
- end if RUBY_VERSION < "1.9"
87
-
88
93
  describe "not hurting brittle rubygems" do
89
94
  it "does not inject #source into the generated YAML of the gem specs" do
90
95
  system_gems "activerecord-2.3.2", "activesupport-2.3.2"
@@ -225,7 +225,7 @@ describe "Bundler.require with platform specific dependencies" do
225
225
 
226
226
  run "Bundler.require; puts RACK", :expect_err => true
227
227
 
228
- out.should == "1.0.0"
228
+ check out.should == "1.0.0"
229
229
  err.should be_empty
230
230
  end
231
231
  end
@@ -156,6 +156,14 @@ describe "Bundler.setup" do
156
156
  run "require 'yard'"
157
157
  out.should == "bundler-#{Bundler::VERSION}\nyard-1.0"
158
158
  end
159
+
160
+ context "when the ruby stdlib is a substring of Gem.path" do
161
+ it "does not reject the stdlib from $LOAD_PATH" do
162
+ substring = "/" + $LOAD_PATH.find{|p| p =~ /vendor_ruby/ }.split("/")[2]
163
+ run "puts 'worked!'", :env => {"GEM_PATH" => substring}
164
+ out.should == "worked!"
165
+ end
166
+ end
159
167
  end
160
168
  end
161
169
 
@@ -237,14 +245,14 @@ describe "Bundler.setup" do
237
245
  end
238
246
 
239
247
  it "works even when the cache directory has been deleted" do
240
- bundle "install vendor"
248
+ bundle "install --path vendor/bundle"
241
249
  FileUtils.rm_rf vendored_gems('cache')
242
250
  should_be_installed "rack 1.0.0"
243
251
  end
244
252
 
245
253
  it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
246
254
  begin
247
- bundle "install vendor"
255
+ bundle "install --path vendor/bundle"
248
256
 
249
257
  Dir["**/*"].each do |f|
250
258
  File.directory?(f) ?
@@ -409,4 +417,162 @@ describe "Bundler.setup" do
409
417
 
410
418
  out.should == "[]"
411
419
  end
420
+
421
+ describe "with git gems that don't have gemspecs" do
422
+ before :each do
423
+ build_git "no-gemspec", :gemspec => false
424
+
425
+ install_gemfile <<-G
426
+ gem "no-gemspec", "1.0", :git => "#{lib_path('no-gemspec-1.0')}"
427
+ G
428
+ end
429
+
430
+ it "loads the library via a virtual spec" do
431
+ run <<-R
432
+ require 'no-gemspec'
433
+ puts NOGEMSPEC
434
+ R
435
+
436
+ out.should == "1.0"
437
+ end
438
+ end
439
+
440
+ describe "with bundled and system gems" do
441
+ before :each do
442
+ system_gems "rack-1.0.0"
443
+
444
+ install_gemfile <<-G
445
+ source "file://#{gem_repo1}"
446
+
447
+ gem "activesupport", "2.3.5"
448
+ G
449
+ end
450
+
451
+ it "does not pull in system gems" do
452
+ run <<-R
453
+ require 'rubygems'
454
+
455
+ begin;
456
+ require 'rack'
457
+ rescue LoadError
458
+ puts 'WIN'
459
+ end
460
+ R
461
+
462
+ out.should == "WIN"
463
+ end
464
+
465
+ it "provides a gem method" do
466
+ run <<-R
467
+ gem 'activesupport'
468
+ require 'activesupport'
469
+ puts ACTIVESUPPORT
470
+ R
471
+
472
+ out.should == "2.3.5"
473
+ end
474
+
475
+ it "raises an exception if gem is used to invoke a system gem not in the bundle" do
476
+ run <<-R
477
+ begin
478
+ gem 'rack'
479
+ rescue LoadError => e
480
+ puts e.message
481
+ end
482
+ R
483
+
484
+ out.should == "rack is not part of the bundle. Add it to Gemfile."
485
+ end
486
+
487
+ it "sets GEM_HOME appropriately" do
488
+ run "puts ENV['GEM_HOME']"
489
+ out.should == default_bundle_path.to_s
490
+ end
491
+ end
492
+
493
+ describe "with system gems in the bundle" do
494
+ before :each do
495
+ system_gems "rack-1.0.0"
496
+
497
+ install_gemfile <<-G
498
+ source "file://#{gem_repo1}"
499
+ gem "rack", "1.0.0"
500
+ gem "activesupport", "2.3.5"
501
+ G
502
+ end
503
+
504
+ it "sets GEM_PATH appropriately" do
505
+ run "puts Gem.path"
506
+ paths = out.split("\n")
507
+ paths.should include(system_gem_path.to_s)
508
+ paths.should include(default_bundle_path.to_s)
509
+ end
510
+ end
511
+
512
+ describe "with a gemspec that requires other files" do
513
+ before :each do
514
+ build_git "bar", :gemspec => false do |s|
515
+ s.write "lib/bar/version.rb", %{BAR_VERSION = '1.0'}
516
+ s.write "bar.gemspec", <<-G
517
+ lib = File.expand_path('../lib/', __FILE__)
518
+ $:.unshift lib unless $:.include?(lib)
519
+ require 'bar/version'
520
+
521
+ Gem::Specification.new do |s|
522
+ s.name = 'bar'
523
+ s.version = BAR_VERSION
524
+ s.summary = 'Bar'
525
+ s.files = Dir["lib/**/*.rb"]
526
+ end
527
+ G
528
+ end
529
+
530
+ gemfile <<-G
531
+ gem "bar", :git => "#{lib_path('bar-1.0')}"
532
+ G
533
+ end
534
+
535
+ it "evals each gemspec in the context of its parent directory" do
536
+ bundle :install
537
+ run "require 'bar'; puts BAR"
538
+ out.should == "1.0"
539
+ end
540
+
541
+ it "error intelligently if the gemspec has a LoadError" do
542
+ update_git "bar", :gemspec => false do |s|
543
+ s.write "bar.gemspec", "require 'foobarbaz'"
544
+ end
545
+ bundle :install
546
+ out.should include("was a LoadError while evaluating bar.gemspec")
547
+ out.should include("foobarbaz")
548
+ out.should include("bar.gemspec:1")
549
+ out.should include("try to require a relative path") if RUBY_VERSION >= "1.9.0"
550
+ end
551
+
552
+ it "evals each gemspec with a binding from the top level" do
553
+ bundle "install"
554
+
555
+ ruby <<-RUBY
556
+ require 'bundler'
557
+ def Bundler.require(path)
558
+ raise "LOSE"
559
+ end
560
+ Bundler.load
561
+ RUBY
562
+
563
+ err.should be_empty
564
+ out.should be_empty
565
+ end
566
+ end
567
+
568
+ describe "when Bundler is bundled" do
569
+ it "doesn't blow up" do
570
+ install_gemfile <<-G
571
+ gem "bundler", :path => "#{File.expand_path("..", lib)}"
572
+ G
573
+
574
+ bundle %|exec ruby -e "require 'bundler'; Bundler.setup"|
575
+ err.should be_empty
576
+ end
577
+ end
412
578
  end
data/spec/spec_helper.rb CHANGED
@@ -27,6 +27,7 @@ $show_err = true
27
27
  Spec::Rubygems.setup
28
28
  FileUtils.rm_rf(Spec::Path.gem_repo1)
29
29
  ENV['RUBYOPT'] = "-I#{Spec::Path.root}/spec/support/rubygems_hax"
30
+ ENV['BUNDLE_SPEC_RUN'] = "true"
30
31
 
31
32
  RSpec.configure do |config|
32
33
  config.include Spec::Builders
@@ -38,7 +39,7 @@ RSpec.configure do |config|
38
39
  config.include Spec::Platforms
39
40
  config.include Spec::Sudo
40
41
 
41
- config.filter_run :focused => true
42
+ config.filter_run :focused => true unless ENV['CI']
42
43
  config.run_all_when_everything_filtered = true
43
44
  config.alias_example_to :fit, :focused => true
44
45
 
@@ -294,8 +294,9 @@ module Spec
294
294
  end
295
295
 
296
296
  def build_git(name, *args, &block)
297
- opts = Hash === args.last ? args.last : {}
298
- spec = build_with(GitBuilder, name, args, &block)
297
+ opts = args.last.is_a?(Hash) ? args.last : {}
298
+ builder = opts[:bare] ? GitBareBuilder : GitBuilder
299
+ spec = build_with(builder, name, args, &block)
299
300
  GitReader.new(opts[:path] || lib_path(spec.full_name))
300
301
  end
301
302
 
@@ -345,14 +346,7 @@ module Spec
345
346
 
346
347
  def platforms(platforms)
347
348
  platforms.split(/\s+/).each do |platform|
348
- platform = 'x86-mswin32' if platform == 'mswin32'
349
- platform = Gem::Platform.new(platform)
350
- if String === platform
351
- class << platform
352
- undef =~
353
- alias =~ ==
354
- end
355
- end
349
+ platform.gsub!(/^(mswin32)$/, 'x86-\1')
356
350
  yield Gem::Platform.new(platform)
357
351
  end
358
352
  end
@@ -484,6 +478,16 @@ module Spec
484
478
  end
485
479
  end
486
480
 
481
+ class GitBareBuilder < LibBuilder
482
+ def _build(options)
483
+ path = options[:path] || _default_path
484
+ super(options.merge(:path => path))
485
+ Dir.chdir(path) do
486
+ `git init --bare`
487
+ end
488
+ end
489
+ end
490
+
487
491
  class GitUpdater < LibBuilder
488
492
  WINDOWS = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
489
493
  NULL = WINDOWS ? "NUL" : "/dev/null"
@@ -508,6 +512,10 @@ module Spec
508
512
  silently("git checkout #{branch}")
509
513
  elsif tag = options[:tag]
510
514
  `git tag #{tag}`
515
+ elsif options[:remote]
516
+ silently("git remote add origin file://#{options[:remote]}")
517
+ elsif options[:push]
518
+ silently("git push origin #{options[:push]}")
511
519
  end
512
520
 
513
521
  current_ref = `git rev-parse HEAD`.strip
@@ -29,15 +29,10 @@ module Spec
29
29
  def run(cmd, *args)
30
30
  opts = args.last.is_a?(Hash) ? args.pop : {}
31
31
  expect_err = opts.delete(:expect_err)
32
+ env = opts.delete(:env)
32
33
  groups = args.map {|a| a.inspect }.join(", ")
33
-
34
- if opts[:lite_runtime]
35
- setup = "require 'rubygems' ; require 'bundler/setup' ; Bundler.setup(#{groups})\n"
36
- else
37
- setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
38
- end
39
-
40
- @out = ruby(setup + cmd, :expect_err => expect_err)
34
+ setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
35
+ @out = ruby(setup + cmd, :expect_err => expect_err, :env => env)
41
36
  end
42
37
 
43
38
  def lib
@@ -46,7 +41,7 @@ module Spec
46
41
 
47
42
  def bundle(cmd, options = {})
48
43
  expect_err = options.delete(:expect_err)
49
- exit_status = options.delete(:exit_status)
44
+ exitstatus = options.delete(:exitstatus)
50
45
  options["no-color"] = true unless options.key?("no-color") || cmd.to_s[0..3] == "exec"
51
46
 
52
47
  env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
@@ -56,7 +51,7 @@ module Spec
56
51
  gemfile = File.expand_path('../../../bin/bundle', __FILE__)
57
52
  cmd = "#{env}#{Gem.ruby} -I#{lib} #{gemfile} #{cmd}#{args}"
58
53
 
59
- if exit_status
54
+ if exitstatus
60
55
  sys_status(cmd)
61
56
  else
62
57
  sys_exec(cmd, expect_err){|i| yield i if block_given? }
@@ -65,8 +60,9 @@ module Spec
65
60
 
66
61
  def ruby(ruby, options = {})
67
62
  expect_err = options.delete(:expect_err)
63
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
68
64
  ruby.gsub!(/["`\$]/) {|m| "\\#{m}" }
69
- sys_exec(%'#{Gem.ruby} -I#{lib} -e "#{ruby}"', expect_err)
65
+ sys_exec(%{#{env}#{Gem.ruby} -I#{lib} -e "#{ruby}"}, expect_err)
70
66
  end
71
67
 
72
68
  def gembin(cmd)
@@ -26,7 +26,6 @@ module Spec
26
26
  def should_resolve_as(specs)
27
27
  got = resolve
28
28
  got = got.map { |s| s.full_name }.sort
29
-
30
29
  got.should == specs.sort
31
30
  end
32
31
 
@@ -88,17 +87,17 @@ module Spec
88
87
  end
89
88
 
90
89
  versions '1.0 1.2 1.2.1 1.2.2 1.3 1.3.0.1 1.3.5 1.4.0 1.4.2 1.4.2.1' do |version|
91
- platforms "ruby java mswin32" do |platform|
90
+ platforms "ruby java mswin32 mingw32" do |platform|
92
91
  next if version == v('1.4.2.1') && platform != pl('x86-mswin32')
93
92
  next if version == v('1.4.2') && platform == pl('x86-mswin32')
94
93
  gem "nokogiri", version, platform do
95
- dep "weakling", ">= 0.0.3" if platform =~ 'java'
94
+ dep "weakling", ">= 0.0.3" if platform =~ pl('java')
96
95
  end
97
96
  end
98
97
  end
99
98
 
100
99
  versions '0.0.1 0.0.2 0.0.3' do |version|
101
- gem "weakling", version #, pl('java')
100
+ gem "weakling", version
102
101
  end
103
102
 
104
103
  # --- Rails related