bundler 1.0.0 → 1.0.2

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 (108) hide show
  1. data/.gitignore +12 -0
  2. data/CHANGELOG.md +28 -6
  3. data/ISSUES.md +1 -1
  4. data/README.md +7 -5
  5. data/Rakefile +173 -0
  6. data/UPGRADING.md +103 -0
  7. data/bundler.gemspec +28 -0
  8. data/lib/bundler.rb +1 -0
  9. data/lib/bundler/capistrano.rb +2 -31
  10. data/lib/bundler/cli.rb +18 -16
  11. data/lib/bundler/deployment.rb +37 -0
  12. data/lib/bundler/dsl.rb +3 -3
  13. data/lib/bundler/gem_helper.rb +4 -7
  14. data/lib/bundler/graph.rb +3 -3
  15. data/lib/bundler/installer.rb +1 -0
  16. data/lib/bundler/lockfile_parser.rb +1 -1
  17. data/lib/bundler/man/bundle +1 -1
  18. data/lib/bundler/man/bundle-config +92 -0
  19. data/lib/bundler/man/bundle-config.txt +72 -30
  20. data/lib/bundler/man/bundle-exec +1 -1
  21. data/lib/bundler/man/bundle-exec.txt +1 -1
  22. data/lib/bundler/man/bundle-install +1 -1
  23. data/lib/bundler/man/bundle-install.txt +1 -1
  24. data/lib/bundler/man/bundle-package +1 -1
  25. data/lib/bundler/man/bundle-package.txt +1 -1
  26. data/lib/bundler/man/bundle-update +1 -1
  27. data/lib/bundler/man/bundle-update.txt +1 -1
  28. data/lib/bundler/man/bundle.txt +1 -1
  29. data/lib/bundler/man/gemfile.5 +2 -2
  30. data/lib/bundler/man/gemfile.5.txt +2 -2
  31. data/lib/bundler/settings.rb +2 -2
  32. data/lib/bundler/source.rb +2 -3
  33. data/lib/bundler/templates/Executable +1 -1
  34. data/lib/bundler/templates/newgem/Gemfile.tt +1 -1
  35. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  36. data/lib/bundler/templates/newgem/newgem.gemspec.tt +11 -12
  37. data/lib/bundler/version.rb +1 -1
  38. data/lib/bundler/vlad.rb +9 -0
  39. data/man/bundle-config.ronn +90 -0
  40. data/man/bundle-exec.ronn +98 -0
  41. data/man/bundle-install.ronn +310 -0
  42. data/man/bundle-package.ronn +59 -0
  43. data/man/bundle-update.ronn +176 -0
  44. data/man/bundle.ronn +77 -0
  45. data/man/gemfile.5.ronn +254 -0
  46. data/man/index.txt +6 -0
  47. data/spec/cache/gems_spec.rb +205 -0
  48. data/spec/cache/git_spec.rb +9 -0
  49. data/spec/cache/path_spec.rb +27 -0
  50. data/spec/cache/platform_spec.rb +57 -0
  51. data/spec/install/deploy_spec.rb +171 -0
  52. data/spec/install/deprecated_spec.rb +43 -0
  53. data/spec/install/gems/c_ext_spec.rb +48 -0
  54. data/spec/install/gems/env_spec.rb +107 -0
  55. data/spec/install/gems/flex_spec.rb +272 -0
  56. data/spec/install/gems/groups_spec.rb +209 -0
  57. data/spec/install/gems/locked_spec.rb +48 -0
  58. data/spec/install/gems/packed_spec.rb +72 -0
  59. data/spec/install/gems/platform_spec.rb +181 -0
  60. data/spec/install/gems/resolving_spec.rb +72 -0
  61. data/spec/install/gems/simple_case_spec.rb +709 -0
  62. data/spec/install/gems/sudo_spec.rb +77 -0
  63. data/spec/install/gems/win32_spec.rb +26 -0
  64. data/spec/install/gemspec_spec.rb +96 -0
  65. data/spec/install/git_spec.rb +552 -0
  66. data/spec/install/invalid_spec.rb +17 -0
  67. data/spec/install/path_spec.rb +335 -0
  68. data/spec/install/upgrade_spec.rb +26 -0
  69. data/spec/lock/flex_spec.rb +625 -0
  70. data/spec/lock/git_spec.rb +35 -0
  71. data/spec/other/check_spec.rb +221 -0
  72. data/spec/other/config_spec.rb +40 -0
  73. data/spec/other/console_spec.rb +102 -0
  74. data/spec/other/exec_spec.rb +241 -0
  75. data/spec/other/ext_spec.rb +16 -0
  76. data/spec/other/gem_helper_spec.rb +116 -0
  77. data/spec/other/help_spec.rb +36 -0
  78. data/spec/other/init_spec.rb +40 -0
  79. data/spec/other/newgem_spec.rb +24 -0
  80. data/spec/other/open_spec.rb +51 -0
  81. data/spec/other/show_spec.rb +99 -0
  82. data/spec/pack/gems_spec.rb +22 -0
  83. data/spec/quality_spec.rb +55 -0
  84. data/spec/resolver/basic_spec.rb +20 -0
  85. data/spec/resolver/platform_spec.rb +57 -0
  86. data/spec/runtime/environment_rb_spec.rb +170 -0
  87. data/spec/runtime/executable_spec.rb +110 -0
  88. data/spec/runtime/load_spec.rb +107 -0
  89. data/spec/runtime/platform_spec.rb +90 -0
  90. data/spec/runtime/require_spec.rb +261 -0
  91. data/spec/runtime/setup_spec.rb +412 -0
  92. data/spec/runtime/with_clean_env_spec.rb +15 -0
  93. data/spec/spec_helper.rb +81 -0
  94. data/spec/support/builders.rb +566 -0
  95. data/spec/support/helpers.rb +243 -0
  96. data/spec/support/indexes.rb +113 -0
  97. data/spec/support/matchers.rb +89 -0
  98. data/spec/support/path.rb +71 -0
  99. data/spec/support/platforms.rb +49 -0
  100. data/spec/support/ruby_ext.rb +19 -0
  101. data/spec/support/rubygems_ext.rb +30 -0
  102. data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
  103. data/spec/support/sudo.rb +21 -0
  104. data/spec/update/gems_spec.rb +86 -0
  105. data/spec/update/git_spec.rb +159 -0
  106. data/spec/update/source_spec.rb +50 -0
  107. metadata +170 -32
  108. data/ROADMAP.md +0 -36
@@ -0,0 +1,72 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install with gem sources" do
4
+ describe "install time dependencies" do
5
+ it "installs gems with implicit rake dependencies" do
6
+ install_gemfile <<-G
7
+ source "file://#{gem_repo1}"
8
+ gem "with_implicit_rake_dep"
9
+ gem "another_implicit_rake_dep"
10
+ gem "rake"
11
+ G
12
+
13
+ run <<-R
14
+ require 'implicit_rake_dep'
15
+ require 'another_implicit_rake_dep'
16
+ puts IMPLICIT_RAKE_DEP
17
+ puts ANOTHER_IMPLICIT_RAKE_DEP
18
+ R
19
+ out.should == "YES\nYES"
20
+ end
21
+
22
+ it "installs gems with a dependency with no type" do
23
+ build_repo2
24
+
25
+ path = "#{gem_repo2}/#{Gem::MARSHAL_SPEC_DIR}/actionpack-2.3.2.gemspec.rz"
26
+ spec = Marshal.load(Gem.inflate(File.read(path)))
27
+ spec.dependencies.each do |d|
28
+ d.instance_variable_set(:@type, :fail)
29
+ end
30
+ File.open(path, 'w') do |f|
31
+ f.write Gem.deflate(Marshal.dump(spec))
32
+ end
33
+
34
+ install_gemfile <<-G
35
+ source "file://#{gem_repo2}"
36
+ gem "actionpack", "2.3.2"
37
+ G
38
+
39
+ should_be_installed "actionpack 2.3.2", "activesupport 2.3.2"
40
+ end
41
+
42
+ describe "with crazy rubygem plugin stuff" do
43
+ it "installs plugins" do
44
+ install_gemfile <<-G
45
+ source "file://#{gem_repo1}"
46
+ gem "net_b"
47
+ G
48
+
49
+ should_be_installed "net_b 1.0"
50
+ end
51
+
52
+ it "installs plugins depended on by other plugins" do
53
+ install_gemfile <<-G
54
+ source "file://#{gem_repo1}"
55
+ gem "net_a"
56
+ G
57
+
58
+ should_be_installed "net_a 1.0", "net_b 1.0"
59
+ end
60
+
61
+ it "installs multiple levels of dependencies" do
62
+ install_gemfile <<-G
63
+ source "file://#{gem_repo1}"
64
+ gem "net_c"
65
+ gem "net_e"
66
+ G
67
+
68
+ should_be_installed "net_a 1.0", "net_b 1.0", "net_c 1.0", "net_d 1.0", "net_e 1.0"
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,709 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install with gem sources" do
4
+ describe "the simple case" do
5
+ it "prints output and returns if no dependencies are specified" do
6
+ gemfile <<-G
7
+ source "file://#{gem_repo1}"
8
+ G
9
+
10
+ bundle :install
11
+ out.should =~ /no dependencies/
12
+ end
13
+
14
+ it "does not make a lockfile if the install fails" do
15
+ install_gemfile <<-G, :expect_err => true
16
+ raise StandardError, "FAIL"
17
+ G
18
+
19
+ err.should =~ /FAIL \(StandardError\)/
20
+ bundled_app("Gemfile.lock").should_not exist
21
+ end
22
+
23
+ it "creates a Gemfile.lock" do
24
+ install_gemfile <<-G
25
+ source "file://#{gem_repo1}"
26
+ gem "rack"
27
+ G
28
+
29
+ bundled_app('Gemfile.lock').should exist
30
+ end
31
+
32
+ it "creates lock files based on the Gemfile name" do
33
+ gemfile bundled_app('OmgFile'), <<-G
34
+ source "file://#{gem_repo1}"
35
+ gem "rack", "1.0"
36
+ G
37
+
38
+ bundle 'install --gemfile OmgFile'
39
+
40
+ bundled_app("OmgFile.lock").should exist
41
+ end
42
+
43
+ it "doesn't delete the lockfile if one already exists" do
44
+ install_gemfile <<-G
45
+ source "file://#{gem_repo1}"
46
+ gem 'rack'
47
+ G
48
+
49
+ lockfile = File.read(bundled_app("Gemfile.lock"))
50
+
51
+ install_gemfile <<-G, :expect_err => true
52
+ raise StandardError, "FAIL"
53
+ G
54
+
55
+ File.read(bundled_app("Gemfile.lock")).should == lockfile
56
+ end
57
+
58
+ it "does not touch the lockfile if nothing changed" do
59
+ install_gemfile <<-G
60
+ source "file://#{gem_repo1}"
61
+ gem "rack"
62
+ G
63
+
64
+ lambda { run '1' }.should_not change { File.mtime(bundled_app('Gemfile.lock')) }
65
+ end
66
+ it "fetches gems" do
67
+ install_gemfile <<-G
68
+ source "file://#{gem_repo1}"
69
+ gem 'rack'
70
+ G
71
+
72
+ default_bundle_path("gems/rack-1.0.0").should exist
73
+ should_be_installed("rack 1.0.0")
74
+ end
75
+
76
+ it "fetches gems when multiple versions are specified" do
77
+ install_gemfile <<-G
78
+ source "file://#{gem_repo1}"
79
+ gem 'rack', "> 0.9", "< 1.0"
80
+ G
81
+
82
+ default_bundle_path("gems/rack-0.9.1").should exist
83
+ should_be_installed("rack 0.9.1")
84
+ end
85
+
86
+ it "fetches gems when multiple versions are specified take 2" do
87
+ install_gemfile <<-G
88
+ source "file://#{gem_repo1}"
89
+ gem 'rack', "< 1.0", "> 0.9"
90
+ G
91
+
92
+ default_bundle_path("gems/rack-0.9.1").should exist
93
+ should_be_installed("rack 0.9.1")
94
+ end
95
+
96
+ it "raises an appropriate error when gems are specified using symbols" do
97
+ status = install_gemfile(<<-G, :exit_status => true)
98
+ source "file://#{gem_repo1}"
99
+ gem :rack
100
+ G
101
+ status.should == 4
102
+ end
103
+
104
+ it "pulls in dependencies" do
105
+ install_gemfile <<-G
106
+ source "file://#{gem_repo1}"
107
+ gem "rails"
108
+ G
109
+
110
+ should_be_installed "actionpack 2.3.2", "rails 2.3.2"
111
+ end
112
+
113
+ it "does the right version" do
114
+ install_gemfile <<-G
115
+ source "file://#{gem_repo1}"
116
+ gem "rack", "0.9.1"
117
+ G
118
+
119
+ should_be_installed "rack 0.9.1"
120
+ end
121
+
122
+ it "does not install the development dependency" do
123
+ install_gemfile <<-G
124
+ source "file://#{gem_repo1}"
125
+ gem "with_development_dependency"
126
+ G
127
+
128
+ should_be_installed "with_development_dependency 1.0.0"
129
+ should_not_be_installed "activesupport 2.3.5"
130
+ end
131
+
132
+ it "resolves correctly" do
133
+ install_gemfile <<-G
134
+ source "file://#{gem_repo1}"
135
+ gem "activemerchant"
136
+ gem "rails"
137
+ G
138
+
139
+ should_be_installed "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
140
+ end
141
+
142
+ it "activates gem correctly according to the resolved gems" do
143
+ install_gemfile <<-G
144
+ source "file://#{gem_repo1}"
145
+ gem "activesupport", "2.3.5"
146
+ G
147
+
148
+ install_gemfile <<-G
149
+ source "file://#{gem_repo1}"
150
+ gem "activemerchant"
151
+ gem "rails"
152
+ G
153
+
154
+ should_be_installed "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
155
+ end
156
+
157
+ it "does not reinstall any gem that is already available locally" do
158
+ system_gems "activesupport-2.3.2"
159
+
160
+ build_repo2 do
161
+ build_gem "activesupport", "2.3.2" do |s|
162
+ s.write "lib/activesupport.rb", "ACTIVESUPPORT = 'fail'"
163
+ end
164
+ end
165
+
166
+ install_gemfile <<-G
167
+ source "file://#{gem_repo2}"
168
+ gem "activerecord", "2.3.2"
169
+ G
170
+
171
+ should_be_installed "activesupport 2.3.2"
172
+ end
173
+
174
+ it "works when the gemfile specifies gems that only exist in the system" do
175
+ build_gem "foo", :to_system => true
176
+ install_gemfile <<-G
177
+ source "file://#{gem_repo1}"
178
+ gem "rack"
179
+ gem "foo"
180
+ G
181
+
182
+ should_be_installed "rack 1.0.0", "foo 1.0.0"
183
+ end
184
+
185
+ it "prioritizes local gems over remote gems" do
186
+ build_gem 'rack', '1.0.0', :to_system => true do |s|
187
+ s.add_dependency "activesupport", "2.3.5"
188
+ end
189
+
190
+ install_gemfile <<-G
191
+ source "file://#{gem_repo1}"
192
+ gem "rack"
193
+ G
194
+
195
+ should_be_installed "rack 1.0.0", "activesupport 2.3.5"
196
+ end
197
+
198
+ describe "with a gem that installs multiple platforms" do
199
+ it "installs gems for the local platform as first choice" do
200
+ install_gemfile <<-G
201
+ source "file://#{gem_repo1}"
202
+ gem "platform_specific"
203
+ G
204
+
205
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
206
+ out.should == "1.0.0 #{Gem::Platform.local}"
207
+ end
208
+
209
+ it "falls back on plain ruby" do
210
+ simulate_platform "foo-bar-baz"
211
+ install_gemfile <<-G
212
+ source "file://#{gem_repo1}"
213
+ gem "platform_specific"
214
+ G
215
+
216
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
217
+ out.should == "1.0.0 RUBY"
218
+ end
219
+
220
+ it "installs gems for java" do
221
+ simulate_platform "java"
222
+ install_gemfile <<-G
223
+ source "file://#{gem_repo1}"
224
+ gem "platform_specific"
225
+ G
226
+
227
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
228
+ out.should == "1.0.0 JAVA"
229
+ end
230
+
231
+ it "installs gems for windows" do
232
+ simulate_platform mswin
233
+
234
+ install_gemfile <<-G
235
+ source "file://#{gem_repo1}"
236
+ gem "platform_specific"
237
+ G
238
+
239
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
240
+ out.should == "1.0.0 MSWIN"
241
+ end
242
+ end
243
+
244
+ describe "doing bundle install foo" do
245
+ before do
246
+ gemfile <<-G
247
+ source "file://#{gem_repo1}"
248
+ gem "rack"
249
+ G
250
+ end
251
+
252
+ it "works" do
253
+ bundle "install vendor"
254
+ should_be_installed "rack 1.0"
255
+ end
256
+
257
+ it "allows running bundle install --system without deleting foo" do
258
+ bundle "install vendor"
259
+ bundle "install --system"
260
+ FileUtils.rm_rf(bundled_app("vendor"))
261
+ should_be_installed "rack 1.0"
262
+ end
263
+
264
+ it "allows running bundle install --system after deleting foo" do
265
+ bundle "install vendor"
266
+ FileUtils.rm_rf(bundled_app("vendor"))
267
+ bundle "install --system"
268
+ should_be_installed "rack 1.0"
269
+ end
270
+ end
271
+
272
+ it "finds gems in multiple sources" do
273
+ build_repo2
274
+ update_repo2
275
+
276
+ install_gemfile <<-G
277
+ source "file://#{gem_repo1}"
278
+ source "file://#{gem_repo2}"
279
+
280
+ gem "activesupport", "1.2.3"
281
+ gem "rack", "1.2"
282
+ G
283
+
284
+ should_be_installed "rack 1.2", "activesupport 1.2.3"
285
+ end
286
+
287
+ it "gives a useful error if no sources are set" do
288
+ install_gemfile <<-G
289
+ gem "rack"
290
+ G
291
+
292
+ bundle :install, :expect_err => true
293
+ out.should =~ /Your Gemfile doesn't have any sources/i
294
+ end
295
+ end
296
+
297
+ describe "when prerelease gems are available" do
298
+ it "finds prereleases" do
299
+ install_gemfile <<-G
300
+ source "file://#{gem_repo1}"
301
+ gem "not_released"
302
+ G
303
+ should_be_installed "not_released 1.0.pre"
304
+ end
305
+
306
+ it "uses regular releases if available" do
307
+ install_gemfile <<-G
308
+ source "file://#{gem_repo1}"
309
+ gem "has_prerelease"
310
+ G
311
+ should_be_installed "has_prerelease 1.0"
312
+ end
313
+
314
+ it "uses prereleases if requested" do
315
+ install_gemfile <<-G
316
+ source "file://#{gem_repo1}"
317
+ gem "has_prerelease", "1.1.pre"
318
+ G
319
+ should_be_installed "has_prerelease 1.1.pre"
320
+ end
321
+ end
322
+
323
+ describe "when prerelease gems are not available" do
324
+ it "still works" do
325
+ build_repo3
326
+ install_gemfile <<-G
327
+ source "file://#{gem_repo3}"
328
+ gem "rack"
329
+ G
330
+
331
+ should_be_installed "rack 1.0"
332
+ end
333
+ end
334
+
335
+ describe "when BUNDLE_PATH or the global path config is set" do
336
+ before :each do
337
+ build_lib "rack", "1.0.0", :to_system => true do |s|
338
+ s.write "lib/rack.rb", "raise 'FAIL'"
339
+ end
340
+
341
+ gemfile <<-G
342
+ source "file://#{gem_repo1}"
343
+ gem "rack"
344
+ G
345
+ end
346
+
347
+ def set_bundle_path(type, location)
348
+ if type == :env
349
+ ENV["BUNDLE_PATH"] = location
350
+ elsif type == :global
351
+ bundle "config path #{location}", "no-color" => nil
352
+ end
353
+ end
354
+
355
+ [:env, :global].each do |type|
356
+ it "installs gems to a path if one is specified" do
357
+ set_bundle_path(type, bundled_app("vendor2").to_s)
358
+ bundle "install vendor"
359
+
360
+ vendored_gems("gems/rack-1.0.0").should be_directory
361
+ bundled_app("vendor2").should_not be_directory
362
+ should_be_installed "rack 1.0.0"
363
+ end
364
+
365
+ it "installs gems to BUNDLE_PATH with #{type}" do
366
+ set_bundle_path(type, bundled_app("vendor").to_s)
367
+
368
+ bundle :install
369
+
370
+ bundled_app('vendor/gems/rack-1.0.0').should be_directory
371
+ should_be_installed "rack 1.0.0"
372
+ end
373
+
374
+ it "installs gems to BUNDLE_PATH relative to root when relative" do
375
+ set_bundle_path(type, "vendor")
376
+
377
+ FileUtils.mkdir_p bundled_app('lol')
378
+ Dir.chdir(bundled_app('lol')) do
379
+ bundle :install
380
+ end
381
+
382
+ bundled_app('vendor/gems/rack-1.0.0').should be_directory
383
+ should_be_installed "rack 1.0.0"
384
+ end
385
+ end
386
+
387
+ it "installs gems to BUNDLE_PATH from .bundle/config" do
388
+ config "BUNDLE_PATH" => bundled_app("vendor").to_s
389
+
390
+ bundle :install
391
+
392
+ vendored_gems('gems/rack-1.0.0').should be_directory
393
+ should_be_installed "rack 1.0.0"
394
+ end
395
+
396
+ it "sets BUNDLE_PATH as the first argument to bundle install" do
397
+ bundle "install ./vendor"
398
+
399
+ vendored_gems('gems/rack-1.0.0').should be_directory
400
+ should_be_installed "rack 1.0.0"
401
+ end
402
+
403
+ it "disables system gems when passing a path to install" do
404
+ # This is so that vendored gems can be distributed to others
405
+ build_gem "rack", "1.1.0", :to_system => true
406
+ bundle "install ./vendor"
407
+
408
+ vendored_gems('gems/rack-1.0.0').should be_directory
409
+ should_be_installed "rack 1.0.0"
410
+ end
411
+ end
412
+
413
+ describe "when passing in a Gemfile via --gemfile" do
414
+ it "finds the gemfile" do
415
+ gemfile bundled_app("NotGemfile"), <<-G
416
+ source "file://#{gem_repo1}"
417
+ gem 'rack'
418
+ G
419
+
420
+ bundle :install, :gemfile => bundled_app("NotGemfile")
421
+
422
+ ENV['BUNDLE_GEMFILE'] = "NotGemfile"
423
+ should_be_installed "rack 1.0.0"
424
+ end
425
+ end
426
+
427
+ describe "when requesting a quiet install via --quiet" do
428
+ it "should be quiet if there are no warnings" do
429
+ gemfile <<-G
430
+ source "file://#{gem_repo1}"
431
+ gem 'rack'
432
+ G
433
+
434
+ bundle :install, :quiet => true
435
+ out.should == ""
436
+ end
437
+
438
+ it "should still display warnings" do
439
+ gemfile <<-G
440
+ gem 'rack'
441
+ G
442
+
443
+ bundle :install, :quiet => true
444
+ out.should =~ /doesn't have any sources/
445
+ end
446
+ end
447
+
448
+ describe "when disabling system gems" do
449
+ before :each do
450
+ build_gem "rack", "1.0.0", :to_system => true do |s|
451
+ s.write "lib/rack.rb", "puts 'FAIL'"
452
+ end
453
+
454
+ gemfile <<-G
455
+ source "file://#{gem_repo1}"
456
+ gem "rack"
457
+ G
458
+ end
459
+
460
+ it "behaves like bundle install vendor/bundle with --deployment" do
461
+ bundle "install"
462
+ bundle "install --deployment"
463
+ out.should include("Your bundle was installed to `vendor/bundle`")
464
+ should_be_installed "rack 1.0.0"
465
+ bundled_app("vendor/bundle").should exist
466
+ end
467
+
468
+ it "prints a warning if you try to use --disable-shared-gems" do
469
+ bundle "install vendor --disable-shared-gems"
470
+ out.should include "The disable-shared-gem option is no longer available"
471
+ end
472
+
473
+ ["install vendor", "install --path vendor"].each do |install|
474
+ it "does not use available system gems with bundle #{install}" do
475
+ bundle install
476
+ should_be_installed "rack 1.0.0"
477
+ end
478
+
479
+ it "prints a warning to let the user know what has happened with bundle #{install}" do
480
+ bundle install
481
+ out.should include("Your bundle was installed to `vendor`")
482
+ end
483
+
484
+ it "disallows #{install} --system" do
485
+ bundle "#{install} --system"
486
+ out.should include("Please choose.")
487
+ end
488
+
489
+ it "remembers to disable system gems after the first time with bundle #{install}" do
490
+ bundle install
491
+ FileUtils.rm_rf bundled_app('vendor')
492
+ bundle "install"
493
+
494
+ vendored_gems('gems/rack-1.0.0').should be_directory
495
+ should_be_installed "rack 1.0.0"
496
+ end
497
+ end
498
+ end
499
+
500
+ describe "when loading only the default group" do
501
+ it "should not load all groups" do
502
+ install_gemfile <<-G
503
+ source "file://#{gem_repo1}"
504
+ gem "rack"
505
+ gem "activesupport", :group => :development
506
+ G
507
+
508
+ ruby <<-R
509
+ require "bundler"
510
+ Bundler.setup :default
511
+ Bundler.require :default
512
+ puts RACK
513
+ begin
514
+ require "activesupport"
515
+ rescue LoadError
516
+ puts "no activesupport"
517
+ end
518
+ R
519
+
520
+ out.should include("1.0")
521
+ out.should include("no activesupport")
522
+ end
523
+ end
524
+
525
+ describe "when a gem has a YAML gemspec" do
526
+ before :each do
527
+ build_repo2 do
528
+ build_gem "yaml_spec", :gemspec => :yaml
529
+ end
530
+ end
531
+
532
+ it "still installs correctly" do
533
+ gemfile <<-G
534
+ source "file://#{gem_repo2}"
535
+ gem "yaml_spec"
536
+ G
537
+ bundle :install
538
+ err.should be_empty
539
+ end
540
+ end
541
+
542
+ describe "when the gem has an architecture in its platform" do
543
+ it "still installs correctly" do
544
+ simulate_platform mswin
545
+
546
+ gemfile <<-G
547
+ # Set up pretend http gem server with FakeWeb
548
+ $LOAD_PATH.unshift '#{Dir[base_system_gems.join("gems/fakeweb*/lib")].first}'
549
+ require 'fakeweb'
550
+ FakeWeb.allow_net_connect = false
551
+ files = [ 'specs.4.8.gz',
552
+ 'prerelease_specs.4.8.gz',
553
+ 'quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz',
554
+ 'gems/rcov-1.0-mswin32.gem' ]
555
+ files.each do |file|
556
+ FakeWeb.register_uri(:get, "http://localgemserver.com/\#{file}",
557
+ :body => File.read("#{gem_repo1}/\#{file}"))
558
+ end
559
+ FakeWeb.register_uri(:get, "http://localgemserver.com/gems/rcov-1.0-x86-mswin32.gem",
560
+ :status => ["404", "Not Found"])
561
+
562
+ # Try to install gem with nil arch
563
+ source "http://localgemserver.com/"
564
+ gem "rcov"
565
+ G
566
+ bundle :install
567
+ should_be_installed "rcov 1.0.0"
568
+ end
569
+ end
570
+
571
+ describe "bundler dependencies" do
572
+ before(:each) do
573
+ build_repo2 do
574
+ build_gem "rails", "3.0" do |s|
575
+ s.add_dependency "bundler", ">= 0.9.0.pre"
576
+ end
577
+ build_gem "bundler", "0.9.1"
578
+ build_gem "bundler", Bundler::VERSION
579
+ end
580
+ end
581
+
582
+ it "are forced to the current bundler version" do
583
+ install_gemfile <<-G
584
+ source "file://#{gem_repo2}"
585
+ gem "rails", "3.0"
586
+ G
587
+
588
+ should_be_installed "bundler #{Bundler::VERSION}"
589
+ end
590
+
591
+ it "are not added if not already present" do
592
+ install_gemfile <<-G
593
+ source "file://#{gem_repo1}"
594
+ gem "rack"
595
+ G
596
+ should_not_be_installed "bundler 0.9.1"
597
+ end
598
+
599
+ it "causes a conflict if explicitly requesting a different version" do
600
+ install_gemfile <<-G
601
+ source "file://#{gem_repo2}"
602
+ gem "rails", "3.0"
603
+ gem "bundler", "0.9.2"
604
+ G
605
+
606
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
607
+ Fetching source index for file:#{gem_repo2}/
608
+ Bundler could not find compatible versions for gem "bundler":
609
+ In Gemfile:
610
+ bundler (= 0.9.2)
611
+
612
+ In snapshot (Gemfile.lock):
613
+ bundler (#{Bundler::VERSION})
614
+ E
615
+ out.should == nice_error
616
+ end
617
+
618
+ it "works for gems with multiple versions in its dependencies" do
619
+ install_gemfile <<-G
620
+ source "file://#{gem_repo2}"
621
+
622
+ gem "multiple_versioned_deps"
623
+ G
624
+
625
+
626
+ install_gemfile <<-G
627
+ source "file://#{gem_repo2}"
628
+
629
+ gem "multiple_versioned_deps"
630
+ gem "rack"
631
+ G
632
+
633
+ should_be_installed "multiple_versioned_deps 1.0.0"
634
+ end
635
+
636
+ it "includes bundler in the bundle when it's a child dependency" do
637
+ install_gemfile <<-G
638
+ source "file://#{gem_repo2}"
639
+ gem "rails", "3.0"
640
+ G
641
+
642
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError; puts 'FAIL'; end"
643
+ out.should == "WIN"
644
+ end
645
+
646
+ it "allows gem 'bundler' when Bundler is not in the Gemfile or its dependencies" do
647
+ install_gemfile <<-G
648
+ source "file://#{gem_repo2}"
649
+ gem "rack"
650
+ G
651
+
652
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError => e; puts e.backtrace; end"
653
+ out.should == "WIN"
654
+ end
655
+
656
+ it "causes a conflict if child dependencies conflict" do
657
+ install_gemfile <<-G
658
+ source "file://#{gem_repo2}"
659
+ gem "activemerchant"
660
+ gem "rails_fail"
661
+ G
662
+
663
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
664
+ Fetching source index for file:#{gem_repo2}/
665
+ Bundler could not find compatible versions for gem "activesupport":
666
+ In Gemfile:
667
+ activemerchant depends on
668
+ activesupport (>= 2.0.0)
669
+
670
+ rails_fail depends on
671
+ activesupport (1.2.3)
672
+ E
673
+ out.should == nice_error
674
+ end
675
+
676
+ it "causes a conflict if a child dependency conflicts with the Gemfile" do
677
+ install_gemfile <<-G
678
+ source "file://#{gem_repo2}"
679
+ gem "rails_fail"
680
+ gem "activesupport", "2.3.5"
681
+ G
682
+
683
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
684
+ Fetching source index for file:#{gem_repo2}/
685
+ Bundler could not find compatible versions for gem "activesupport":
686
+ In Gemfile:
687
+ rails_fail depends on
688
+ activesupport (= 1.2.3)
689
+
690
+ activesupport (2.3.5)
691
+ E
692
+ out.should == nice_error
693
+ end
694
+
695
+ it "can install dependencies even if " do
696
+ install_gemfile <<-G
697
+ source "file://#{gem_repo2}"
698
+ gem "rails", "3.0"
699
+ G
700
+
701
+ simulate_bundler_version "10.0.0"
702
+ #simulate_new_machine
703
+
704
+ bundle "check"
705
+ out.should == "The Gemfile's dependencies are satisfied"
706
+ end
707
+ end
708
+
709
+ end