rkh-bundler 1.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +42 -0
  3. data/CHANGELOG.md +1105 -0
  4. data/ISSUES.md +67 -0
  5. data/LICENSE +23 -0
  6. data/README.md +31 -0
  7. data/Rakefile +208 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +31 -0
  10. data/bundler.gemspec +31 -0
  11. data/lib/bundler.rb +353 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +693 -0
  14. data/lib/bundler/definition.rb +568 -0
  15. data/lib/bundler/dep_proxy.rb +43 -0
  16. data/lib/bundler/dependency.rb +134 -0
  17. data/lib/bundler/deployment.rb +58 -0
  18. data/lib/bundler/dsl.rb +256 -0
  19. data/lib/bundler/endpoint_specification.rb +78 -0
  20. data/lib/bundler/environment.rb +47 -0
  21. data/lib/bundler/fetcher.rb +225 -0
  22. data/lib/bundler/gem_helper.rb +162 -0
  23. data/lib/bundler/gem_helpers.rb +23 -0
  24. data/lib/bundler/gem_installer.rb +9 -0
  25. data/lib/bundler/gem_tasks.rb +2 -0
  26. data/lib/bundler/graph.rb +148 -0
  27. data/lib/bundler/index.rb +187 -0
  28. data/lib/bundler/installer.rb +190 -0
  29. data/lib/bundler/lazy_specification.rb +79 -0
  30. data/lib/bundler/lockfile_parser.rb +127 -0
  31. data/lib/bundler/match_platform.rb +13 -0
  32. data/lib/bundler/psyched_yaml.rb +15 -0
  33. data/lib/bundler/remote_specification.rb +57 -0
  34. data/lib/bundler/resolver.rb +486 -0
  35. data/lib/bundler/ruby_version.rb +94 -0
  36. data/lib/bundler/rubygems_ext.rb +153 -0
  37. data/lib/bundler/rubygems_integration.rb +394 -0
  38. data/lib/bundler/runtime.rb +233 -0
  39. data/lib/bundler/settings.rb +128 -0
  40. data/lib/bundler/setup.rb +23 -0
  41. data/lib/bundler/shared_helpers.rb +71 -0
  42. data/lib/bundler/source.rb +869 -0
  43. data/lib/bundler/spec_set.rb +137 -0
  44. data/lib/bundler/templates/Executable +16 -0
  45. data/lib/bundler/templates/Executable.standalone +12 -0
  46. data/lib/bundler/templates/Gemfile +4 -0
  47. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  48. data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
  49. data/lib/bundler/templates/newgem/README.md.tt +29 -0
  50. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  51. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  52. data/lib/bundler/templates/newgem/gitignore.tt +17 -0
  53. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
  54. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  55. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -0
  56. data/lib/bundler/ui.rb +88 -0
  57. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  58. data/lib/bundler/vendor/net/http/persistent.rb +468 -0
  59. data/lib/bundler/vendor/thor.rb +358 -0
  60. data/lib/bundler/vendor/thor/actions.rb +314 -0
  61. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  62. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  63. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  64. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  65. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
  66. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
  67. data/lib/bundler/vendor/thor/base.rb +576 -0
  68. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  69. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  70. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  71. data/lib/bundler/vendor/thor/error.rb +30 -0
  72. data/lib/bundler/vendor/thor/group.rb +273 -0
  73. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  74. data/lib/bundler/vendor/thor/parser.rb +4 -0
  75. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  76. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  77. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  78. data/lib/bundler/vendor/thor/parser/options.rb +172 -0
  79. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  80. data/lib/bundler/vendor/thor/runner.rb +309 -0
  81. data/lib/bundler/vendor/thor/shell.rb +88 -0
  82. data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
  83. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  84. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  85. data/lib/bundler/vendor/thor/task.rb +113 -0
  86. data/lib/bundler/vendor/thor/util.rb +229 -0
  87. data/lib/bundler/vendor/thor/version.rb +3 -0
  88. data/lib/bundler/vendored_thor.rb +7 -0
  89. data/lib/bundler/version.rb +6 -0
  90. data/lib/bundler/vlad.rb +11 -0
  91. data/man/bundle-config.ronn +130 -0
  92. data/man/bundle-exec.ronn +111 -0
  93. data/man/bundle-install.ronn +335 -0
  94. data/man/bundle-package.ronn +59 -0
  95. data/man/bundle-update.ronn +176 -0
  96. data/man/bundle.ronn +83 -0
  97. data/man/gemfile.5.ronn +324 -0
  98. data/man/index.txt +6 -0
  99. data/spec/bundler/dsl_spec.rb +48 -0
  100. data/spec/bundler/gem_helper_spec.rb +174 -0
  101. data/spec/bundler/source_spec.rb +25 -0
  102. data/spec/cache/gems_spec.rb +239 -0
  103. data/spec/cache/git_spec.rb +124 -0
  104. data/spec/cache/path_spec.rb +103 -0
  105. data/spec/cache/platform_spec.rb +57 -0
  106. data/spec/install/deploy_spec.rb +211 -0
  107. data/spec/install/gems/c_ext_spec.rb +48 -0
  108. data/spec/install/gems/dependency_api_spec.rb +402 -0
  109. data/spec/install/gems/env_spec.rb +107 -0
  110. data/spec/install/gems/flex_spec.rb +313 -0
  111. data/spec/install/gems/groups_spec.rb +268 -0
  112. data/spec/install/gems/packed_spec.rb +84 -0
  113. data/spec/install/gems/platform_spec.rb +208 -0
  114. data/spec/install/gems/post_install_spec.rb +47 -0
  115. data/spec/install/gems/resolving_spec.rb +72 -0
  116. data/spec/install/gems/simple_case_spec.rb +814 -0
  117. data/spec/install/gems/standalone_spec.rb +260 -0
  118. data/spec/install/gems/sudo_spec.rb +74 -0
  119. data/spec/install/gems/win32_spec.rb +26 -0
  120. data/spec/install/gemspec_spec.rb +170 -0
  121. data/spec/install/git_spec.rb +796 -0
  122. data/spec/install/invalid_spec.rb +35 -0
  123. data/spec/install/path_spec.rb +405 -0
  124. data/spec/install/upgrade_spec.rb +26 -0
  125. data/spec/lock/git_spec.rb +35 -0
  126. data/spec/lock/lockfile_spec.rb +809 -0
  127. data/spec/other/check_spec.rb +265 -0
  128. data/spec/other/clean_spec.rb +492 -0
  129. data/spec/other/config_spec.rb +138 -0
  130. data/spec/other/console_spec.rb +54 -0
  131. data/spec/other/exec_spec.rb +229 -0
  132. data/spec/other/ext_spec.rb +37 -0
  133. data/spec/other/help_spec.rb +39 -0
  134. data/spec/other/init_spec.rb +40 -0
  135. data/spec/other/newgem_spec.rb +87 -0
  136. data/spec/other/open_spec.rb +35 -0
  137. data/spec/other/outdated_spec.rb +93 -0
  138. data/spec/other/platform_spec.rb +881 -0
  139. data/spec/other/show_spec.rb +88 -0
  140. data/spec/quality_spec.rb +62 -0
  141. data/spec/realworld/edgecases_spec.rb +177 -0
  142. data/spec/resolver/basic_spec.rb +20 -0
  143. data/spec/resolver/platform_spec.rb +82 -0
  144. data/spec/runtime/executable_spec.rb +120 -0
  145. data/spec/runtime/load_spec.rb +107 -0
  146. data/spec/runtime/platform_spec.rb +90 -0
  147. data/spec/runtime/require_spec.rb +261 -0
  148. data/spec/runtime/setup_spec.rb +755 -0
  149. data/spec/runtime/with_clean_env_spec.rb +80 -0
  150. data/spec/spec_helper.rb +98 -0
  151. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
  152. data/spec/support/artifice/endpoint.rb +54 -0
  153. data/spec/support/artifice/endpoint_500.rb +37 -0
  154. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  155. data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
  156. data/spec/support/artifice/endpoint_extra.rb +27 -0
  157. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  158. data/spec/support/artifice/endpoint_fallback.rb +18 -0
  159. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  160. data/spec/support/artifice/endpoint_redirect.rb +15 -0
  161. data/spec/support/builders.rb +604 -0
  162. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  163. data/spec/support/fakeweb/windows.rb +23 -0
  164. data/spec/support/helpers.rb +317 -0
  165. data/spec/support/indexes.rb +112 -0
  166. data/spec/support/matchers.rb +77 -0
  167. data/spec/support/path.rb +73 -0
  168. data/spec/support/platforms.rb +86 -0
  169. data/spec/support/ruby_ext.rb +20 -0
  170. data/spec/support/rubygems_ext.rb +37 -0
  171. data/spec/support/rubygems_hax/platform.rb +22 -0
  172. data/spec/support/sudo.rb +21 -0
  173. data/spec/update/gems_spec.rb +134 -0
  174. data/spec/update/git_spec.rb +196 -0
  175. data/spec/update/source_spec.rb +51 -0
  176. metadata +338 -0
@@ -0,0 +1,796 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install with git sources" do
4
+ describe "when floating on master" do
5
+ before :each do
6
+ build_git "foo" do |s|
7
+ s.executables = "foobar"
8
+ end
9
+
10
+ install_gemfile <<-G
11
+ source "file://#{gem_repo1}"
12
+ git "#{lib_path('foo-1.0')}" do
13
+ gem 'foo'
14
+ end
15
+ G
16
+ end
17
+
18
+ it "fetches gems" do
19
+ should_be_installed("foo 1.0")
20
+
21
+ run <<-RUBY
22
+ require 'foo'
23
+ puts "WIN" unless defined?(FOO_PREV_REF)
24
+ RUBY
25
+
26
+ out.should == "WIN"
27
+ end
28
+
29
+ it "caches the git repo" do
30
+ Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"].should have(1).item
31
+ end
32
+
33
+ it "does not update the git source implicitly" do
34
+ update_git "foo"
35
+
36
+ in_app_root2 do
37
+ install_gemfile bundled_app2("Gemfile"), <<-G
38
+ git "#{lib_path('foo-1.0')}" do
39
+ gem 'foo'
40
+ end
41
+ G
42
+ end
43
+
44
+ in_app_root do
45
+ run <<-RUBY
46
+ require 'foo'
47
+ puts "fail" if defined?(FOO_PREV_REF)
48
+ RUBY
49
+
50
+ out.should be_empty
51
+ end
52
+ end
53
+
54
+ it "setups executables" do
55
+ pending_jruby_shebang_fix
56
+ bundle "exec foobar"
57
+ out.should == "1.0"
58
+ end
59
+
60
+ it "complains if pinned specs don't exist in the git repo" do
61
+ build_git "foo"
62
+
63
+ install_gemfile <<-G
64
+ gem "foo", "1.1", :git => "#{lib_path('foo-1.0')}"
65
+ G
66
+
67
+ out.should include("Source contains 'foo' at: 1.0")
68
+ end
69
+
70
+ it "still works after moving the application directory" do
71
+ bundle "install --path vendor/bundle"
72
+ FileUtils.mv bundled_app, tmp('bundled_app.bck')
73
+
74
+ Dir.chdir tmp('bundled_app.bck')
75
+ should_be_installed "foo 1.0"
76
+ end
77
+
78
+ it "can still install after moving the application directory" do
79
+ bundle "install --path vendor/bundle"
80
+ FileUtils.mv bundled_app, tmp('bundled_app.bck')
81
+
82
+ update_git "foo", "1.1", :path => lib_path("foo-1.0")
83
+
84
+ Dir.chdir tmp('bundled_app.bck')
85
+ gemfile tmp('bundled_app.bck/Gemfile'), <<-G
86
+ source "file://#{gem_repo1}"
87
+ git "#{lib_path('foo-1.0')}" do
88
+ gem 'foo'
89
+ end
90
+
91
+ gem "rack", "1.0"
92
+ G
93
+
94
+ bundle "update foo"
95
+
96
+ should_be_installed "foo 1.1", "rack 1.0"
97
+ end
98
+
99
+ end
100
+
101
+ describe "with an empty git block" do
102
+ before do
103
+ build_git "foo"
104
+ gemfile <<-G
105
+ source "file://#{gem_repo1}"
106
+ gem "rack"
107
+
108
+ git "#{lib_path("foo-1.0")}" do
109
+ # this page left intentionally blank
110
+ end
111
+ G
112
+ end
113
+
114
+ it "does not explode" do
115
+ bundle "install"
116
+ should_be_installed "rack 1.0"
117
+ end
118
+ end
119
+
120
+ describe "when specifying a revision" do
121
+ before(:each) do
122
+ build_git "foo"
123
+ @revision = revision_for(lib_path("foo-1.0"))
124
+ update_git "foo"
125
+ end
126
+
127
+ it "works" do
128
+ install_gemfile <<-G
129
+ git "#{lib_path('foo-1.0')}", :ref => "#{@revision}" do
130
+ gem "foo"
131
+ end
132
+ G
133
+
134
+ run <<-RUBY
135
+ require 'foo'
136
+ puts "WIN" unless defined?(FOO_PREV_REF)
137
+ RUBY
138
+
139
+ out.should == "WIN"
140
+ end
141
+
142
+ it "works when the revision is a symbol" do
143
+ install_gemfile <<-G
144
+ git "#{lib_path('foo-1.0')}", :ref => #{@revision.to_sym.inspect} do
145
+ gem "foo"
146
+ end
147
+ G
148
+ err.should eq("")
149
+
150
+ run <<-RUBY
151
+ require 'foo'
152
+ puts "WIN" unless defined?(FOO_PREV_REF)
153
+ RUBY
154
+
155
+ out.should == "WIN"
156
+ end
157
+ end
158
+
159
+ describe "when specifying local" do
160
+ it "uses the local repository instead of checking a new one out" do
161
+ # We don't generate it because we actually don't need it
162
+ # build_git "rack", "0.8"
163
+
164
+ build_git "rack", "0.8", :path => lib_path('local-rack') do |s|
165
+ s.write "lib/rack.rb", "puts :LOCAL"
166
+ end
167
+
168
+ gemfile <<-G
169
+ source "file://#{gem_repo1}"
170
+ gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
171
+ G
172
+
173
+ bundle %|config local.rack #{lib_path('local-rack')}|
174
+ bundle :install
175
+ out.should =~ /at #{lib_path('local-rack')}/
176
+
177
+ run "require 'rack'"
178
+ out.should == "LOCAL"
179
+ end
180
+
181
+ it "chooses the local repository on runtime" do
182
+ build_git "rack", "0.8"
183
+
184
+ FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
185
+
186
+ update_git "rack", "0.8", :path => lib_path('local-rack') do |s|
187
+ s.write "lib/rack.rb", "puts :LOCAL"
188
+ end
189
+
190
+ install_gemfile <<-G
191
+ source "file://#{gem_repo1}"
192
+ gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
193
+ G
194
+
195
+ bundle %|config local.rack #{lib_path('local-rack')}|
196
+ run "require 'rack'"
197
+ out.should == "LOCAL"
198
+ end
199
+
200
+ it "updates specs on runtime" do
201
+ system_gems "nokogiri-1.4.2"
202
+
203
+ build_git "rack", "0.8"
204
+
205
+ install_gemfile <<-G
206
+ source "file://#{gem_repo1}"
207
+ gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
208
+ G
209
+
210
+ lockfile0 = File.read(bundled_app("Gemfile.lock"))
211
+
212
+ FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
213
+ update_git "rack", "0.8", :path => lib_path('local-rack') do |s|
214
+ s.add_dependency "nokogiri", "1.4.2"
215
+ end
216
+
217
+ bundle %|config local.rack #{lib_path('local-rack')}|
218
+ run "require 'rack'"
219
+
220
+ lockfile1 = File.read(bundled_app("Gemfile.lock"))
221
+ lockfile1.should_not == lockfile0
222
+ end
223
+
224
+ it "updates ref on install" do
225
+ build_git "rack", "0.8"
226
+
227
+ install_gemfile <<-G
228
+ source "file://#{gem_repo1}"
229
+ gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
230
+ G
231
+
232
+ lockfile0 = File.read(bundled_app("Gemfile.lock"))
233
+
234
+ FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
235
+ update_git "rack", "0.8", :path => lib_path('local-rack')
236
+
237
+ bundle %|config local.rack #{lib_path('local-rack')}|
238
+ bundle :install
239
+
240
+ lockfile1 = File.read(bundled_app("Gemfile.lock"))
241
+ lockfile1.should_not == lockfile0
242
+ end
243
+
244
+ it "explodes if given path does not exist" do
245
+ build_git "rack", "0.8"
246
+
247
+ install_gemfile <<-G
248
+ source "file://#{gem_repo1}"
249
+ gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
250
+ G
251
+
252
+ bundle %|config local.rack #{lib_path('local-rack')}|
253
+ bundle :install
254
+ out.should =~ /Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/
255
+ end
256
+
257
+ it "does not explode if branch is not given" do
258
+ build_git "rack", "0.8"
259
+ FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
260
+
261
+ install_gemfile <<-G
262
+ source "file://#{gem_repo1}"
263
+ gem "rack", :git => "#{lib_path('rack-0.8')}"
264
+ G
265
+
266
+ bundle %|config local.rack #{lib_path('local-rack')}|
267
+ bundle :install
268
+ out.should =~ /Your bundle is complete!/
269
+ end
270
+
271
+ it "explodes on different branches" do
272
+ build_git "rack", "0.8"
273
+
274
+ FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
275
+
276
+ update_git "rack", "0.8", :path => lib_path('local-rack'), :branch => "another" do |s|
277
+ s.write "lib/rack.rb", "puts :LOCAL"
278
+ end
279
+
280
+ install_gemfile <<-G
281
+ source "file://#{gem_repo1}"
282
+ gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
283
+ G
284
+
285
+ bundle %|config local.rack #{lib_path('local-rack')}|
286
+ bundle :install
287
+ out.should =~ /is using branch another but Gemfile specifies master/
288
+ end
289
+
290
+ it "explodes on invalid revision" do
291
+ build_git "rack", "0.8"
292
+
293
+ build_git "rack", "0.8", :path => lib_path('local-rack') do |s|
294
+ s.write "lib/rack.rb", "puts :LOCAL"
295
+ end
296
+
297
+ install_gemfile <<-G
298
+ source "file://#{gem_repo1}"
299
+ gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
300
+ G
301
+
302
+ bundle %|config local.rack #{lib_path('local-rack')}|
303
+ bundle :install
304
+ out.should =~ /The Gemfile lock is pointing to revision \w+/
305
+ end
306
+ end
307
+
308
+ describe "specified inline" do
309
+ # TODO: Figure out how to write this test so that it is not flaky depending
310
+ # on the current network situation.
311
+ # it "supports private git URLs" do
312
+ # gemfile <<-G
313
+ # gem "thingy", :git => "git@notthere.fallingsnow.net:somebody/thingy.git"
314
+ # G
315
+ #
316
+ # bundle :install, :expect_err => true
317
+ #
318
+ # # p out
319
+ # # p err
320
+ # puts err unless err.empty? # This spec fails randomly every so often
321
+ # err.should include("notthere.fallingsnow.net")
322
+ # err.should include("ssh")
323
+ # end
324
+
325
+ it "installs from git even if a newer gem is available elsewhere" do
326
+ build_git "rack", "0.8"
327
+
328
+ install_gemfile <<-G
329
+ source "file://#{gem_repo1}"
330
+ gem "rack", :git => "#{lib_path('rack-0.8')}"
331
+ G
332
+
333
+ should_be_installed "rack 0.8"
334
+ end
335
+
336
+ it "installs dependencies from git even if a newer gem is available elsewhere" do
337
+ system_gems "rack-1.0.0"
338
+
339
+ build_lib "rack", "1.0", :path => lib_path('nested/bar') do |s|
340
+ s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
341
+ end
342
+
343
+ build_git "foo", :path => lib_path('nested') do |s|
344
+ s.add_dependency "rack", "= 1.0"
345
+ end
346
+
347
+ install_gemfile <<-G
348
+ source "file://#{gem_repo1}"
349
+ gem "foo", :git => "#{lib_path('nested')}"
350
+ G
351
+
352
+ run "require 'rack'"
353
+ out.should == 'WIN OVERRIDE'
354
+ end
355
+
356
+ it "correctly unlocks when changing to a git source" do
357
+ install_gemfile <<-G
358
+ source "file://#{gem_repo1}"
359
+ gem "rack", "0.9.1"
360
+ G
361
+
362
+ build_git "rack", :path => lib_path("rack")
363
+
364
+ install_gemfile <<-G
365
+ source "file://#{gem_repo1}"
366
+ gem "rack", "1.0.0", :git => "#{lib_path('rack')}"
367
+ G
368
+
369
+ should_be_installed "rack 1.0.0"
370
+ end
371
+
372
+ it "correctly unlocks when changing to a git source without versions" do
373
+ install_gemfile <<-G
374
+ source "file://#{gem_repo1}"
375
+ gem "rack"
376
+ G
377
+
378
+ build_git "rack", "1.2", :path => lib_path("rack")
379
+
380
+ install_gemfile <<-G
381
+ source "file://#{gem_repo1}"
382
+ gem "rack", :git => "#{lib_path('rack')}"
383
+ G
384
+
385
+ should_be_installed "rack 1.2"
386
+ end
387
+ end
388
+
389
+ describe "block syntax" do
390
+ it "pulls all gems from a git block" do
391
+ build_lib "omg", :path => lib_path('hi2u/omg')
392
+ build_lib "hi2u", :path => lib_path('hi2u')
393
+
394
+ install_gemfile <<-G
395
+ path "#{lib_path('hi2u')}" do
396
+ gem "omg"
397
+ gem "hi2u"
398
+ end
399
+ G
400
+
401
+ should_be_installed "omg 1.0", "hi2u 1.0"
402
+ end
403
+ end
404
+
405
+ it "uses a ref if specified" do
406
+ build_git "foo"
407
+ @revision = revision_for(lib_path("foo-1.0"))
408
+ update_git "foo"
409
+
410
+ install_gemfile <<-G
411
+ gem "foo", :git => "#{lib_path('foo-1.0')}", :ref => "#{@revision}"
412
+ G
413
+
414
+ run <<-RUBY
415
+ require 'foo'
416
+ puts "WIN" unless defined?(FOO_PREV_REF)
417
+ RUBY
418
+
419
+ out.should == "WIN"
420
+ end
421
+
422
+ it "correctly handles cases with invalid gemspecs" do
423
+ build_git "foo" do |s|
424
+ s.summary = nil
425
+ end
426
+
427
+ install_gemfile <<-G
428
+ source "file://#{gem_repo1}"
429
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
430
+ gem "rails", "2.3.2"
431
+ G
432
+
433
+ should_be_installed "foo 1.0"
434
+ should_be_installed "rails 2.3.2"
435
+ end
436
+
437
+ it "runs the gemspec in the context of its parent directory" do
438
+ build_lib "bar", :path => lib_path("foo/bar"), :gemspec => false do |s|
439
+ s.write lib_path("foo/bar/lib/version.rb"), %{BAR_VERSION = '1.0'}
440
+ s.write "bar.gemspec", <<-G
441
+ $:.unshift Dir.pwd # For 1.9
442
+ require 'lib/version'
443
+ Gem::Specification.new do |s|
444
+ s.name = 'bar'
445
+ s.version = BAR_VERSION
446
+ s.summary = 'Bar'
447
+ s.files = Dir["lib/**/*.rb"]
448
+ end
449
+ G
450
+ end
451
+
452
+ build_git "foo", :path => lib_path("foo") do |s|
453
+ s.write "bin/foo", ""
454
+ end
455
+
456
+ install_gemfile <<-G
457
+ source "file://#{gem_repo1}"
458
+ gem "bar", :git => "#{lib_path("foo")}"
459
+ gem "rails", "2.3.2"
460
+ G
461
+
462
+ should_be_installed "bar 1.0"
463
+ should_be_installed "rails 2.3.2"
464
+ end
465
+
466
+ it "installs from git even if a rubygems gem is present" do
467
+ build_gem "foo", "1.0", :path => lib_path('fake_foo'), :to_system => true do |s|
468
+ s.write "lib/foo.rb", "raise 'FAIL'"
469
+ end
470
+
471
+ build_git "foo", "1.0"
472
+
473
+ install_gemfile <<-G
474
+ gem "foo", "1.0", :git => "#{lib_path('foo-1.0')}"
475
+ G
476
+
477
+ should_be_installed "foo 1.0"
478
+ end
479
+
480
+ it "fakes the gem out if there is no gemspec" do
481
+ build_git "foo", :gemspec => false
482
+
483
+ install_gemfile <<-G
484
+ source "file://#{gem_repo1}"
485
+ gem "foo", "1.0", :git => "#{lib_path('foo-1.0')}"
486
+ gem "rails", "2.3.2"
487
+ G
488
+
489
+ should_be_installed("foo 1.0")
490
+ should_be_installed("rails 2.3.2")
491
+ end
492
+
493
+ it "catches git errors and spits out useful output" do
494
+ gemfile <<-G
495
+ gem "foo", "1.0", :git => "omgomg"
496
+ G
497
+
498
+ bundle :install, :expect_err => true
499
+
500
+ out.should include("Git error:")
501
+ err.should include("fatal")
502
+ err.should include("omgomg")
503
+ end
504
+
505
+ it "works when the gem path has spaces in it" do
506
+ build_git "foo", :path => lib_path('foo space-1.0')
507
+
508
+ install_gemfile <<-G
509
+ gem "foo", :git => "#{lib_path('foo space-1.0')}"
510
+ G
511
+
512
+ should_be_installed "foo 1.0"
513
+ end
514
+
515
+ it "handles repos that have been force-pushed" do
516
+ build_git "forced", "1.0"
517
+
518
+ install_gemfile <<-G
519
+ git "#{lib_path('forced-1.0')}" do
520
+ gem 'forced'
521
+ end
522
+ G
523
+ should_be_installed "forced 1.0"
524
+
525
+ update_git "forced" do |s|
526
+ s.write "lib/forced.rb", "FORCED = '1.1'"
527
+ end
528
+
529
+ bundle "update"
530
+ should_be_installed "forced 1.1"
531
+
532
+ Dir.chdir(lib_path('forced-1.0')) do
533
+ `git reset --hard HEAD^`
534
+ end
535
+
536
+ bundle "update"
537
+ should_be_installed "forced 1.0"
538
+ end
539
+
540
+ it "ignores submodules if :submodule is not passed" do
541
+ build_git "submodule", "1.0"
542
+ build_git "has_submodule", "1.0" do |s|
543
+ s.add_dependency "submodule"
544
+ end
545
+ Dir.chdir(lib_path('has_submodule-1.0')) do
546
+ `git submodule add #{lib_path('submodule-1.0')} submodule-1.0`
547
+ `git commit -m "submodulator"`
548
+ end
549
+
550
+ install_gemfile <<-G, :expect_err => true
551
+ git "#{lib_path('has_submodule-1.0')}" do
552
+ gem "has_submodule"
553
+ end
554
+ G
555
+ out.should =~ /could not find gem 'submodule/i
556
+
557
+ should_not_be_installed "has_submodule 1.0", :expect_err => true
558
+ end
559
+
560
+ it "handles repos with submodules" do
561
+ build_git "submodule", "1.0"
562
+ build_git "has_submodule", "1.0" do |s|
563
+ s.add_dependency "submodule"
564
+ end
565
+ Dir.chdir(lib_path('has_submodule-1.0')) do
566
+ `git submodule add #{lib_path('submodule-1.0')} submodule-1.0`
567
+ `git commit -m "submodulator"`
568
+ end
569
+
570
+ install_gemfile <<-G
571
+ git "#{lib_path('has_submodule-1.0')}", :submodules => true do
572
+ gem "has_submodule"
573
+ end
574
+ G
575
+
576
+ should_be_installed "has_submodule 1.0"
577
+ end
578
+
579
+ it "handles implicit updates when modifying the source info" do
580
+ git = build_git "foo"
581
+
582
+ install_gemfile <<-G
583
+ git "#{lib_path('foo-1.0')}" do
584
+ gem "foo"
585
+ end
586
+ G
587
+
588
+ update_git "foo"
589
+ update_git "foo"
590
+
591
+ install_gemfile <<-G
592
+ git "#{lib_path('foo-1.0')}", :ref => "#{git.ref_for('HEAD^')}" do
593
+ gem "foo"
594
+ end
595
+ G
596
+
597
+ run <<-RUBY
598
+ require 'foo'
599
+ puts "WIN" if FOO_PREV_REF == '#{git.ref_for("HEAD^^")}'
600
+ RUBY
601
+
602
+ out.should == "WIN"
603
+ end
604
+
605
+ it "does not to a remote fetch if the revision is cached locally" do
606
+ build_git "foo"
607
+
608
+ install_gemfile <<-G
609
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
610
+ G
611
+
612
+ FileUtils.rm_rf(lib_path('foo-1.0'))
613
+
614
+ bundle "install"
615
+ out.should_not =~ /updating/i
616
+ end
617
+
618
+ it "doesn't blow up if bundle install is run twice in a row" do
619
+ build_git "foo"
620
+
621
+ gemfile <<-G
622
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
623
+ G
624
+
625
+ bundle "install"
626
+ bundle "install", :exitstatus => true
627
+ exitstatus.should == 0
628
+ end
629
+
630
+ it "does not duplicate git gem sources" do
631
+ build_lib "foo", :path => lib_path('nested/foo')
632
+ build_lib "bar", :path => lib_path('nested/bar')
633
+
634
+ build_git "foo", :path => lib_path('nested')
635
+ build_git "bar", :path => lib_path('nested')
636
+
637
+ gemfile <<-G
638
+ gem "foo", :git => "#{lib_path('nested')}"
639
+ gem "bar", :git => "#{lib_path('nested')}"
640
+ G
641
+
642
+ bundle "install"
643
+ File.read(bundled_app("Gemfile.lock")).scan('GIT').size.should == 1
644
+ end
645
+
646
+ describe "switching sources" do
647
+ it "doesn't explode when switching Path to Git sources" do
648
+ build_gem "foo", "1.0", :to_system => true do |s|
649
+ s.write "lib/foo.rb", "raise 'fail'"
650
+ end
651
+ build_lib "foo", "1.0", :path => lib_path('bar/foo')
652
+ build_git "bar", "1.0", :path => lib_path('bar') do |s|
653
+ s.add_dependency 'foo'
654
+ end
655
+
656
+ install_gemfile <<-G
657
+ source "file://#{gem_repo1}"
658
+ gem "bar", :path => "#{lib_path('bar')}"
659
+ G
660
+
661
+ install_gemfile <<-G
662
+ source "file://#{gem_repo1}"
663
+ gem "bar", :git => "#{lib_path('bar')}"
664
+ G
665
+
666
+ should_be_installed "foo 1.0", "bar 1.0"
667
+ end
668
+
669
+ it "doesn't explode when switching Gem to Git source" do
670
+ install_gemfile <<-G
671
+ source "file://#{gem_repo1}"
672
+ gem "rack-obama"
673
+ gem "rack", "1.0.0"
674
+ G
675
+
676
+ build_git "rack", "1.0" do |s|
677
+ s.write "lib/new_file.rb", "puts 'USING GIT'"
678
+ end
679
+
680
+ install_gemfile <<-G
681
+ source "file://#{gem_repo1}"
682
+ gem "rack-obama"
683
+ gem "rack", "1.0.0", :git => "#{lib_path("rack-1.0")}"
684
+ G
685
+
686
+ run "require 'new_file'"
687
+ out.should == "USING GIT"
688
+ end
689
+ end
690
+
691
+ describe "bundle install after the remote has been updated" do
692
+ it "installs" do
693
+ build_git "valim"
694
+
695
+ install_gemfile <<-G
696
+ gem "valim", :git => "file://#{lib_path("valim-1.0")}"
697
+ G
698
+
699
+ old_revision = revision_for(lib_path("valim-1.0"))
700
+ update_git "valim"
701
+ new_revision = revision_for(lib_path("valim-1.0"))
702
+
703
+ lockfile = File.read(bundled_app("Gemfile.lock"))
704
+ File.open(bundled_app("Gemfile.lock"), "w") do |file|
705
+ file.puts lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}")
706
+ end
707
+
708
+ bundle "install"
709
+
710
+ run <<-R
711
+ require "valim"
712
+ puts VALIM_PREV_REF
713
+ R
714
+
715
+ out.should == old_revision
716
+ end
717
+ end
718
+
719
+ describe "bundle install --deployment with git sources" do
720
+ it "works" do
721
+ build_git "valim", :path => lib_path('valim')
722
+
723
+ install_gemfile <<-G
724
+ source "file://#{gem_repo1}"
725
+ gem "valim", "= 1.0", :git => "#{lib_path('valim')}"
726
+ G
727
+
728
+ simulate_new_machine
729
+
730
+ bundle "install --deployment", :exitstatus => true
731
+ exitstatus.should == 0
732
+ end
733
+ end
734
+
735
+ describe "gem install hooks" do
736
+ it "runs pre-install hooks" do
737
+ build_git "foo"
738
+ gemfile <<-G
739
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
740
+ G
741
+
742
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
743
+ h.write <<-H
744
+ require 'rubygems'
745
+ Gem.pre_install_hooks << lambda do |inst|
746
+ STDERR.puts "Ran pre-install hook: \#{inst.spec.full_name}"
747
+ end
748
+ H
749
+ end
750
+
751
+ bundle :install, :expect_err => true,
752
+ :requires => [lib_path('install_hooks.rb')]
753
+ err.should == "Ran pre-install hook: foo-1.0"
754
+ end
755
+
756
+ it "runs post-install hooks" do
757
+ build_git "foo"
758
+ gemfile <<-G
759
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
760
+ G
761
+
762
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
763
+ h.write <<-H
764
+ require 'rubygems'
765
+ Gem.post_install_hooks << lambda do |inst|
766
+ STDERR.puts "Ran post-install hook: \#{inst.spec.full_name}"
767
+ end
768
+ H
769
+ end
770
+
771
+ bundle :install, :expect_err => true,
772
+ :requires => [lib_path('install_hooks.rb')]
773
+ err.should == "Ran post-install hook: foo-1.0"
774
+ end
775
+
776
+ it "complains if the install hook fails" do
777
+ build_git "foo"
778
+ gemfile <<-G
779
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
780
+ G
781
+
782
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
783
+ h.write <<-H
784
+ require 'rubygems'
785
+ Gem.pre_install_hooks << lambda do |inst|
786
+ false
787
+ end
788
+ H
789
+ end
790
+
791
+ bundle :install, :expect_err => true,
792
+ :requires => [lib_path('install_hooks.rb')]
793
+ out.should include("failed for foo-1.0")
794
+ end
795
+ end
796
+ end