bundler_package_git 1.1.pre.1

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 (149) hide show
  1. data/.gitignore +22 -0
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG.md +659 -0
  4. data/ISSUES.md +47 -0
  5. data/LICENSE +23 -0
  6. data/README.md +29 -0
  7. data/Rakefile +167 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +22 -0
  10. data/bundler.gemspec +30 -0
  11. data/lib/bundler.rb +283 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +490 -0
  14. data/lib/bundler/definition.rb +429 -0
  15. data/lib/bundler/dependency.rb +130 -0
  16. data/lib/bundler/deployment.rb +53 -0
  17. data/lib/bundler/dsl.rb +243 -0
  18. data/lib/bundler/environment.rb +47 -0
  19. data/lib/bundler/fetcher.rb +101 -0
  20. data/lib/bundler/gem_helper.rb +146 -0
  21. data/lib/bundler/graph.rb +130 -0
  22. data/lib/bundler/index.rb +131 -0
  23. data/lib/bundler/installer.rb +117 -0
  24. data/lib/bundler/lazy_specification.rb +71 -0
  25. data/lib/bundler/lockfile_parser.rb +108 -0
  26. data/lib/bundler/remote_specification.rb +57 -0
  27. data/lib/bundler/resolver.rb +470 -0
  28. data/lib/bundler/rubygems_ext.rb +226 -0
  29. data/lib/bundler/runtime.rb +201 -0
  30. data/lib/bundler/settings.rb +117 -0
  31. data/lib/bundler/setup.rb +16 -0
  32. data/lib/bundler/shared_helpers.rb +167 -0
  33. data/lib/bundler/source.rb +675 -0
  34. data/lib/bundler/spec_set.rb +134 -0
  35. data/lib/bundler/templates/Executable +16 -0
  36. data/lib/bundler/templates/Gemfile +4 -0
  37. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  38. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  39. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  40. data/lib/bundler/templates/newgem/gitignore.tt +4 -0
  41. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
  42. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  43. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
  44. data/lib/bundler/ui.rb +73 -0
  45. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  46. data/lib/bundler/vendor/net/http/persistent.rb +464 -0
  47. data/lib/bundler/vendor/thor.rb +319 -0
  48. data/lib/bundler/vendor/thor/actions.rb +297 -0
  49. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  50. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  51. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  52. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
  53. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
  54. data/lib/bundler/vendor/thor/base.rb +556 -0
  55. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  56. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  57. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  58. data/lib/bundler/vendor/thor/error.rb +30 -0
  59. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  60. data/lib/bundler/vendor/thor/parser.rb +4 -0
  61. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  62. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  63. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  64. data/lib/bundler/vendor/thor/parser/options.rb +174 -0
  65. data/lib/bundler/vendor/thor/shell.rb +88 -0
  66. data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
  67. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  68. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  69. data/lib/bundler/vendor/thor/task.rb +114 -0
  70. data/lib/bundler/vendor/thor/util.rb +229 -0
  71. data/lib/bundler/vendor/thor/version.rb +3 -0
  72. data/lib/bundler/version.rb +6 -0
  73. data/lib/bundler/vlad.rb +9 -0
  74. data/man/bundle-config.ronn +90 -0
  75. data/man/bundle-exec.ronn +111 -0
  76. data/man/bundle-install.ronn +314 -0
  77. data/man/bundle-package.ronn +59 -0
  78. data/man/bundle-update.ronn +176 -0
  79. data/man/bundle.ronn +80 -0
  80. data/man/gemfile.5.ronn +279 -0
  81. data/man/index.txt +6 -0
  82. data/spec/cache/gems_spec.rb +219 -0
  83. data/spec/cache/git_spec.rb +9 -0
  84. data/spec/cache/path_spec.rb +27 -0
  85. data/spec/cache/platform_spec.rb +57 -0
  86. data/spec/install/deploy_spec.rb +197 -0
  87. data/spec/install/deprecated_spec.rb +37 -0
  88. data/spec/install/gems/c_ext_spec.rb +48 -0
  89. data/spec/install/gems/dependency_api_spec.rb +85 -0
  90. data/spec/install/gems/env_spec.rb +107 -0
  91. data/spec/install/gems/flex_spec.rb +313 -0
  92. data/spec/install/gems/groups_spec.rb +245 -0
  93. data/spec/install/gems/packed_spec.rb +84 -0
  94. data/spec/install/gems/platform_spec.rb +208 -0
  95. data/spec/install/gems/resolving_spec.rb +72 -0
  96. data/spec/install/gems/simple_case_spec.rb +715 -0
  97. data/spec/install/gems/standalone_spec.rb +162 -0
  98. data/spec/install/gems/sudo_spec.rb +73 -0
  99. data/spec/install/gems/win32_spec.rb +26 -0
  100. data/spec/install/gemspec_spec.rb +108 -0
  101. data/spec/install/git_spec.rb +571 -0
  102. data/spec/install/invalid_spec.rb +17 -0
  103. data/spec/install/path_spec.rb +353 -0
  104. data/spec/install/upgrade_spec.rb +26 -0
  105. data/spec/lock/git_spec.rb +35 -0
  106. data/spec/lock/lockfile_spec.rb +683 -0
  107. data/spec/other/check_spec.rb +221 -0
  108. data/spec/other/clean_spec.rb +202 -0
  109. data/spec/other/config_spec.rb +40 -0
  110. data/spec/other/console_spec.rb +54 -0
  111. data/spec/other/exec_spec.rb +241 -0
  112. data/spec/other/ext_spec.rb +16 -0
  113. data/spec/other/gem_helper_spec.rb +128 -0
  114. data/spec/other/help_spec.rb +38 -0
  115. data/spec/other/init_spec.rb +40 -0
  116. data/spec/other/newgem_spec.rb +24 -0
  117. data/spec/other/open_spec.rb +35 -0
  118. data/spec/other/show_spec.rb +82 -0
  119. data/spec/pack/gems_spec.rb +54 -0
  120. data/spec/quality_spec.rb +58 -0
  121. data/spec/resolver/basic_spec.rb +20 -0
  122. data/spec/resolver/platform_spec.rb +82 -0
  123. data/spec/runtime/executable_spec.rb +110 -0
  124. data/spec/runtime/load_spec.rb +107 -0
  125. data/spec/runtime/platform_spec.rb +90 -0
  126. data/spec/runtime/require_spec.rb +231 -0
  127. data/spec/runtime/setup_spec.rb +688 -0
  128. data/spec/runtime/with_clean_env_spec.rb +15 -0
  129. data/spec/spec_helper.rb +85 -0
  130. data/spec/support/artifice/endpoint.rb +50 -0
  131. data/spec/support/artifice/endpoint_fallback.rb +22 -0
  132. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  133. data/spec/support/artifice/endpoint_redirect.rb +11 -0
  134. data/spec/support/builders.rb +574 -0
  135. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  136. data/spec/support/fakeweb/windows.rb +23 -0
  137. data/spec/support/helpers.rb +246 -0
  138. data/spec/support/indexes.rb +112 -0
  139. data/spec/support/matchers.rb +89 -0
  140. data/spec/support/path.rb +73 -0
  141. data/spec/support/platforms.rb +53 -0
  142. data/spec/support/ruby_ext.rb +20 -0
  143. data/spec/support/rubygems_ext.rb +35 -0
  144. data/spec/support/rubygems_hax/platform.rb +11 -0
  145. data/spec/support/sudo.rb +21 -0
  146. data/spec/update/gems_spec.rb +121 -0
  147. data/spec/update/git_spec.rb +196 -0
  148. data/spec/update/source_spec.rb +51 -0
  149. metadata +294 -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,715 @@
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 "does not use available system gems with bundle --path vendor/bundle" do
470
+ bundle "install --path vendor/bundle"
471
+ should_be_installed "rack 1.0.0"
472
+ end
473
+
474
+ it "prints a warning to let the user know what has happened with bundle --path vendor/bundle" do
475
+ bundle "install --path vendor/bundle"
476
+ out.should include("It was installed into ./vendor")
477
+ end
478
+
479
+ it "disallows --path vendor/bundle --system" do
480
+ bundle "install --path vendor/bundle --system"
481
+ out.should include("Please choose.")
482
+ end
483
+
484
+ it "remembers to disable system gems after the first time with bundle --path vendor/bundle" do
485
+ bundle "install --path vendor/bundle"
486
+ FileUtils.rm_rf bundled_app('vendor')
487
+ bundle "install"
488
+
489
+ vendored_gems('gems/rack-1.0.0').should be_directory
490
+ should_be_installed "rack 1.0.0"
491
+ end
492
+ end
493
+
494
+ describe "when loading only the default group" do
495
+ it "should not load all groups" do
496
+ install_gemfile <<-G
497
+ source "file://#{gem_repo1}"
498
+ gem "rack"
499
+ gem "activesupport", :groups => :development
500
+ G
501
+
502
+ ruby <<-R
503
+ require "bundler"
504
+ Bundler.setup :default
505
+ Bundler.require :default
506
+ puts RACK
507
+ begin
508
+ require "activesupport"
509
+ rescue LoadError
510
+ puts "no activesupport"
511
+ end
512
+ R
513
+
514
+ out.should include("1.0")
515
+ out.should include("no activesupport")
516
+ end
517
+ end
518
+
519
+ describe "when a gem has a YAML gemspec" do
520
+ before :each do
521
+ build_repo2 do
522
+ build_gem "yaml_spec", :gemspec => :yaml
523
+ end
524
+ end
525
+
526
+ it "still installs correctly" do
527
+ gemfile <<-G
528
+ source "file://#{gem_repo2}"
529
+ gem "yaml_spec"
530
+ G
531
+ bundle :install
532
+ err.should be_empty
533
+ end
534
+
535
+ it "still installs correctly when using path" do
536
+ build_lib 'yaml_spec', :gemspec => :yaml
537
+
538
+ install_gemfile <<-G
539
+ gem 'yaml_spec', :path => "#{lib_path('yaml_spec-1.0')}"
540
+ G
541
+ err.should == ""
542
+ end
543
+ end
544
+
545
+ describe "bundler dependencies" do
546
+ before(:each) do
547
+ build_repo2 do
548
+ build_gem "rails", "3.0" do |s|
549
+ s.add_dependency "bundler", ">= 0.9.0.pre"
550
+ end
551
+ build_gem "bundler", "0.9.1"
552
+ build_gem "bundler", Bundler::VERSION
553
+ end
554
+ end
555
+
556
+ it "are forced to the current bundler version" do
557
+ install_gemfile <<-G
558
+ source "file://#{gem_repo2}"
559
+ gem "rails", "3.0"
560
+ G
561
+
562
+ should_be_installed "bundler #{Bundler::VERSION}"
563
+ end
564
+
565
+ it "are not added if not already present" do
566
+ install_gemfile <<-G
567
+ source "file://#{gem_repo1}"
568
+ gem "rack"
569
+ G
570
+ should_not_be_installed "bundler #{Bundler::VERSION}"
571
+ end
572
+
573
+ it "causes a conflict if explicitly requesting a different version" do
574
+ install_gemfile <<-G
575
+ source "file://#{gem_repo2}"
576
+ gem "rails", "3.0"
577
+ gem "bundler", "0.9.2"
578
+ G
579
+
580
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
581
+ Fetching source index for file:#{gem_repo2}/
582
+ Bundler could not find compatible versions for gem "bundler":
583
+ In Gemfile:
584
+ bundler (= 0.9.2)
585
+
586
+ Current Bundler version:
587
+ bundler (#{Bundler::VERSION})
588
+ E
589
+ out.should == nice_error
590
+ end
591
+
592
+ it "works for gems with multiple versions in its dependencies" do
593
+ install_gemfile <<-G
594
+ source "file://#{gem_repo2}"
595
+
596
+ gem "multiple_versioned_deps"
597
+ G
598
+
599
+
600
+ install_gemfile <<-G
601
+ source "file://#{gem_repo2}"
602
+
603
+ gem "multiple_versioned_deps"
604
+ gem "rack"
605
+ G
606
+
607
+ should_be_installed "multiple_versioned_deps 1.0.0"
608
+ end
609
+
610
+ it "includes bundler in the bundle when it's a child dependency" do
611
+ install_gemfile <<-G
612
+ source "file://#{gem_repo2}"
613
+ gem "rails", "3.0"
614
+ G
615
+
616
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError; puts 'FAIL'; end"
617
+ out.should == "WIN"
618
+ end
619
+
620
+ it "allows gem 'bundler' when Bundler is not in the Gemfile or its dependencies" do
621
+ install_gemfile <<-G
622
+ source "file://#{gem_repo2}"
623
+ gem "rack"
624
+ G
625
+
626
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError => e; puts e.backtrace; end"
627
+ out.should == "WIN"
628
+ end
629
+
630
+ it "causes a conflict if child dependencies conflict" do
631
+ install_gemfile <<-G
632
+ source "file://#{gem_repo2}"
633
+ gem "activemerchant"
634
+ gem "rails_fail"
635
+ G
636
+
637
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
638
+ Fetching source index for file:#{gem_repo2}/
639
+ Bundler could not find compatible versions for gem "activesupport":
640
+ In Gemfile:
641
+ activemerchant depends on
642
+ activesupport (>= 2.0.0)
643
+
644
+ rails_fail depends on
645
+ activesupport (1.2.3)
646
+ E
647
+ out.should == nice_error
648
+ end
649
+
650
+ it "causes a conflict if a child dependency conflicts with the Gemfile" do
651
+ install_gemfile <<-G
652
+ source "file://#{gem_repo2}"
653
+ gem "rails_fail"
654
+ gem "activesupport", "2.3.5"
655
+ G
656
+
657
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
658
+ Fetching source index for file:#{gem_repo2}/
659
+ Bundler could not find compatible versions for gem "activesupport":
660
+ In Gemfile:
661
+ rails_fail depends on
662
+ activesupport (= 1.2.3)
663
+
664
+ activesupport (2.3.5)
665
+ E
666
+ out.should == nice_error
667
+ end
668
+
669
+ it "can install dependencies even if " do
670
+ install_gemfile <<-G
671
+ source "file://#{gem_repo2}"
672
+ gem "rails", "3.0"
673
+ G
674
+
675
+ simulate_bundler_version "10.0.0"
676
+ #simulate_new_machine
677
+
678
+ bundle "check"
679
+ out.should == "The Gemfile's dependencies are satisfied"
680
+ end
681
+ end
682
+
683
+ describe "when locked and installed with --without" do
684
+ before(:each) do
685
+ build_repo2
686
+ system_gems "rack-0.9.1" do
687
+ install_gemfile <<-G, :without => :rack
688
+ source "file://#{gem_repo2}"
689
+ gem "rack"
690
+
691
+ group :rack do
692
+ gem "rack_middleware"
693
+ end
694
+ G
695
+ end
696
+ end
697
+
698
+ it "uses the correct versions even if --without was used on the original" do
699
+ should_be_installed "rack 0.9.1"
700
+ should_not_be_installed "rack_middleware 1.0"
701
+ simulate_new_machine
702
+
703
+ bundle :install
704
+
705
+ should_be_installed "rack 0.9.1"
706
+ should_be_installed "rack_middleware 1.0"
707
+ end
708
+
709
+ it "does not hit the remote a second time" do
710
+ FileUtils.rm_rf gem_repo2
711
+ bundle "install --without rack"
712
+ err.should be_empty
713
+ end
714
+ end
715
+ end