bundler-maglev- 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +32 -0
  3. data/CHANGELOG.md +805 -0
  4. data/ISSUES.md +62 -0
  5. data/LICENSE +23 -0
  6. data/README.md +29 -0
  7. data/Rakefile +212 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +22 -0
  10. data/bundler.gemspec +30 -0
  11. data/lib/bundler.rb +286 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +520 -0
  14. data/lib/bundler/definition.rb +438 -0
  15. data/lib/bundler/dependency.rb +134 -0
  16. data/lib/bundler/deployment.rb +58 -0
  17. data/lib/bundler/dsl.rb +257 -0
  18. data/lib/bundler/environment.rb +47 -0
  19. data/lib/bundler/gem_helper.rb +151 -0
  20. data/lib/bundler/gem_installer.rb +9 -0
  21. data/lib/bundler/gem_tasks.rb +2 -0
  22. data/lib/bundler/graph.rb +130 -0
  23. data/lib/bundler/index.rb +138 -0
  24. data/lib/bundler/installer.rb +97 -0
  25. data/lib/bundler/lazy_specification.rb +74 -0
  26. data/lib/bundler/lockfile_parser.rb +108 -0
  27. data/lib/bundler/remote_specification.rb +59 -0
  28. data/lib/bundler/resolver.rb +464 -0
  29. data/lib/bundler/rubygems_ext.rb +237 -0
  30. data/lib/bundler/rubygems_integration.rb +349 -0
  31. data/lib/bundler/runtime.rb +152 -0
  32. data/lib/bundler/settings.rb +115 -0
  33. data/lib/bundler/setup.rb +23 -0
  34. data/lib/bundler/shared_helpers.rb +71 -0
  35. data/lib/bundler/source.rb +708 -0
  36. data/lib/bundler/spec_set.rb +135 -0
  37. data/lib/bundler/templates/Executable +16 -0
  38. data/lib/bundler/templates/Gemfile +4 -0
  39. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  40. data/lib/bundler/templates/newgem/Rakefile.tt +1 -0
  41. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  42. data/lib/bundler/templates/newgem/gitignore.tt +4 -0
  43. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
  44. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  45. data/lib/bundler/templates/newgem/newgem.gemspec.tt +24 -0
  46. data/lib/bundler/ui.rb +73 -0
  47. data/lib/bundler/vendor/thor.rb +358 -0
  48. data/lib/bundler/vendor/thor/actions.rb +314 -0
  49. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  50. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  51. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  52. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  53. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
  54. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
  55. data/lib/bundler/vendor/thor/base.rb +576 -0
  56. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  57. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  58. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  59. data/lib/bundler/vendor/thor/error.rb +30 -0
  60. data/lib/bundler/vendor/thor/group.rb +273 -0
  61. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  62. data/lib/bundler/vendor/thor/parser.rb +4 -0
  63. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  64. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  65. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  66. data/lib/bundler/vendor/thor/parser/options.rb +175 -0
  67. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  68. data/lib/bundler/vendor/thor/runner.rb +309 -0
  69. data/lib/bundler/vendor/thor/shell.rb +88 -0
  70. data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
  71. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  72. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  73. data/lib/bundler/vendor/thor/task.rb +113 -0
  74. data/lib/bundler/vendor/thor/util.rb +229 -0
  75. data/lib/bundler/vendor/thor/version.rb +3 -0
  76. data/lib/bundler/vendored_thor.rb +7 -0
  77. data/lib/bundler/version.rb +6 -0
  78. data/lib/bundler/vlad.rb +11 -0
  79. data/man/bundle-config.ronn +90 -0
  80. data/man/bundle-exec.ronn +111 -0
  81. data/man/bundle-install.ronn +317 -0
  82. data/man/bundle-package.ronn +59 -0
  83. data/man/bundle-update.ronn +176 -0
  84. data/man/bundle.ronn +80 -0
  85. data/man/gemfile.5.ronn +284 -0
  86. data/man/index.txt +6 -0
  87. data/spec/bundler/gem_helper_spec.rb +143 -0
  88. data/spec/cache/gems_spec.rb +230 -0
  89. data/spec/cache/git_spec.rb +12 -0
  90. data/spec/cache/path_spec.rb +27 -0
  91. data/spec/cache/platform_spec.rb +57 -0
  92. data/spec/install/deploy_spec.rb +197 -0
  93. data/spec/install/deprecated_spec.rb +37 -0
  94. data/spec/install/gems/c_ext_spec.rb +48 -0
  95. data/spec/install/gems/env_spec.rb +107 -0
  96. data/spec/install/gems/flex_spec.rb +313 -0
  97. data/spec/install/gems/groups_spec.rb +259 -0
  98. data/spec/install/gems/packed_spec.rb +84 -0
  99. data/spec/install/gems/platform_spec.rb +192 -0
  100. data/spec/install/gems/resolving_spec.rb +72 -0
  101. data/spec/install/gems/simple_case_spec.rb +770 -0
  102. data/spec/install/gems/sudo_spec.rb +74 -0
  103. data/spec/install/gems/win32_spec.rb +26 -0
  104. data/spec/install/gemspec_spec.rb +125 -0
  105. data/spec/install/git_spec.rb +570 -0
  106. data/spec/install/invalid_spec.rb +35 -0
  107. data/spec/install/path_spec.rb +405 -0
  108. data/spec/install/upgrade_spec.rb +26 -0
  109. data/spec/lock/git_spec.rb +35 -0
  110. data/spec/lock/lockfile_spec.rb +739 -0
  111. data/spec/other/check_spec.rb +221 -0
  112. data/spec/other/config_spec.rb +40 -0
  113. data/spec/other/console_spec.rb +54 -0
  114. data/spec/other/exec_spec.rb +248 -0
  115. data/spec/other/ext_spec.rb +37 -0
  116. data/spec/other/help_spec.rb +39 -0
  117. data/spec/other/init_spec.rb +40 -0
  118. data/spec/other/newgem_spec.rb +46 -0
  119. data/spec/other/open_spec.rb +35 -0
  120. data/spec/other/show_spec.rb +82 -0
  121. data/spec/quality_spec.rb +62 -0
  122. data/spec/resolver/basic_spec.rb +20 -0
  123. data/spec/resolver/platform_spec.rb +82 -0
  124. data/spec/runtime/executable_spec.rb +110 -0
  125. data/spec/runtime/load_spec.rb +107 -0
  126. data/spec/runtime/platform_spec.rb +90 -0
  127. data/spec/runtime/require_spec.rb +231 -0
  128. data/spec/runtime/setup_spec.rb +730 -0
  129. data/spec/runtime/with_clean_env_spec.rb +15 -0
  130. data/spec/spec_helper.rb +92 -0
  131. data/spec/support/builders.rb +597 -0
  132. data/spec/support/helpers.rb +239 -0
  133. data/spec/support/indexes.rb +112 -0
  134. data/spec/support/matchers.rb +77 -0
  135. data/spec/support/path.rb +71 -0
  136. data/spec/support/platforms.rb +53 -0
  137. data/spec/support/ruby_ext.rb +20 -0
  138. data/spec/support/rubygems_ext.rb +37 -0
  139. data/spec/support/rubygems_hax/platform.rb +11 -0
  140. data/spec/support/sudo.rb +21 -0
  141. data/spec/update/gems_spec.rb +122 -0
  142. data/spec/update/git_spec.rb +196 -0
  143. data/spec/update/source_spec.rb +51 -0
  144. metadata +296 -0
@@ -0,0 +1,730 @@
1
+ require "spec_helper"
2
+
3
+ describe "Bundler.setup" do
4
+ describe "with no arguments" do
5
+ it "makes all groups available" do
6
+ install_gemfile <<-G
7
+ source "file://#{gem_repo1}"
8
+ gem "rack", :group => :test
9
+ G
10
+
11
+ ruby <<-RUBY
12
+ require 'rubygems'
13
+ require 'bundler'
14
+ Bundler.setup
15
+
16
+ require 'rack'
17
+ puts RACK
18
+ RUBY
19
+ err.should eq("")
20
+ out.should eq("1.0.0")
21
+ end
22
+ end
23
+
24
+ describe "when called with groups" do
25
+ before(:each) do
26
+ install_gemfile <<-G
27
+ source "file://#{gem_repo1}"
28
+ gem "yard"
29
+ gem "rack", :group => :test
30
+ G
31
+ end
32
+
33
+ it "doesn't make all groups available" do
34
+ ruby <<-RUBY
35
+ require 'rubygems'
36
+ require 'bundler'
37
+ Bundler.setup(:default)
38
+
39
+ begin
40
+ require 'rack'
41
+ rescue LoadError
42
+ puts "WIN"
43
+ end
44
+ RUBY
45
+ err.should eq("")
46
+ out.should eq("WIN")
47
+ end
48
+
49
+ it "leaves all groups available if they were already" do
50
+ ruby <<-RUBY
51
+ require 'rubygems'
52
+ require 'bundler'
53
+ Bundler.setup
54
+ Bundler.setup(:default)
55
+
56
+ require 'rack'
57
+ puts RACK
58
+ RUBY
59
+ err.should eq("")
60
+ out.should eq("1.0.0")
61
+ end
62
+
63
+ it "leaves :default available if setup is called twice" do
64
+ ruby <<-RUBY
65
+ require 'rubygems'
66
+ require 'bundler'
67
+ Bundler.setup(:default)
68
+ Bundler.setup(:default, :test)
69
+
70
+ begin
71
+ require 'yard'
72
+ puts "WIN"
73
+ rescue LoadError
74
+ puts "FAIL"
75
+ end
76
+ RUBY
77
+ err.should eq("")
78
+ out.should match("WIN")
79
+ end
80
+ end
81
+
82
+ it "raises if the Gemfile was not yet installed" do
83
+ gemfile <<-G
84
+ source "file://#{gem_repo1}"
85
+ gem "rack"
86
+ G
87
+
88
+ ruby <<-R
89
+ require 'rubygems'
90
+ require 'bundler'
91
+
92
+ begin
93
+ Bundler.setup
94
+ puts "FAIL"
95
+ rescue Bundler::GemNotFound
96
+ puts "WIN"
97
+ end
98
+ R
99
+
100
+ out.should == "WIN"
101
+ end
102
+
103
+ it "doesn't create a Gemfile.lock if the setup fails" do
104
+ gemfile <<-G
105
+ source "file://#{gem_repo1}"
106
+ gem "rack"
107
+ G
108
+
109
+ ruby <<-R, :expect_err => true
110
+ require 'rubygems'
111
+ require 'bundler'
112
+
113
+ Bundler.setup
114
+ R
115
+
116
+ bundled_app("Gemfile.lock").should_not exist
117
+ end
118
+
119
+ it "doesn't change the Gemfile.lock if the setup fails" do
120
+ install_gemfile <<-G
121
+ source "file://#{gem_repo1}"
122
+ gem "rack"
123
+ G
124
+
125
+ lockfile = File.read(bundled_app("Gemfile.lock"))
126
+
127
+ gemfile <<-G
128
+ source "file://#{gem_repo1}"
129
+ gem "rack"
130
+ gem "nosuchgem", "10.0"
131
+ G
132
+
133
+ ruby <<-R, :expect_err => true
134
+ require 'rubygems'
135
+ require 'bundler'
136
+
137
+ Bundler.setup
138
+ R
139
+
140
+ File.read(bundled_app("Gemfile.lock")).should == lockfile
141
+ end
142
+
143
+ it "makes a Gemfile.lock if setup succeeds" do
144
+ install_gemfile <<-G
145
+ source "file://#{gem_repo1}"
146
+ gem "rack"
147
+ G
148
+
149
+ File.read(bundled_app("Gemfile.lock"))
150
+
151
+ FileUtils.rm(bundled_app("Gemfile.lock"))
152
+
153
+ run "1"
154
+ bundled_app("Gemfile.lock").should exist
155
+ end
156
+
157
+ it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
158
+ gemfile <<-G
159
+ source "file://#{gem_repo1}"
160
+ gem "rack"
161
+ G
162
+
163
+ gemfile bundled_app('4realz'), <<-G
164
+ source "file://#{gem_repo1}"
165
+ gem "activesupport", "2.3.5"
166
+ G
167
+
168
+ ENV['BUNDLE_GEMFILE'] = bundled_app('4realz').to_s
169
+ bundle :install
170
+
171
+ should_be_installed "activesupport 2.3.5"
172
+ end
173
+
174
+ it "prioritizes gems in BUNDLE_PATH over gems in GEM_HOME" do
175
+ ENV['BUNDLE_PATH'] = bundled_app('.bundle').to_s
176
+ install_gemfile <<-G
177
+ source "file://#{gem_repo1}"
178
+ gem "rack", "1.0.0"
179
+ G
180
+
181
+ build_gem "rack", "1.0", :to_system => true do |s|
182
+ s.write "lib/rack.rb", "RACK = 'FAIL'"
183
+ end
184
+
185
+ should_be_installed "rack 1.0.0"
186
+ end
187
+
188
+ describe "integrate with rubygems" do
189
+ describe "by replacing #gem" do
190
+ before :each do
191
+ install_gemfile <<-G
192
+ source "file://#{gem_repo1}"
193
+ gem "rack", "0.9.1"
194
+ G
195
+ end
196
+
197
+ it "replaces #gem but raises when the gem is missing" do
198
+ run <<-R
199
+ begin
200
+ gem "activesupport"
201
+ puts "FAIL"
202
+ rescue LoadError
203
+ puts "WIN"
204
+ end
205
+ R
206
+
207
+ out.should == "WIN"
208
+ end
209
+
210
+ it "version_requirement is now deprecated in rubygems 1.4.0+ when gem is missing" do
211
+ run <<-R, :expect_err => true
212
+ begin
213
+ gem "activesupport"
214
+ puts "FAIL"
215
+ rescue LoadError
216
+ puts "WIN"
217
+ end
218
+ R
219
+
220
+ err.should be_empty
221
+ end
222
+
223
+ it "replaces #gem but raises when the version is wrong" do
224
+ run <<-R
225
+ begin
226
+ gem "rack", "1.0.0"
227
+ puts "FAIL"
228
+ rescue LoadError
229
+ puts "WIN"
230
+ end
231
+ R
232
+
233
+ out.should == "WIN"
234
+ end
235
+
236
+ it "version_requirement is now deprecated in rubygems 1.4.0+ when the version is wrong" do
237
+ run <<-R, :expect_err => true
238
+ begin
239
+ gem "rack", "1.0.0"
240
+ puts "FAIL"
241
+ rescue LoadError
242
+ puts "WIN"
243
+ end
244
+ R
245
+
246
+ err.should be_empty
247
+ end
248
+ end
249
+
250
+ describe "by hiding system gems" do
251
+ before :each do
252
+ system_gems "activesupport-2.3.5"
253
+ install_gemfile <<-G
254
+ source "file://#{gem_repo1}"
255
+ gem "yard"
256
+ G
257
+ end
258
+
259
+ it "removes system gems from Gem.source_index" do
260
+ run "require 'yard'"
261
+ out.should == "bundler-#{Bundler::VERSION}\nyard-1.0"
262
+ end
263
+
264
+ context "when the ruby stdlib is a substring of Gem.path" do
265
+ it "does not reject the stdlib from $LOAD_PATH" do
266
+ substring = "/" + $LOAD_PATH.find{|p| p =~ /vendor_ruby/ }.split("/")[2]
267
+ run "puts 'worked!'", :env => {"GEM_PATH" => substring}
268
+ out.should == "worked!"
269
+ end
270
+ end
271
+ end
272
+ end
273
+
274
+ describe "with paths" do
275
+ it "activates the gems in the path source" do
276
+ system_gems "rack-1.0.0"
277
+
278
+ build_lib "rack", "1.0.0" do |s|
279
+ s.write "lib/rack.rb", "puts 'WIN'"
280
+ end
281
+
282
+ gemfile <<-G
283
+ path "#{lib_path('rack-1.0.0')}"
284
+ source "file://#{gem_repo1}"
285
+ gem "rack"
286
+ G
287
+
288
+ run "require 'rack'"
289
+ out.should == "WIN"
290
+ end
291
+ end
292
+
293
+ describe "with git" do
294
+ before do
295
+ build_git "rack", "1.0.0"
296
+
297
+ gemfile <<-G
298
+ gem "rack", :git => "#{lib_path('rack-1.0.0')}"
299
+ G
300
+ end
301
+
302
+ it "provides a useful exception when the git repo is not checked out yet" do
303
+ run "1", :expect_err => true
304
+ err.should include("#{lib_path('rack-1.0.0')} (at master) is not checked out. Please run `bundle install`")
305
+ end
306
+
307
+ it "does not hit the git binary if the lockfile is available and up to date" do
308
+ bundle "install"
309
+
310
+ break_git!
311
+
312
+ ruby <<-R
313
+ require 'rubygems'
314
+ require 'bundler'
315
+
316
+ begin
317
+ Bundler.setup
318
+ puts "WIN"
319
+ rescue Exception => e
320
+ puts "FAIL"
321
+ end
322
+ R
323
+
324
+ out.should == "WIN"
325
+ end
326
+
327
+ it "provides a good exception if the lockfile is unavailable" do
328
+ bundle "install"
329
+
330
+ FileUtils.rm(bundled_app("Gemfile.lock"))
331
+
332
+ break_git!
333
+
334
+ ruby <<-R
335
+ require "rubygems"
336
+ require "bundler"
337
+
338
+ begin
339
+ Bundler.setup
340
+ puts "FAIL"
341
+ rescue Bundler::GitError => e
342
+ puts e.message
343
+ end
344
+ R
345
+
346
+ run "puts 'FAIL'", :expect_err => true
347
+
348
+ err.should_not include "This is not the git you are looking for"
349
+ end
350
+
351
+ it "works even when the cache directory has been deleted" do
352
+ bundle "install --path vendor/bundle"
353
+ FileUtils.rm_rf vendored_gems('cache')
354
+ should_be_installed "rack 1.0.0"
355
+ end
356
+
357
+ it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
358
+ begin
359
+ bundle "install --path vendor/bundle"
360
+
361
+ Dir["**/*"].each do |f|
362
+ File.directory?(f) ?
363
+ File.chmod(0555, f) :
364
+ File.chmod(0444, f)
365
+ end
366
+ should_be_installed "rack 1.0.0"
367
+ ensure
368
+ Dir["**/*"].each do |f|
369
+ File.directory?(f) ?
370
+ File.chmod(0755, f) :
371
+ File.chmod(0644, f)
372
+ end
373
+ end
374
+ end
375
+ end
376
+
377
+ describe "when excluding groups" do
378
+ it "doesn't change the resolve if --without is used" do
379
+ install_gemfile <<-G, :without => :rails
380
+ source "file://#{gem_repo1}"
381
+ gem "activesupport"
382
+
383
+ group :rails do
384
+ gem "rails", "2.3.2"
385
+ end
386
+ G
387
+
388
+ install_gems "activesupport-2.3.5"
389
+
390
+ should_be_installed "activesupport 2.3.2", :groups => :default
391
+ end
392
+
393
+ it "remembers --without and does not bail on bare Bundler.setup" do
394
+ install_gemfile <<-G, :without => :rails
395
+ source "file://#{gem_repo1}"
396
+ gem "activesupport"
397
+
398
+ group :rails do
399
+ gem "rails", "2.3.2"
400
+ end
401
+ G
402
+
403
+ install_gems "activesupport-2.3.5"
404
+
405
+ should_be_installed "activesupport 2.3.2"
406
+ end
407
+
408
+ it "remembers --without and does not include groups passed to Bundler.setup" do
409
+ install_gemfile <<-G, :without => :rails
410
+ source "file://#{gem_repo1}"
411
+ gem "activesupport"
412
+
413
+ group :rack do
414
+ gem "rack"
415
+ end
416
+
417
+ group :rails do
418
+ gem "rails", "2.3.2"
419
+ end
420
+ G
421
+
422
+ should_not_be_installed "activesupport 2.3.2", :groups => :rack
423
+ should_be_installed "rack 1.0.0", :groups => :rack
424
+ end
425
+ end
426
+
427
+ # Unfortunately, gem_prelude does not record the information about
428
+ # activated gems, so this test cannot work on 1.9 :(
429
+ if RUBY_VERSION < "1.9"
430
+ describe "preactivated gems" do
431
+ it "raises an exception if a pre activated gem conflicts with the bundle" do
432
+ system_gems "thin-1.0", "rack-1.0.0"
433
+ build_gem "thin", "1.1", :to_system => true do |s|
434
+ s.add_dependency "rack"
435
+ end
436
+
437
+ gemfile <<-G
438
+ gem "thin", "1.0"
439
+ G
440
+
441
+ ruby <<-R
442
+ require 'rubygems'
443
+ gem "thin"
444
+ require 'bundler'
445
+ begin
446
+ Bundler.setup
447
+ puts "FAIL"
448
+ rescue Gem::LoadError => e
449
+ puts e.message
450
+ end
451
+ R
452
+
453
+ out.should == "You have already activated thin 1.1, but your Gemfile requires thin 1.0. Using bundle exec may solve this."
454
+ end
455
+
456
+ it "version_requirement is now deprecated in rubygems 1.4.0+" do
457
+ system_gems "thin-1.0", "rack-1.0.0"
458
+ build_gem "thin", "1.1", :to_system => true do |s|
459
+ s.add_dependency "rack"
460
+ end
461
+
462
+ gemfile <<-G
463
+ gem "thin", "1.0"
464
+ G
465
+
466
+ ruby <<-R, :expect_err => true
467
+ require 'rubygems'
468
+ gem "thin"
469
+ require 'bundler'
470
+ begin
471
+ Bundler.setup
472
+ puts "FAIL"
473
+ rescue Gem::LoadError => e
474
+ puts e.message
475
+ end
476
+ R
477
+
478
+ err.should be_empty
479
+ end
480
+ end
481
+ end
482
+
483
+ # Rubygems returns loaded_from as a string
484
+ it "has loaded_from as a string on all specs" do
485
+ build_git "foo"
486
+ build_git "no-gemspec", :gemspec => false
487
+
488
+ install_gemfile <<-G
489
+ source "file://#{gem_repo1}"
490
+ gem "rack"
491
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
492
+ gem "no-gemspec", "1.0", :git => "#{lib_path('no-gemspec-1.0')}"
493
+ G
494
+
495
+ run <<-R
496
+ Gem.loaded_specs.each do |n, s|
497
+ puts "FAIL" unless String === s.loaded_from
498
+ end
499
+ R
500
+
501
+ out.should be_empty
502
+ end
503
+
504
+ it "ignores empty gem paths" do
505
+ install_gemfile <<-G
506
+ source "file://#{gem_repo1}"
507
+ gem "rack"
508
+ G
509
+
510
+ ENV["GEM_HOME"] = ""
511
+ bundle %{exec ruby -e "require 'set'"}
512
+
513
+ err.should be_empty
514
+ end
515
+
516
+ it "should prepend gemspec require paths to $LOAD_PATH in order" do
517
+ update_repo2 do
518
+ build_gem("requirepaths") do |s|
519
+ s.write("lib/rq.rb", "puts 'yay'")
520
+ s.write("src/rq.rb", "puts 'nooo'")
521
+ s.require_paths = ["lib", "src"]
522
+ end
523
+ end
524
+
525
+ install_gemfile <<-G
526
+ source "file://#{gem_repo2}"
527
+ gem "requirepaths", :require => nil
528
+ G
529
+
530
+ run "require 'rq'"
531
+ out.should == "yay"
532
+ end
533
+
534
+ it "ignores Gem.refresh" do
535
+ system_gems "rack-1.0.0"
536
+
537
+ install_gemfile <<-G
538
+ source "file://#{gem_repo1}"
539
+ gem "activesupport"
540
+ G
541
+
542
+ run <<-R
543
+ Gem.refresh
544
+ puts Bundler.rubygems.find_name("rack").inspect
545
+ R
546
+
547
+ out.should == "[]"
548
+ end
549
+
550
+ describe "when a vendored gem specification uses the :path option" do
551
+ it "should resolve paths relative to the Gemfile" do
552
+ path = bundled_app(File.join('vendor', 'foo'))
553
+ build_lib "foo", :path => path
554
+
555
+ # If the .gemspec exists, then Bundler handles the path differently.
556
+ # See Source::Path.load_spec_files for details.
557
+ FileUtils.rm(File.join(path, 'foo.gemspec'))
558
+
559
+ install_gemfile <<-G
560
+ gem 'foo', '1.2.3', :path => 'vendor/foo'
561
+ G
562
+
563
+ Dir.chdir(bundled_app.parent) do
564
+ run <<-R, :env => {"BUNDLE_GEMFILE" => bundled_app('Gemfile')}
565
+ require 'foo'
566
+ R
567
+ end
568
+ err.should == ""
569
+ end
570
+ end
571
+
572
+ describe "with git gems that don't have gemspecs" do
573
+ before :each do
574
+ build_git "no-gemspec", :gemspec => false
575
+
576
+ install_gemfile <<-G
577
+ gem "no-gemspec", "1.0", :git => "#{lib_path('no-gemspec-1.0')}"
578
+ G
579
+ end
580
+
581
+ it "loads the library via a virtual spec" do
582
+ run <<-R
583
+ require 'no-gemspec'
584
+ puts NOGEMSPEC
585
+ R
586
+
587
+ out.should == "1.0"
588
+ end
589
+ end
590
+
591
+ describe "with bundled and system gems" do
592
+ before :each do
593
+ system_gems "rack-1.0.0"
594
+
595
+ install_gemfile <<-G
596
+ source "file://#{gem_repo1}"
597
+
598
+ gem "activesupport", "2.3.5"
599
+ G
600
+ end
601
+
602
+ it "does not pull in system gems" do
603
+ run <<-R
604
+ require 'rubygems'
605
+
606
+ begin;
607
+ require 'rack'
608
+ rescue LoadError
609
+ puts 'WIN'
610
+ end
611
+ R
612
+
613
+ out.should == "WIN"
614
+ end
615
+
616
+ it "provides a gem method" do
617
+ run <<-R
618
+ gem 'activesupport'
619
+ require 'activesupport'
620
+ puts ACTIVESUPPORT
621
+ R
622
+
623
+ out.should == "2.3.5"
624
+ end
625
+
626
+ it "raises an exception if gem is used to invoke a system gem not in the bundle" do
627
+ run <<-R
628
+ begin
629
+ gem 'rack'
630
+ rescue LoadError => e
631
+ puts e.message
632
+ end
633
+ R
634
+
635
+ out.should == "rack is not part of the bundle. Add it to Gemfile."
636
+ end
637
+
638
+ it "sets GEM_HOME appropriately" do
639
+ run "puts ENV['GEM_HOME']"
640
+ out.should == default_bundle_path.to_s
641
+ end
642
+ end
643
+
644
+ describe "with system gems in the bundle" do
645
+ before :each do
646
+ system_gems "rack-1.0.0"
647
+
648
+ install_gemfile <<-G
649
+ source "file://#{gem_repo1}"
650
+ gem "rack", "1.0.0"
651
+ gem "activesupport", "2.3.5"
652
+ G
653
+ end
654
+
655
+ it "sets GEM_PATH appropriately" do
656
+ run "puts Gem.path"
657
+ paths = out.split("\n")
658
+ paths.should include(system_gem_path.to_s)
659
+ paths.should include(default_bundle_path.to_s)
660
+ end
661
+ end
662
+
663
+ describe "with a gemspec that requires other files" do
664
+ before :each do
665
+ build_git "bar", :gemspec => false do |s|
666
+ s.write "lib/bar/version.rb", %{BAR_VERSION = '1.0'}
667
+ s.write "bar.gemspec", <<-G
668
+ lib = File.expand_path('../lib/', __FILE__)
669
+ $:.unshift lib unless $:.include?(lib)
670
+ require 'bar/version'
671
+
672
+ Gem::Specification.new do |s|
673
+ s.name = 'bar'
674
+ s.version = BAR_VERSION
675
+ s.summary = 'Bar'
676
+ s.files = Dir["lib/**/*.rb"]
677
+ end
678
+ G
679
+ end
680
+
681
+ gemfile <<-G
682
+ gem "bar", :git => "#{lib_path('bar-1.0')}"
683
+ G
684
+ end
685
+
686
+ it "evals each gemspec in the context of its parent directory" do
687
+ bundle :install
688
+ run "require 'bar'; puts BAR"
689
+ out.should == "1.0"
690
+ end
691
+
692
+ it "error intelligently if the gemspec has a LoadError" do
693
+ update_git "bar", :gemspec => false do |s|
694
+ s.write "bar.gemspec", "require 'foobarbaz'"
695
+ end
696
+ bundle :install
697
+ out.should include("was a LoadError while evaluating bar.gemspec")
698
+ out.should include("foobarbaz")
699
+ out.should include("bar.gemspec:1")
700
+ out.should include("try to require a relative path") if RUBY_VERSION >= "1.9.0"
701
+ end
702
+
703
+ it "evals each gemspec with a binding from the top level" do
704
+ bundle "install"
705
+
706
+ ruby <<-RUBY
707
+ require 'bundler'
708
+ def Bundler.require(path)
709
+ raise "LOSE"
710
+ end
711
+ Bundler.load
712
+ RUBY
713
+
714
+ err.should eq("")
715
+ out.should eq("")
716
+ end
717
+ end
718
+
719
+ describe "when Bundler is bundled" do
720
+ it "doesn't blow up" do
721
+ install_gemfile <<-G
722
+ gem "bundler", :path => "#{File.expand_path("..", lib)}"
723
+ G
724
+
725
+ bundle %|exec ruby -e "require 'bundler'; Bundler.setup"|
726
+ err.should be_empty
727
+ end
728
+ end
729
+
730
+ end