bundler 1.7.15 → 1.8.0.pre

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 (191) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -14
  3. data/.rspec +1 -0
  4. data/.travis.yml +22 -15
  5. data/CHANGELOG.md +43 -13
  6. data/CODE_OF_CONDUCT.md +40 -0
  7. data/CONTRIBUTING.md +14 -12
  8. data/DEVELOPMENT.md +4 -2
  9. data/ISSUES.md +1 -1
  10. data/README.md +10 -14
  11. data/Rakefile +10 -10
  12. data/bin/bundle +1 -1
  13. data/bundler.gemspec +5 -4
  14. data/lib/bundler.rb +22 -3
  15. data/lib/bundler/anonymizable_uri.rb +24 -8
  16. data/lib/bundler/cli.rb +103 -66
  17. data/lib/bundler/cli/cache.rb +1 -0
  18. data/lib/bundler/cli/clean.rb +11 -4
  19. data/lib/bundler/cli/common.rb +2 -0
  20. data/lib/bundler/cli/console.rb +22 -26
  21. data/lib/bundler/cli/exec.rb +29 -22
  22. data/lib/bundler/cli/gem.rb +125 -37
  23. data/lib/bundler/cli/install.rb +22 -9
  24. data/lib/bundler/cli/outdated.rb +1 -1
  25. data/lib/bundler/cli/package.rb +8 -1
  26. data/lib/bundler/cli/show.rb +29 -3
  27. data/lib/bundler/cli/update.rb +2 -2
  28. data/lib/bundler/cli/viz.rb +1 -1
  29. data/lib/bundler/definition.rb +14 -22
  30. data/lib/bundler/dependency.rb +8 -1
  31. data/lib/bundler/dsl.rb +17 -4
  32. data/lib/bundler/endpoint_specification.rb +1 -1
  33. data/lib/bundler/env.rb +44 -25
  34. data/lib/bundler/fetcher.rb +33 -25
  35. data/lib/bundler/friendly_errors.rb +38 -5
  36. data/lib/bundler/gem_helper.rb +16 -10
  37. data/lib/bundler/gem_helpers.rb +1 -0
  38. data/lib/bundler/graph.rb +4 -1
  39. data/lib/bundler/index.rb +15 -25
  40. data/lib/bundler/installer.rb +6 -6
  41. data/lib/bundler/lockfile_parser.rb +7 -7
  42. data/lib/bundler/resolver.rb +2 -1
  43. data/lib/bundler/ruby_version.rb +1 -1
  44. data/lib/bundler/rubygems_ext.rb +1 -0
  45. data/lib/bundler/rubygems_integration.rb +1 -1
  46. data/lib/bundler/runtime.rb +22 -40
  47. data/lib/bundler/settings.rb +14 -5
  48. data/lib/bundler/setup.rb +2 -1
  49. data/lib/bundler/shared_helpers.rb +56 -4
  50. data/lib/bundler/source.rb +8 -9
  51. data/lib/bundler/source/git.rb +5 -1
  52. data/lib/bundler/source/git/git_proxy.rb +4 -0
  53. data/lib/bundler/source/path.rb +8 -11
  54. data/lib/bundler/source/path/installer.rb +0 -2
  55. data/lib/bundler/source/rubygems.rb +58 -72
  56. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +13 -0
  57. data/lib/bundler/templates/newgem/LICENSE.txt.tt +17 -18
  58. data/lib/bundler/templates/newgem/README.md.tt +9 -1
  59. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  60. data/lib/bundler/templates/newgem/bin/console.tt +14 -0
  61. data/lib/bundler/templates/newgem/bin/setup.tt +7 -0
  62. data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  63. data/lib/bundler/templates/newgem/gitignore.tt +2 -0
  64. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +1 -1
  65. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -13
  66. data/lib/bundler/templates/newgem/test/test_newgem.rb.tt +1 -1
  67. data/lib/bundler/ui/shell.rb +1 -1
  68. data/lib/bundler/version.rb +1 -1
  69. data/lib/bundler/worker.rb +73 -0
  70. data/man/bundle-config.ronn +17 -15
  71. data/man/bundle-install.ronn +102 -93
  72. data/man/bundle-update.ronn +39 -30
  73. data/man/bundle.ronn +6 -0
  74. data/man/gemfile.5.ronn +74 -13
  75. metadata +10 -231
  76. data/lib/bundler/parallel_workers.rb +0 -18
  77. data/lib/bundler/parallel_workers/thread_worker.rb +0 -30
  78. data/lib/bundler/parallel_workers/unix_worker.rb +0 -101
  79. data/lib/bundler/parallel_workers/worker.rb +0 -69
  80. data/lib/bundler/templates/newgem/bin/newgem.tt +0 -3
  81. data/spec/bundler/anonymizable_uri_spec.rb +0 -32
  82. data/spec/bundler/bundler_spec.rb +0 -72
  83. data/spec/bundler/cli_spec.rb +0 -16
  84. data/spec/bundler/definition_spec.rb +0 -22
  85. data/spec/bundler/dsl_spec.rb +0 -82
  86. data/spec/bundler/friendly_errors_spec.rb +0 -13
  87. data/spec/bundler/gem_helper_spec.rb +0 -226
  88. data/spec/bundler/psyched_yaml_spec.rb +0 -8
  89. data/spec/bundler/retry_spec.rb +0 -59
  90. data/spec/bundler/settings_spec.rb +0 -13
  91. data/spec/bundler/source/rubygems_spec.rb +0 -25
  92. data/spec/bundler/source_list_spec.rb +0 -361
  93. data/spec/cache/gems_spec.rb +0 -284
  94. data/spec/cache/git_spec.rb +0 -188
  95. data/spec/cache/path_spec.rb +0 -121
  96. data/spec/cache/platform_spec.rb +0 -57
  97. data/spec/commands/binstubs_spec.rb +0 -219
  98. data/spec/commands/check_spec.rb +0 -278
  99. data/spec/commands/clean_spec.rb +0 -592
  100. data/spec/commands/config_spec.rb +0 -263
  101. data/spec/commands/console_spec.rb +0 -76
  102. data/spec/commands/exec_spec.rb +0 -309
  103. data/spec/commands/help_spec.rb +0 -39
  104. data/spec/commands/init_spec.rb +0 -39
  105. data/spec/commands/inject_spec.rb +0 -78
  106. data/spec/commands/licenses_spec.rb +0 -18
  107. data/spec/commands/newgem_spec.rb +0 -428
  108. data/spec/commands/open_spec.rb +0 -68
  109. data/spec/commands/outdated_spec.rb +0 -156
  110. data/spec/commands/package_spec.rb +0 -114
  111. data/spec/commands/show_spec.rb +0 -125
  112. data/spec/install/binstubs_spec.rb +0 -24
  113. data/spec/install/bundler_spec.rb +0 -146
  114. data/spec/install/deploy_spec.rb +0 -250
  115. data/spec/install/gemfile/gemspec_spec.rb +0 -170
  116. data/spec/install/gemfile/git_spec.rb +0 -967
  117. data/spec/install/gemfile/path_spec.rb +0 -500
  118. data/spec/install/gemfile_spec.rb +0 -44
  119. data/spec/install/gems/c_ext_spec.rb +0 -48
  120. data/spec/install/gems/dependency_api_spec.rb +0 -652
  121. data/spec/install/gems/env_spec.rb +0 -107
  122. data/spec/install/gems/flex_spec.rb +0 -314
  123. data/spec/install/gems/groups_spec.rb +0 -308
  124. data/spec/install/gems/mirror_spec.rb +0 -39
  125. data/spec/install/gems/platform_spec.rb +0 -195
  126. data/spec/install/gems/post_install_spec.rb +0 -121
  127. data/spec/install/gems/resolving_spec.rb +0 -124
  128. data/spec/install/gems/simple_case_spec.rb +0 -377
  129. data/spec/install/gems/sources_spec.rb +0 -386
  130. data/spec/install/gems/standalone_spec.rb +0 -260
  131. data/spec/install/gems/sudo_spec.rb +0 -136
  132. data/spec/install/gems/win32_spec.rb +0 -26
  133. data/spec/install/gemspecs_spec.rb +0 -50
  134. data/spec/install/path_spec.rb +0 -150
  135. data/spec/install/post_bundle_message_spec.rb +0 -142
  136. data/spec/install/prereleases_spec.rb +0 -43
  137. data/spec/install/security_policy_spec.rb +0 -77
  138. data/spec/install/upgrade_spec.rb +0 -26
  139. data/spec/lock/git_spec.rb +0 -34
  140. data/spec/lock/lockfile_spec.rb +0 -924
  141. data/spec/other/bundle_ruby_spec.rb +0 -142
  142. data/spec/other/cli_dispatch_spec.rb +0 -21
  143. data/spec/other/ext_spec.rb +0 -60
  144. data/spec/other/platform_spec.rb +0 -1285
  145. data/spec/other/ssl_cert_spec.rb +0 -23
  146. data/spec/quality_spec.rb +0 -88
  147. data/spec/realworld/dependency_api_spec.rb +0 -60
  148. data/spec/realworld/edgecases_spec.rb +0 -212
  149. data/spec/realworld/parallel_spec.rb +0 -71
  150. data/spec/resolver/basic_spec.rb +0 -66
  151. data/spec/resolver/platform_spec.rb +0 -88
  152. data/spec/runtime/executable_spec.rb +0 -149
  153. data/spec/runtime/load_spec.rb +0 -107
  154. data/spec/runtime/platform_spec.rb +0 -90
  155. data/spec/runtime/require_spec.rb +0 -332
  156. data/spec/runtime/setup_spec.rb +0 -853
  157. data/spec/runtime/with_clean_env_spec.rb +0 -91
  158. data/spec/spec_helper.rb +0 -123
  159. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +0 -13
  160. data/spec/support/artifice/endpoint.rb +0 -71
  161. data/spec/support/artifice/endpoint_500.rb +0 -37
  162. data/spec/support/artifice/endpoint_api_forbidden.rb +0 -11
  163. data/spec/support/artifice/endpoint_api_missing.rb +0 -16
  164. data/spec/support/artifice/endpoint_basic_authentication.rb +0 -13
  165. data/spec/support/artifice/endpoint_creds_diff_host.rb +0 -38
  166. data/spec/support/artifice/endpoint_extra.rb +0 -31
  167. data/spec/support/artifice/endpoint_extra_api.rb +0 -32
  168. data/spec/support/artifice/endpoint_extra_missing.rb +0 -15
  169. data/spec/support/artifice/endpoint_fallback.rb +0 -17
  170. data/spec/support/artifice/endpoint_host_redirect.rb +0 -15
  171. data/spec/support/artifice/endpoint_marshal_fail.rb +0 -11
  172. data/spec/support/artifice/endpoint_redirect.rb +0 -15
  173. data/spec/support/artifice/endpoint_strict_basic_authentication.rb +0 -18
  174. data/spec/support/artifice/endpoint_timeout.rb +0 -13
  175. data/spec/support/builders.rb +0 -693
  176. data/spec/support/fakeweb/rack-1.0.0.marshal +0 -2
  177. data/spec/support/fakeweb/windows.rb +0 -23
  178. data/spec/support/hax.rb +0 -22
  179. data/spec/support/helpers.rb +0 -361
  180. data/spec/support/indexes.rb +0 -280
  181. data/spec/support/matchers.rb +0 -77
  182. data/spec/support/path.rb +0 -85
  183. data/spec/support/permissions.rb +0 -10
  184. data/spec/support/platforms.rb +0 -94
  185. data/spec/support/ruby_ext.rb +0 -20
  186. data/spec/support/rubygems_ext.rb +0 -39
  187. data/spec/support/streams.rb +0 -13
  188. data/spec/support/sudo.rb +0 -16
  189. data/spec/update/gems_spec.rb +0 -201
  190. data/spec/update/git_spec.rb +0 -283
  191. data/spec/update/path_spec.rb +0 -18
@@ -1,377 +0,0 @@
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
- expect(out).to match(/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
- expect(err).to match(/FAIL \(StandardError\)/)
20
- expect(bundled_app("Gemfile.lock")).not_to 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
- expect(bundled_app('Gemfile.lock')).to 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
- expect(bundled_app("OmgFile.lock")).to 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
- expect(File.read(bundled_app("Gemfile.lock"))).to eq(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
- expect { run '1' }.not_to 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
- expect(default_bundle_path("gems/rack-1.0.0")).to 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
- expect(default_bundle_path("gems/rack-0.9.1")).to 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
- expect(default_bundle_path("gems/rack-0.9.1")).to 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
- expect(status).to eq(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
- expect(out).to eq("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
- expect(out).to eq("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
- expect(out).to eq("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
- expect(out).to eq("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
- expect(out).to include("Your Gemfile has no gem server sources")
295
- end
296
-
297
- it "creates a Gemfile.lock on a blank Gemfile" do
298
- install_gemfile <<-G
299
- G
300
-
301
- expect(File.exist?(bundled_app("Gemfile.lock"))).to eq(true)
302
- end
303
-
304
- it "gracefully handles error when rubygems server is unavailable" do
305
- install_gemfile <<-G
306
- source "file://#{gem_repo1}"
307
- source "http://localhost:9384"
308
-
309
- gem 'foo'
310
- G
311
-
312
- bundle :install
313
- expect(out).to include("Could not fetch specs from http://localhost:9384/")
314
- expect(out).not_to include("file://")
315
- end
316
-
317
- it "doesn't blow up when the local .bundle/config is empty" do
318
- FileUtils.mkdir_p(bundled_app(".bundle"))
319
- FileUtils.touch(bundled_app(".bundle/config"))
320
-
321
- install_gemfile(<<-G, :exitstatus => true)
322
- source "file://#{gem_repo1}"
323
-
324
- gem 'foo'
325
- G
326
- expect(exitstatus).to eq(0)
327
- end
328
-
329
- it "doesn't blow up when the global .bundle/config is empty" do
330
- FileUtils.mkdir_p("#{Bundler.rubygems.user_home}/.bundle")
331
- FileUtils.touch("#{Bundler.rubygems.user_home}/.bundle/config")
332
-
333
- install_gemfile(<<-G, :exitstatus => true)
334
- source "file://#{gem_repo1}"
335
-
336
- gem 'foo'
337
- G
338
- expect(exitstatus).to eq(0)
339
- end
340
- end
341
-
342
- describe "when Bundler root contains regex chars" do
343
- before do
344
- root_dir = tmp("foo[]bar")
345
-
346
- FileUtils.mkdir_p(root_dir)
347
- in_app_root_custom(root_dir)
348
- end
349
-
350
- it "doesn't blow up" do
351
- build_lib "foo"
352
- gemfile = <<-G
353
- gem 'foo', :path => "#{lib_path('foo-1.0')}"
354
- G
355
- File.open('Gemfile', 'w') do |file|
356
- file.puts gemfile
357
- end
358
-
359
- bundle :install, :exitstatus => true
360
-
361
- expect(exitstatus).to eq(0)
362
- end
363
- end
364
-
365
- describe "when requesting a quiet install via --quiet" do
366
- it "should be quiet" do
367
- gemfile <<-G
368
- gem 'rack'
369
- G
370
-
371
- bundle :install, :quiet => true
372
- expect(out).to include("Could not find gem 'rack (>= 0) ruby'")
373
- expect(out).to_not include("Your Gemfile has no gem server sources")
374
- end
375
- end
376
-
377
- end
@@ -1,386 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "bundle install with gems on multiple sources" do
4
- # repo1 is built automatically before all of the specs run
5
- # it contains rack-obama 1.0.0 and rack 0.9.1 & 1.0.0 amongst other gems
6
-
7
- context "without source affinity" do
8
- before do
9
- # Oh no! Someone evil is trying to hijack rack :(
10
- # need this to be broken to check for correct source ordering
11
- build_repo gem_repo3 do
12
- build_gem "rack", repo3_rack_version do |s|
13
- s.write "lib/rack.rb", "RACK = 'FAIL'"
14
- end
15
- end
16
- end
17
-
18
- context "when the same version of the same gem is in multiple sources" do
19
- let(:repo3_rack_version) { "1.0.0" }
20
-
21
- before do
22
- gemfile <<-G
23
- source "file://#{gem_repo3}"
24
- source "file://#{gem_repo1}"
25
- gem "rack-obama"
26
- gem "rack"
27
- G
28
- end
29
-
30
- it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do
31
- bundle :install
32
-
33
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
34
- expect(out).to include("Installed from: file:#{gem_repo1}")
35
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
36
- end
37
- end
38
-
39
- context "when different versions of the same gem are in multiple sources" do
40
- let(:repo3_rack_version) { "1.2" }
41
-
42
- before do
43
- gemfile <<-G
44
- source "file://#{gem_repo3}"
45
- source "file://#{gem_repo1}"
46
- gem "rack-obama"
47
- gem "rack", "1.0.0" # force it to install the working version in repo1
48
- G
49
- end
50
-
51
- it "warns about ambiguous gems, but installs anyway" do
52
- bundle :install
53
-
54
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
55
- expect(out).to include("Installed from: file:#{gem_repo1}")
56
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
57
- end
58
- end
59
- end
60
-
61
- context "with source affinity" do
62
- context "with sources given by a block" do
63
- before do
64
- # Oh no! Someone evil is trying to hijack rack :(
65
- # need this to be broken to check for correct source ordering
66
- build_repo gem_repo3 do
67
- build_gem "rack", "1.0.0" do |s|
68
- s.write "lib/rack.rb", "RACK = 'FAIL'"
69
- end
70
- end
71
-
72
- gemfile <<-G
73
- source "file://#{gem_repo3}"
74
- source "file://#{gem_repo1}" do
75
- gem "thin" # comes first to test name sorting
76
- gem "rack"
77
- end
78
- gem "rack-obama" # shoud come from repo3!
79
- G
80
- end
81
-
82
- it "installs the gems without any warning" do
83
- bundle :install
84
- expect(out).not_to include("Warning")
85
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
86
- end
87
-
88
- it "can cache and deploy" do
89
- bundle :package
90
-
91
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
92
- expect(bundled_app("vendor/cache/rack-obama-1.0.gem")).to exist
93
-
94
- bundle "install --deployment", :exitstatus => true
95
-
96
- expect(exitstatus).to eq(0)
97
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
98
- end
99
- end
100
-
101
- context "with sources set by an option" do
102
- before do
103
- # Oh no! Someone evil is trying to hijack rack :(
104
- # need this to be broken to check for correct source ordering
105
- build_repo gem_repo3 do
106
- build_gem "rack", "1.0.0" do |s|
107
- s.write "lib/rack.rb", "RACK = 'FAIL'"
108
- end
109
- end
110
-
111
- gemfile <<-G
112
- source "file://#{gem_repo3}"
113
- gem "rack-obama" # should come from repo3!
114
- gem "rack", :source => "file://#{gem_repo1}"
115
- G
116
- end
117
-
118
- it "installs the gems without any warning" do
119
- bundle :install
120
- expect(out).not_to include("Warning")
121
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
122
- end
123
- end
124
-
125
- context "with an indirect dependency" do
126
- before do
127
- build_repo gem_repo3 do
128
- build_gem "depends_on_rack", "1.0.1" do |s|
129
- s.add_dependency "rack"
130
- end
131
- end
132
- end
133
-
134
- context "when the indirect dependency is in the pinned source" do
135
- before do
136
- # we need a working rack gem in repo3
137
- update_repo gem_repo3 do
138
- build_gem "rack", "1.0.0"
139
- end
140
-
141
- gemfile <<-G
142
- source "file://#{gem_repo2}"
143
- source "file://#{gem_repo3}" do
144
- gem "depends_on_rack"
145
- end
146
- G
147
- end
148
-
149
- context "and not in any other sources" do
150
- before do
151
- build_repo(gem_repo2) {}
152
- end
153
-
154
- it "installs from the same source without any warning" do
155
- bundle :install
156
- expect(out).not_to include("Warning")
157
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
158
- end
159
- end
160
-
161
- context "and in another source" do
162
- before do
163
- # need this to be broken to check for correct source ordering
164
- build_repo gem_repo2 do
165
- build_gem "rack", "1.0.0" do |s|
166
- s.write "lib/rack.rb", "RACK = 'FAIL'"
167
- end
168
- end
169
- end
170
-
171
- it "installs from the same source without any warning" do
172
- bundle :install
173
- expect(out).not_to include("Warning")
174
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
175
- end
176
- end
177
- end
178
-
179
- context "when the indirect dependency is in a different source" do
180
- before do
181
- # In these tests, we need a working rack gem in repo2 and not repo3
182
- build_repo gem_repo2 do
183
- build_gem "rack", "1.0.0"
184
- end
185
- end
186
-
187
- context "and not in any other sources" do
188
- before do
189
- gemfile <<-G
190
- source "file://#{gem_repo2}"
191
- source "file://#{gem_repo3}" do
192
- gem "depends_on_rack"
193
- end
194
- G
195
- end
196
-
197
- it "installs from the other source without any warning" do
198
- bundle :install
199
- expect(out).not_to include("Warning")
200
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
201
- end
202
- end
203
-
204
- context "and in yet another source" do
205
- before do
206
- gemfile <<-G
207
- source "file://#{gem_repo1}"
208
- source "file://#{gem_repo2}"
209
- source "file://#{gem_repo3}" do
210
- gem "depends_on_rack"
211
- end
212
- G
213
- end
214
-
215
- it "installs from the other source and warns about ambiguous gems" do
216
- bundle :install
217
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
218
- expect(out).to include("Installed from: file:#{gem_repo2}")
219
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
220
- end
221
- end
222
-
223
- context "and only the dependency is pinned" do
224
- before do
225
- # need this to be broken to check for correct source ordering
226
- build_repo gem_repo2 do
227
- build_gem "rack", "1.0.0" do |s|
228
- s.write "lib/rack.rb", "RACK = 'FAIL'"
229
- end
230
- end
231
-
232
- gemfile <<-G
233
- source "file://#{gem_repo3}" # contains depends_on_rack
234
- source "file://#{gem_repo2}" # contains broken rack
235
-
236
- gem "depends_on_rack" # installed from gem_repo3
237
- gem "rack", :source => "file://#{gem_repo1}"
238
- G
239
- end
240
-
241
- it "installs the dependency from the pinned source without warning" do
242
- bundle :install
243
-
244
- expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
245
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
246
-
247
- # In https://github.com/bundler/bundler/issues/3585 this failed
248
- # when there is already a lock file, and the gems are missing, so try again
249
- system_gems []
250
- bundle :install
251
-
252
- expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
253
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
254
- end
255
- end
256
- end
257
- end
258
-
259
- context "with a gem that is only found in the wrong source" do
260
- before do
261
- build_repo gem_repo3 do
262
- build_gem "not_in_repo1", "1.0.0"
263
- end
264
-
265
- gemfile <<-G
266
- source "file://#{gem_repo3}"
267
- gem "not_in_repo1", :source => "file://#{gem_repo1}"
268
- G
269
- end
270
-
271
- it "does not install the gem" do
272
- bundle :install
273
- expect(out).to include("Could not find gem 'not_in_repo1 (>= 0) ruby'")
274
- end
275
- end
276
-
277
- context "with an existing lockfile" do
278
- before do
279
- system_gems "rack-0.9.1", "rack-1.0.0"
280
-
281
- lockfile <<-L
282
- GEM
283
- remote: file:#{gem_repo1}
284
- remote: file:#{gem_repo3}
285
- specs:
286
- rack (0.9.1)
287
-
288
- PLATFORMS
289
- ruby
290
-
291
- DEPENDENCIES
292
- rack!
293
- L
294
-
295
- gemfile <<-G
296
- source "file://#{gem_repo1}"
297
- source "file://#{gem_repo3}" do
298
- gem 'rack'
299
- end
300
- G
301
- end
302
-
303
- # Reproduction of https://github.com/bundler/bundler/issues/3298
304
- it "does not unlock the installed gem on exec" do
305
- should_be_installed("rack 0.9.1")
306
- end
307
- end
308
- end
309
-
310
- context "when an older version of the same gem also ships with Ruby" do
311
- before do
312
- system_gems "rack-0.9.1"
313
-
314
- gemfile <<-G
315
- source "file://#{gem_repo1}"
316
- gem "rack" # shoud come from repo1!
317
- G
318
- end
319
-
320
- it "installs the gems without any warning" do
321
- bundle :install
322
- expect(out).not_to include("Warning")
323
- should_be_installed("rack 1.0.0")
324
- end
325
- end
326
-
327
- context "when a single source contains multiple locked gems" do
328
- before do
329
- # 1. With these gems,
330
- build_repo4 do
331
- build_gem "foo", "0.1"
332
- build_gem "bar", "0.1"
333
- end
334
-
335
- # 2. Installing this gemfile will produce...
336
- gemfile <<-G
337
- source 'file://#{gem_repo1}'
338
- gem 'rack'
339
- gem 'foo', '~> 0.1', :source => 'file://#{gem_repo4}'
340
- gem 'bar', '~> 0.1', :source => 'file://#{gem_repo4}'
341
- G
342
-
343
- # 3. this lockfile.
344
- lockfile <<-L
345
- GEM
346
- remote: file:/Users/andre/src/bundler/bundler/tmp/gems/remote1/
347
- remote: file:/Users/andre/src/bundler/bundler/tmp/gems/remote4/
348
- specs:
349
- bar (0.1)
350
- foo (0.1)
351
- rack (1.0.0)
352
-
353
- PLATFORMS
354
- ruby
355
-
356
- DEPENDENCIES
357
- bar (~> 0.1)!
358
- foo (~> 0.1)!
359
- rack
360
- L
361
-
362
- bundle "install --path ../gems/system"
363
-
364
- # 4. Then we add some new versions...
365
- update_repo4 do
366
- build_gem "foo", "0.2"
367
- build_gem "bar", "0.3"
368
- end
369
- end
370
-
371
- it "allows them to be unlocked separately" do
372
- # 5. and install this gemfile, updating only foo.
373
- install_gemfile <<-G
374
- source 'file://#{gem_repo1}'
375
- gem 'rack'
376
- gem 'foo', '~> 0.2', :source => 'file://#{gem_repo4}'
377
- gem 'bar', '~> 0.1', :source => 'file://#{gem_repo4}'
378
- G
379
-
380
- # 6. Which should update foo to 0.2, but not the (locked) bar 0.1
381
- should_be_installed("foo 0.2")
382
- should_be_installed("bar 0.1")
383
- end
384
- end
385
-
386
- end