bundler-maglev- 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
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,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,770 @@
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
+
67
+ it "fetches gems" do
68
+ install_gemfile <<-G
69
+ source "file://#{gem_repo1}"
70
+ gem 'rack'
71
+ G
72
+
73
+ default_bundle_path("gems/rack-1.0.0").should exist
74
+ should_be_installed("rack 1.0.0")
75
+ end
76
+
77
+ it "fetches gems when multiple versions are specified" do
78
+ install_gemfile <<-G
79
+ source "file://#{gem_repo1}"
80
+ gem 'rack', "> 0.9", "< 1.0"
81
+ G
82
+
83
+ default_bundle_path("gems/rack-0.9.1").should exist
84
+ should_be_installed("rack 0.9.1")
85
+ end
86
+
87
+ it "fetches gems when multiple versions are specified take 2" do
88
+ install_gemfile <<-G
89
+ source "file://#{gem_repo1}"
90
+ gem 'rack', "< 1.0", "> 0.9"
91
+ G
92
+
93
+ default_bundle_path("gems/rack-0.9.1").should exist
94
+ should_be_installed("rack 0.9.1")
95
+ end
96
+
97
+ it "raises an appropriate error when gems are specified using symbols" do
98
+ status = install_gemfile(<<-G, :exitstatus => true)
99
+ source "file://#{gem_repo1}"
100
+ gem :rack
101
+ G
102
+ status.should == 4
103
+ end
104
+
105
+ it "pulls in dependencies" do
106
+ install_gemfile <<-G
107
+ source "file://#{gem_repo1}"
108
+ gem "rails"
109
+ G
110
+
111
+ should_be_installed "actionpack 2.3.2", "rails 2.3.2"
112
+ end
113
+
114
+ it "does the right version" do
115
+ install_gemfile <<-G
116
+ source "file://#{gem_repo1}"
117
+ gem "rack", "0.9.1"
118
+ G
119
+
120
+ should_be_installed "rack 0.9.1"
121
+ end
122
+
123
+ it "does not install the development dependency" do
124
+ install_gemfile <<-G
125
+ source "file://#{gem_repo1}"
126
+ gem "with_development_dependency"
127
+ G
128
+
129
+ should_be_installed "with_development_dependency 1.0.0"
130
+ should_not_be_installed "activesupport 2.3.5"
131
+ end
132
+
133
+ it "resolves correctly" do
134
+ install_gemfile <<-G
135
+ source "file://#{gem_repo1}"
136
+ gem "activemerchant"
137
+ gem "rails"
138
+ G
139
+
140
+ should_be_installed "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
141
+ end
142
+
143
+ it "activates gem correctly according to the resolved gems" do
144
+ install_gemfile <<-G
145
+ source "file://#{gem_repo1}"
146
+ gem "activesupport", "2.3.5"
147
+ G
148
+
149
+ install_gemfile <<-G
150
+ source "file://#{gem_repo1}"
151
+ gem "activemerchant"
152
+ gem "rails"
153
+ G
154
+
155
+ should_be_installed "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
156
+ end
157
+
158
+ it "does not reinstall any gem that is already available locally" do
159
+ system_gems "activesupport-2.3.2"
160
+
161
+ build_repo2 do
162
+ build_gem "activesupport", "2.3.2" do |s|
163
+ s.write "lib/activesupport.rb", "ACTIVESUPPORT = 'fail'"
164
+ end
165
+ end
166
+
167
+ install_gemfile <<-G
168
+ source "file://#{gem_repo2}"
169
+ gem "activerecord", "2.3.2"
170
+ G
171
+
172
+ should_be_installed "activesupport 2.3.2"
173
+ end
174
+
175
+ it "works when the gemfile specifies gems that only exist in the system" do
176
+ build_gem "foo", :to_system => true
177
+ install_gemfile <<-G
178
+ source "file://#{gem_repo1}"
179
+ gem "rack"
180
+ gem "foo"
181
+ G
182
+
183
+ should_be_installed "rack 1.0.0", "foo 1.0.0"
184
+ end
185
+
186
+ it "prioritizes local gems over remote gems" do
187
+ build_gem 'rack', '1.0.0', :to_system => true do |s|
188
+ s.add_dependency "activesupport", "2.3.5"
189
+ end
190
+
191
+ install_gemfile <<-G
192
+ source "file://#{gem_repo1}"
193
+ gem "rack"
194
+ G
195
+
196
+ should_be_installed "rack 1.0.0", "activesupport 2.3.5"
197
+ end
198
+
199
+ describe "with a gem that installs multiple platforms" do
200
+ it "installs gems for the local platform as first choice" do
201
+ install_gemfile <<-G
202
+ source "file://#{gem_repo1}"
203
+ gem "platform_specific"
204
+ G
205
+
206
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
207
+ out.should == "1.0.0 #{Gem::Platform.local}"
208
+ end
209
+
210
+ it "falls back on plain ruby" do
211
+ simulate_platform "foo-bar-baz"
212
+ install_gemfile <<-G
213
+ source "file://#{gem_repo1}"
214
+ gem "platform_specific"
215
+ G
216
+
217
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
218
+ out.should == "1.0.0 RUBY"
219
+ end
220
+
221
+ it "installs gems for java" do
222
+ simulate_platform "java"
223
+ install_gemfile <<-G
224
+ source "file://#{gem_repo1}"
225
+ gem "platform_specific"
226
+ G
227
+
228
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
229
+ out.should == "1.0.0 JAVA"
230
+ end
231
+
232
+ it "installs gems for windows" do
233
+ simulate_platform mswin
234
+
235
+ install_gemfile <<-G
236
+ source "file://#{gem_repo1}"
237
+ gem "platform_specific"
238
+ G
239
+
240
+ run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
241
+ out.should == "1.0.0 MSWIN"
242
+ end
243
+ end
244
+
245
+ describe "doing bundle install foo" do
246
+ before do
247
+ gemfile <<-G
248
+ source "file://#{gem_repo1}"
249
+ gem "rack"
250
+ G
251
+ end
252
+
253
+ it "works" do
254
+ bundle "install --path vendor"
255
+ should_be_installed "rack 1.0"
256
+ end
257
+
258
+ it "allows running bundle install --system without deleting foo" do
259
+ bundle "install --path vendor"
260
+ bundle "install --system"
261
+ FileUtils.rm_rf(bundled_app("vendor"))
262
+ should_be_installed "rack 1.0"
263
+ end
264
+
265
+ it "allows running bundle install --system after deleting foo" do
266
+ bundle "install --path vendor"
267
+ FileUtils.rm_rf(bundled_app("vendor"))
268
+ bundle "install --system"
269
+ should_be_installed "rack 1.0"
270
+ end
271
+ end
272
+
273
+ it "finds gems in multiple sources" do
274
+ build_repo2
275
+ update_repo2
276
+
277
+ install_gemfile <<-G
278
+ source "file://#{gem_repo1}"
279
+ source "file://#{gem_repo2}"
280
+
281
+ gem "activesupport", "1.2.3"
282
+ gem "rack", "1.2"
283
+ G
284
+
285
+ should_be_installed "rack 1.2", "activesupport 1.2.3"
286
+ end
287
+
288
+ it "gives a useful error if no sources are set" do
289
+ install_gemfile <<-G
290
+ gem "rack"
291
+ G
292
+
293
+ bundle :install, :expect_err => true
294
+ out.should =~ /Your Gemfile doesn't have any sources/i
295
+ end
296
+ end
297
+
298
+ describe "when prerelease gems are available" do
299
+ it "finds prereleases" do
300
+ install_gemfile <<-G
301
+ source "file://#{gem_repo1}"
302
+ gem "not_released"
303
+ G
304
+ should_be_installed "not_released 1.0.pre"
305
+ end
306
+
307
+ it "uses regular releases if available" do
308
+ install_gemfile <<-G
309
+ source "file://#{gem_repo1}"
310
+ gem "has_prerelease"
311
+ G
312
+ should_be_installed "has_prerelease 1.0"
313
+ end
314
+
315
+ it "uses prereleases if requested" do
316
+ install_gemfile <<-G
317
+ source "file://#{gem_repo1}"
318
+ gem "has_prerelease", "1.1.pre"
319
+ G
320
+ should_be_installed "has_prerelease 1.1.pre"
321
+ end
322
+ end
323
+
324
+ describe "when prerelease gems are not available" do
325
+ it "still works" do
326
+ build_repo3
327
+ install_gemfile <<-G
328
+ source "file://#{gem_repo3}"
329
+ gem "rack"
330
+ G
331
+
332
+ should_be_installed "rack 1.0"
333
+ end
334
+ end
335
+
336
+ describe "when BUNDLE_PATH or the global path config is set" do
337
+ before :each do
338
+ build_lib "rack", "1.0.0", :to_system => true do |s|
339
+ s.write "lib/rack.rb", "raise 'FAIL'"
340
+ end
341
+
342
+ gemfile <<-G
343
+ source "file://#{gem_repo1}"
344
+ gem "rack"
345
+ G
346
+ end
347
+
348
+ def set_bundle_path(type, location)
349
+ if type == :env
350
+ ENV["BUNDLE_PATH"] = location
351
+ elsif type == :global
352
+ bundle "config path #{location}", "no-color" => nil
353
+ end
354
+ end
355
+
356
+ [:env, :global].each do |type|
357
+ it "installs gems to a path if one is specified" do
358
+ set_bundle_path(type, bundled_app("vendor2").to_s)
359
+ bundle "install --path vendor/bundle"
360
+
361
+ vendored_gems("gems/rack-1.0.0").should be_directory
362
+ bundled_app("vendor2").should_not be_directory
363
+ should_be_installed "rack 1.0.0"
364
+ end
365
+
366
+ it "installs gems to BUNDLE_PATH with #{type}" do
367
+ set_bundle_path(type, bundled_app("vendor").to_s)
368
+
369
+ bundle :install
370
+
371
+ bundled_app('vendor/gems/rack-1.0.0').should be_directory
372
+ should_be_installed "rack 1.0.0"
373
+ end
374
+
375
+ it "installs gems to BUNDLE_PATH relative to root when relative" do
376
+ set_bundle_path(type, "vendor")
377
+
378
+ FileUtils.mkdir_p bundled_app('lol')
379
+ Dir.chdir(bundled_app('lol')) do
380
+ bundle :install
381
+ end
382
+
383
+ bundled_app('vendor/gems/rack-1.0.0').should be_directory
384
+ should_be_installed "rack 1.0.0"
385
+ end
386
+ end
387
+
388
+ it "installs gems to BUNDLE_PATH from .bundle/config" do
389
+ config "BUNDLE_PATH" => bundled_app("vendor/bundle").to_s
390
+
391
+ bundle :install
392
+
393
+ vendored_gems('gems/rack-1.0.0').should be_directory
394
+ should_be_installed "rack 1.0.0"
395
+ end
396
+
397
+ it "sets BUNDLE_PATH as the first argument to bundle install" do
398
+ bundle "install --path ./vendor/bundle"
399
+
400
+ vendored_gems('gems/rack-1.0.0').should be_directory
401
+ should_be_installed "rack 1.0.0"
402
+ end
403
+
404
+ it "disables system gems when passing a path to install" do
405
+ # This is so that vendored gems can be distributed to others
406
+ build_gem "rack", "1.1.0", :to_system => true
407
+ bundle "install --path ./vendor/bundle"
408
+
409
+ vendored_gems('gems/rack-1.0.0').should be_directory
410
+ should_be_installed "rack 1.0.0"
411
+ end
412
+ end
413
+
414
+ describe "when passing in a Gemfile via --gemfile" do
415
+ it "finds the gemfile" do
416
+ gemfile bundled_app("NotGemfile"), <<-G
417
+ source "file://#{gem_repo1}"
418
+ gem 'rack'
419
+ G
420
+
421
+ bundle :install, :gemfile => bundled_app("NotGemfile")
422
+
423
+ ENV['BUNDLE_GEMFILE'] = "NotGemfile"
424
+ should_be_installed "rack 1.0.0"
425
+ end
426
+ end
427
+
428
+ describe "when requesting a quiet install via --quiet" do
429
+ it "should be quiet if there are no warnings" do
430
+ gemfile <<-G
431
+ source "file://#{gem_repo1}"
432
+ gem 'rack'
433
+ G
434
+
435
+ bundle :install, :quiet => true
436
+ out.should == ""
437
+ end
438
+
439
+ it "should still display warnings" do
440
+ gemfile <<-G
441
+ gem 'rack'
442
+ G
443
+
444
+ bundle :install, :quiet => true
445
+ out.should =~ /doesn't have any sources/
446
+ end
447
+ end
448
+
449
+ describe "when disabling system gems" do
450
+ before :each do
451
+ build_gem "rack", "1.0.0", :to_system => true do |s|
452
+ s.write "lib/rack.rb", "puts 'FAIL'"
453
+ end
454
+
455
+ gemfile <<-G
456
+ source "file://#{gem_repo1}"
457
+ gem "rack"
458
+ G
459
+ end
460
+
461
+ it "behaves like bundle install vendor/bundle with --deployment" do
462
+ bundle "install"
463
+ bundle "install --deployment"
464
+ out.should include("It was installed into ./vendor/bundle")
465
+ should_be_installed "rack 1.0.0"
466
+ bundled_app("vendor/bundle").should exist
467
+ end
468
+
469
+ it "prints a warning if you try to use --disable-shared-gems" do
470
+ bundle "install --path vendor --disable-shared-gems"
471
+ out.should include "The disable-shared-gem option is no longer available"
472
+ end
473
+
474
+ it "handles paths with regex characters in them" do
475
+ dir = bundled_app("bun++dle")
476
+ dir.mkpath
477
+
478
+ Dir.chdir(dir) do
479
+ bundle "install --path vendor/bundle"
480
+ out.should include("installed into ./vendor/bundle")
481
+ end
482
+
483
+ dir.rmtree
484
+ end
485
+
486
+ ["install vendor/bundle", "install --path vendor/bundle"].each do |install|
487
+ if install == "install vendor/bundle"
488
+ it "displays the deprecation warning for path as an argument to install" do
489
+ bundle install
490
+ out.should include("The path argument to `bundle install` is deprecated.")
491
+ end
492
+ end
493
+
494
+ it "does not use available system gems with bundle #{install}" do
495
+ bundle install
496
+ should_be_installed "rack 1.0.0"
497
+ end
498
+
499
+ it "prints a warning to let the user know what has happened with bundle #{install}" do
500
+ bundle install
501
+ out.should include("It was installed into ./vendor")
502
+ end
503
+
504
+ it "disallows #{install} --system" do
505
+ bundle "#{install} --system"
506
+ out.should include("Please choose.")
507
+ end
508
+
509
+ it "remembers to disable system gems after the first time with bundle #{install}" do
510
+ bundle install
511
+ FileUtils.rm_rf bundled_app('vendor')
512
+ bundle "install"
513
+
514
+ vendored_gems('gems/rack-1.0.0').should be_directory
515
+ should_be_installed "rack 1.0.0"
516
+ end
517
+ end
518
+ end
519
+
520
+ describe "when loading only the default group" do
521
+ it "should not load all groups" do
522
+ install_gemfile <<-G
523
+ source "file://#{gem_repo1}"
524
+ gem "rack"
525
+ gem "activesupport", :group => :development
526
+ G
527
+
528
+ ruby <<-R
529
+ require "bundler"
530
+ Bundler.setup :default
531
+ Bundler.require :default
532
+ puts RACK
533
+ begin
534
+ require "activesupport"
535
+ rescue LoadError
536
+ puts "no activesupport"
537
+ end
538
+ R
539
+
540
+ out.should include("1.0")
541
+ out.should include("no activesupport")
542
+ end
543
+ end
544
+
545
+ describe "when a gem has a YAML gemspec" do
546
+ before :each do
547
+ build_repo2 do
548
+ build_gem "yaml_spec", :gemspec => :yaml
549
+ end
550
+ end
551
+
552
+ it "still installs correctly" do
553
+ gemfile <<-G
554
+ source "file://#{gem_repo2}"
555
+ gem "yaml_spec"
556
+ G
557
+ bundle :install
558
+ err.should be_empty
559
+ end
560
+
561
+ it "still installs correctly when using path" do
562
+ build_lib 'yaml_spec', :gemspec => :yaml
563
+
564
+ install_gemfile <<-G
565
+ gem 'yaml_spec', :path => "#{lib_path('yaml_spec-1.0')}"
566
+ G
567
+ err.should == ""
568
+ end
569
+ end
570
+
571
+ describe "when the gem has an architecture in its platform" do
572
+ it "still installs correctly" do
573
+ simulate_platform mswin
574
+
575
+ gemfile <<-G
576
+ # Set up pretend http gem server with FakeWeb
577
+ $LOAD_PATH.unshift '#{Dir[base_system_gems.join("gems/fakeweb*/lib")].first}'
578
+ require 'fakeweb'
579
+ FakeWeb.allow_net_connect = false
580
+ files = [ 'specs.4.8.gz',
581
+ 'prerelease_specs.4.8.gz',
582
+ 'quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz',
583
+ 'gems/rcov-1.0-mswin32.gem' ]
584
+ files.each do |file|
585
+ FakeWeb.register_uri(:get, "http://localgemserver.com/\#{file}",
586
+ :body => File.read("#{gem_repo1}/\#{file}"))
587
+ end
588
+ FakeWeb.register_uri(:get, "http://localgemserver.com/gems/rcov-1.0-x86-mswin32.gem",
589
+ :status => ["404", "Not Found"])
590
+
591
+ # Try to install gem with nil arch
592
+ source "http://localgemserver.com/"
593
+ gem "rcov"
594
+ G
595
+ bundle :install
596
+ should_be_installed "rcov 1.0.0"
597
+ end
598
+ end
599
+
600
+ describe "bundler dependencies" do
601
+ before(:each) do
602
+ build_repo2 do
603
+ build_gem "rails", "3.0" do |s|
604
+ s.add_dependency "bundler", ">= 0.9.0.pre"
605
+ end
606
+ build_gem "bundler", "0.9.1"
607
+ build_gem "bundler", Bundler::VERSION
608
+ end
609
+ end
610
+
611
+ it "are forced to the current bundler version" do
612
+ install_gemfile <<-G
613
+ source "file://#{gem_repo2}"
614
+ gem "rails", "3.0"
615
+ G
616
+
617
+ should_be_installed "bundler #{Bundler::VERSION}"
618
+ end
619
+
620
+ it "are not added if not already present" do
621
+ install_gemfile <<-G
622
+ source "file://#{gem_repo1}"
623
+ gem "rack"
624
+ G
625
+ should_not_be_installed "bundler #{Bundler::VERSION}"
626
+ end
627
+
628
+ it "causes a conflict if explicitly requesting a different version" do
629
+ install_gemfile <<-G
630
+ source "file://#{gem_repo2}"
631
+ gem "rails", "3.0"
632
+ gem "bundler", "0.9.2"
633
+ G
634
+
635
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
636
+ Fetching source index for file:#{gem_repo2}/
637
+ Bundler could not find compatible versions for gem "bundler":
638
+ In Gemfile:
639
+ bundler (= 0.9.2) ruby
640
+
641
+ Current Bundler version:
642
+ bundler (#{Bundler::VERSION})
643
+ E
644
+ out.should include(nice_error)
645
+ end
646
+
647
+ it "works for gems with multiple versions in its dependencies" do
648
+ install_gemfile <<-G
649
+ source "file://#{gem_repo2}"
650
+
651
+ gem "multiple_versioned_deps"
652
+ G
653
+
654
+
655
+ install_gemfile <<-G
656
+ source "file://#{gem_repo2}"
657
+
658
+ gem "multiple_versioned_deps"
659
+ gem "rack"
660
+ G
661
+
662
+ should_be_installed "multiple_versioned_deps 1.0.0"
663
+ end
664
+
665
+ it "includes bundler in the bundle when it's a child dependency" do
666
+ install_gemfile <<-G
667
+ source "file://#{gem_repo2}"
668
+ gem "rails", "3.0"
669
+ G
670
+
671
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError; puts 'FAIL'; end"
672
+ out.should == "WIN"
673
+ end
674
+
675
+ it "allows gem 'bundler' when Bundler is not in the Gemfile or its dependencies" do
676
+ install_gemfile <<-G
677
+ source "file://#{gem_repo2}"
678
+ gem "rack"
679
+ G
680
+
681
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError => e; puts e.backtrace; end"
682
+ out.should == "WIN"
683
+ end
684
+
685
+ it "causes a conflict if child dependencies conflict" do
686
+ install_gemfile <<-G
687
+ source "file://#{gem_repo2}"
688
+ gem "activemerchant"
689
+ gem "rails_fail"
690
+ G
691
+
692
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
693
+ Fetching source index for file:#{gem_repo2}/
694
+ Bundler could not find compatible versions for gem "activesupport":
695
+ In Gemfile:
696
+ activemerchant (>= 0) ruby depends on
697
+ activesupport (>= 2.0.0) ruby
698
+
699
+ rails_fail (>= 0) ruby depends on
700
+ activesupport (1.2.3)
701
+ E
702
+ out.should == nice_error
703
+ end
704
+
705
+ it "causes a conflict if a child dependency conflicts with the Gemfile" do
706
+ install_gemfile <<-G
707
+ source "file://#{gem_repo2}"
708
+ gem "rails_fail"
709
+ gem "activesupport", "2.3.5"
710
+ G
711
+
712
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
713
+ Fetching source index for file:#{gem_repo2}/
714
+ Bundler could not find compatible versions for gem "activesupport":
715
+ In Gemfile:
716
+ rails_fail (>= 0) ruby depends on
717
+ activesupport (= 1.2.3) ruby
718
+
719
+ activesupport (2.3.5)
720
+ E
721
+ out.should == nice_error
722
+ end
723
+
724
+ it "can install dependencies even if " do
725
+ install_gemfile <<-G
726
+ source "file://#{gem_repo2}"
727
+ gem "rails", "3.0"
728
+ G
729
+
730
+ simulate_bundler_version "10.0.0"
731
+ #simulate_new_machine
732
+
733
+ bundle "check"
734
+ out.should == "The Gemfile's dependencies are satisfied"
735
+ end
736
+ end
737
+
738
+ describe "when locked and installed with --without" do
739
+ before(:each) do
740
+ build_repo2
741
+ system_gems "rack-0.9.1" do
742
+ install_gemfile <<-G, :without => :rack
743
+ source "file://#{gem_repo2}"
744
+ gem "rack"
745
+
746
+ group :rack do
747
+ gem "rack_middleware"
748
+ end
749
+ G
750
+ end
751
+ end
752
+
753
+ it "uses the correct versions even if --without was used on the original" do
754
+ should_be_installed "rack 0.9.1"
755
+ should_not_be_installed "rack_middleware 1.0"
756
+ simulate_new_machine
757
+
758
+ bundle :install
759
+
760
+ should_be_installed "rack 0.9.1"
761
+ should_be_installed "rack_middleware 1.0"
762
+ end
763
+
764
+ it "does not hit the remote a second time" do
765
+ FileUtils.rm_rf gem_repo2
766
+ bundle "install --without rack"
767
+ err.should be_empty
768
+ end
769
+ end
770
+ end