bundler 1.1.pre.8 → 1.1.pre.9

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 (45) hide show
  1. data/.travis.yml +29 -5
  2. data/CHANGELOG.md +58 -3
  3. data/Rakefile +25 -2
  4. data/UPGRADING.md +2 -2
  5. data/bin/bundle +10 -10
  6. data/bundler.gemspec +2 -1
  7. data/lib/bundler.rb +8 -6
  8. data/lib/bundler/cli.rb +45 -14
  9. data/lib/bundler/definition.rb +4 -4
  10. data/lib/bundler/dependency.rb +1 -8
  11. data/lib/bundler/deployment.rb +8 -3
  12. data/lib/bundler/dsl.rb +3 -18
  13. data/lib/bundler/fetcher.rb +15 -3
  14. data/lib/bundler/gem_helper.rb +1 -1
  15. data/lib/bundler/gem_installer.rb +9 -0
  16. data/lib/bundler/installer.rb +33 -18
  17. data/lib/bundler/resolver.rb +19 -7
  18. data/lib/bundler/rubygems_ext.rb +3 -1
  19. data/lib/bundler/rubygems_integration.rb +37 -4
  20. data/lib/bundler/runtime.rb +47 -15
  21. data/lib/bundler/settings.rb +1 -3
  22. data/lib/bundler/source.rb +23 -23
  23. data/lib/bundler/ui.rb +9 -9
  24. data/lib/bundler/version.rb +1 -1
  25. data/man/bundle-install.ronn +3 -3
  26. data/man/bundle.ronn +0 -6
  27. data/man/gemfile.5.ronn +2 -2
  28. data/spec/bundler/dsl_spec.rb +22 -0
  29. data/spec/{other → bundler}/gem_helper_spec.rb +7 -0
  30. data/spec/install/deprecated_spec.rb +2 -3
  31. data/spec/install/gems/dependency_api_spec.rb +13 -2
  32. data/spec/install/gems/groups_spec.rb +14 -0
  33. data/spec/install/gems/simple_case_spec.rb +34 -1
  34. data/spec/install/gems/standalone_spec.rb +24 -10
  35. data/spec/lock/lockfile_spec.rb +48 -15
  36. data/spec/other/clean_spec.rb +236 -37
  37. data/spec/other/exec_spec.rb +6 -0
  38. data/spec/other/help_spec.rb +2 -1
  39. data/spec/other/newgem_spec.rb +18 -0
  40. data/spec/other/outdated_spec.rb +19 -2
  41. data/spec/other/show_spec.rb +6 -0
  42. data/spec/runtime/setup_spec.rb +19 -0
  43. data/spec/support/builders.rb +10 -1
  44. data/spec/update/gems_spec.rb +3 -2
  45. metadata +90 -17
@@ -70,10 +70,9 @@ describe "the lockfile format" do
70
70
  G
71
71
  end
72
72
 
73
- it "parses lockfiles w/ crazy shit" do
73
+ it "generates lockfiles with multiple requirements" do
74
74
  install_gemfile <<-G
75
75
  source "file://#{gem_repo1}"
76
-
77
76
  gem "net-sftp"
78
77
  G
79
78
 
@@ -671,13 +670,18 @@ describe "the lockfile format" do
671
670
 
672
671
  end
673
672
 
674
- context "line endings" do
673
+ describe "line endings" do
674
+ def set_lockfile_mtime_to_known_value
675
+ time = Time.local(2000, 1, 1, 0, 0, 0)
676
+ File.utime(time, time, bundled_app('Gemfile.lock'))
677
+ end
675
678
  before(:each) do
676
679
  build_repo2
677
680
  install_gemfile <<-G
678
681
  source "file://#{gem_repo2}"
679
682
  gem "rack"
680
683
  G
684
+ set_lockfile_mtime_to_known_value
681
685
  end
682
686
 
683
687
  it "generates Gemfile.lock with \\n line endings" do
@@ -685,22 +689,51 @@ describe "the lockfile format" do
685
689
  should_be_installed "rack 1.0"
686
690
  end
687
691
 
688
- it "preserves Gemfile.lock \\n line endings" do
689
- update_repo2
692
+ context "during updates" do
690
693
 
691
- bundle "update"
692
- File.read(bundled_app("Gemfile.lock")).should_not match("\r\n")
693
- should_be_installed "rack 1.2"
694
+ it "preserves Gemfile.lock \\n line endings" do
695
+ update_repo2
696
+
697
+ lambda { bundle "update" }.should change { File.mtime(bundled_app('Gemfile.lock')) }
698
+ File.read(bundled_app("Gemfile.lock")).should_not match("\r\n")
699
+ should_be_installed "rack 1.2"
700
+ end
701
+
702
+ it "preserves Gemfile.lock \\n\\r line endings" do
703
+ update_repo2
704
+ win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
705
+ File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) }
706
+ set_lockfile_mtime_to_known_value
707
+
708
+ lambda { bundle "update" }.should change { File.mtime(bundled_app('Gemfile.lock')) }
709
+ File.read(bundled_app("Gemfile.lock")).should match("\r\n")
710
+ should_be_installed "rack 1.2"
711
+ end
694
712
  end
695
713
 
696
- it "preserves Gemfile.lock \\n\\r line endings" do
697
- update_repo2
698
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
699
- File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) }
714
+ context "when nothing changes" do
700
715
 
701
- bundle "update"
702
- File.read(bundled_app("Gemfile.lock")).should match("\r\n")
703
- should_be_installed "rack 1.2"
716
+ it "preserves Gemfile.lock \\n line endings" do
717
+ lambda { ruby <<-RUBY
718
+ require 'rubygems'
719
+ require 'bundler'
720
+ Bundler.setup
721
+ RUBY
722
+ }.should_not change { File.mtime(bundled_app('Gemfile.lock')) }
723
+ end
724
+
725
+ it "preserves Gemfile.lock \\n\\r line endings" do
726
+ win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
727
+ File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) }
728
+ set_lockfile_mtime_to_known_value
729
+
730
+ lambda { ruby <<-RUBY
731
+ require 'rubygems'
732
+ require 'bundler'
733
+ Bundler.setup
734
+ RUBY
735
+ }.should_not change { File.mtime(bundled_app('Gemfile.lock')) }
736
+ end
704
737
  end
705
738
  end
706
739
  end
@@ -9,94 +9,99 @@ describe "bundle clean" do
9
9
  end
10
10
  end
11
11
 
12
- def should_not_have_gem(rubygem)
13
- vendored_gems("gems/#{rubygem}").should_not exist
14
- vendored_gems("specifications/#{rubygem}.gemspec").should_not exist
15
- vendored_gems("cache/#{rubygem}.gem").should_not exist
12
+ def should_not_have_gems(*gems)
13
+ gems.each do |g|
14
+ vendored_gems("gems/#{g}").should_not exist
15
+ vendored_gems("specifications/#{g}.gemspec").should_not exist
16
+ vendored_gems("cache/#{g}.gem").should_not exist
17
+ end
16
18
  end
17
19
 
18
20
  it "removes unused gems that are different" do
19
- gemfile = <<-G
21
+ gemfile <<-G
20
22
  source "file://#{gem_repo1}"
21
23
 
22
24
  gem "thin"
23
25
  gem "foo"
24
26
  G
25
27
 
26
- install_gemfile(gemfile, :path => "vendor/bundle")
28
+ bundle "install --path vendor/bundle --no-clean"
27
29
 
28
- install_gemfile <<-G
30
+ gemfile <<-G
29
31
  source "file://#{gem_repo1}"
30
32
 
31
33
  gem "thin"
32
34
  G
35
+ bundle "install --no-clean"
33
36
 
34
37
  bundle :clean
35
38
 
36
- out.should == "Removing foo (1.0)"
39
+ out.should eq("Removing foo (1.0)")
37
40
 
38
41
  should_have_gems 'thin-1.0', 'rack-1.0.0'
39
- should_not_have_gem 'foo-1.0'
42
+ should_not_have_gems 'foo-1.0'
40
43
 
41
44
  vendored_gems("bin/rackup").should exist
42
45
  end
43
46
 
44
47
  it "removes old version of gem if unused" do
45
- gemfile = <<-G
48
+ gemfile <<-G
46
49
  source "file://#{gem_repo1}"
47
50
 
48
51
  gem "rack", "0.9.1"
49
52
  gem "foo"
50
53
  G
51
54
 
52
- install_gemfile(gemfile, :path => "vendor/bundle")
55
+ bundle "install --path vendor/bundle --no-clean"
53
56
 
54
- install_gemfile <<-G
57
+ gemfile <<-G
55
58
  source "file://#{gem_repo1}"
56
59
 
57
60
  gem "rack", "1.0.0"
58
61
  gem "foo"
59
62
  G
63
+ bundle "install --no-clean"
60
64
 
61
65
  bundle :clean
62
66
 
63
- out.should == "Removing rack (0.9.1)"
67
+ out.should eq("Removing rack (0.9.1)")
64
68
 
65
69
  should_have_gems 'foo-1.0', 'rack-1.0.0'
66
- should_not_have_gem 'rack-0.9.1'
70
+ should_not_have_gems 'rack-0.9.1'
67
71
 
68
72
  vendored_gems("bin/rackup").should exist
69
73
  end
70
74
 
71
75
  it "removes new version of gem if unused" do
72
- gemfile = <<-G
76
+ gemfile <<-G
73
77
  source "file://#{gem_repo1}"
74
78
 
75
79
  gem "rack", "1.0.0"
76
80
  gem "foo"
77
81
  G
78
82
 
79
- install_gemfile(gemfile, :path => "vendor/bundle")
83
+ bundle "install --path vendor/bundle --no-clean"
80
84
 
81
- install_gemfile <<-G
85
+ gemfile <<-G
82
86
  source "file://#{gem_repo1}"
83
87
 
84
88
  gem "rack", "0.9.1"
85
89
  gem "foo"
86
90
  G
91
+ bundle "install --no-clean"
87
92
 
88
93
  bundle :clean
89
94
 
90
- out.should == "Removing rack (1.0.0)"
95
+ out.should eq("Removing rack (1.0.0)")
91
96
 
92
97
  should_have_gems 'foo-1.0', 'rack-0.9.1'
93
- should_not_have_gem 'rack-1.0.0'
98
+ should_not_have_gems 'rack-1.0.0'
94
99
 
95
100
  vendored_gems("bin/rackup").should exist
96
101
  end
97
102
 
98
103
  it "remove gems in bundle without groups" do
99
- gemfile = <<-G
104
+ gemfile <<-G
100
105
  source "file://#{gem_repo1}"
101
106
 
102
107
  gem "foo"
@@ -106,45 +111,71 @@ describe "bundle clean" do
106
111
  end
107
112
  G
108
113
 
109
- install_gemfile(gemfile, :path => "vendor/bundle")
110
- bundle "install --without test_group"
114
+ bundle "install --path vendor/bundle --no-clean"
115
+ bundle "install --without test_group --no-clean"
111
116
  bundle :clean
112
117
 
113
- out.should == "Removing rack (1.0.0)"
118
+ out.should eq("Removing rack (1.0.0)")
114
119
 
115
120
  should_have_gems 'foo-1.0'
116
- should_not_have_gem 'rack-1.0.0'
121
+ should_not_have_gems 'rack-1.0.0'
117
122
 
118
123
  vendored_gems("bin/rackup").should_not exist
119
124
  end
120
125
 
126
+ it "does not remove cached git dir if it's being used" do
127
+ build_git "foo"
128
+ revision = revision_for(lib_path("foo-1.0"))
129
+ git_path = lib_path('foo-1.0')
130
+
131
+ gemfile <<-G
132
+ source "file://#{gem_repo1}"
133
+
134
+ gem "rack", "1.0.0"
135
+ git "#{git_path}", :ref => "#{revision}" do
136
+ gem "foo"
137
+ end
138
+ G
139
+
140
+ bundle "install --path vendor/bundle --no-clean"
141
+
142
+ bundle :clean
143
+
144
+ digest = Digest::SHA1.hexdigest(git_path.to_s)
145
+ vendored_gems("cache/bundler/git/foo-1.0-#{digest}").should exist
146
+ end
147
+
121
148
  it "removes unused git gems" do
122
149
  build_git "foo"
123
- @revision = revision_for(lib_path("foo-1.0"))
150
+ revision = revision_for(lib_path("foo-1.0"))
151
+ git_path = lib_path('foo-1.0')
124
152
 
125
- gemfile = <<-G
153
+ gemfile <<-G
126
154
  source "file://#{gem_repo1}"
127
155
 
128
156
  gem "rack", "1.0.0"
129
- git "#{lib_path('foo-1.0')}", :ref => "#{@revision}" do
157
+ git "#{git_path}", :ref => "#{revision}" do
130
158
  gem "foo"
131
159
  end
132
160
  G
133
161
 
134
- install_gemfile(gemfile, :path => "vendor/bundle")
162
+ bundle "install --path vendor/bundle --no-clean"
135
163
 
136
- install_gemfile <<-G
164
+ gemfile <<-G
137
165
  source "file://#{gem_repo1}"
138
166
 
139
167
  gem "rack", "1.0.0"
140
168
  G
169
+ bundle "install --no-clean"
141
170
 
142
171
  bundle :clean
143
172
 
144
- out.should == "Removing foo (1.0 #{@revision[0..11]})"
173
+ out.should eq("Removing foo (1.0 #{revision[0..11]})")
145
174
 
146
175
  vendored_gems("gems/rack-1.0.0").should exist
147
- vendored_gems("bundler/gems/foo-1.0-#{@revision[0..11]}").should_not exist
176
+ vendored_gems("bundler/gems/foo-1.0-#{revision[0..11]}").should_not exist
177
+ digest = Digest::SHA1.hexdigest(git_path.to_s)
178
+ vendored_gems("cache/bundler/git/foo-1.0-#{digest}").should_not exist
148
179
 
149
180
  vendored_gems("specifications/rack-1.0.0.gemspec").should exist
150
181
 
@@ -155,7 +186,7 @@ describe "bundle clean" do
155
186
  build_git "foo"
156
187
  revision = revision_for(lib_path("foo-1.0"))
157
188
 
158
- gemfile = <<-G
189
+ gemfile <<-G
159
190
  source "file://#{gem_repo1}"
160
191
 
161
192
  gem "rack", "1.0.0"
@@ -164,16 +195,15 @@ describe "bundle clean" do
164
195
  end
165
196
  G
166
197
 
167
- install_gemfile(gemfile, :path => "vendor/bundle")
198
+ bundle "install --path vendor/bundle --no-clean"
168
199
 
169
200
  update_git "foo"
170
201
  revision2 = revision_for(lib_path("foo-1.0"))
171
202
 
172
- bundle :update
173
- bundle :install
203
+ bundle "update --no-clean"
174
204
  bundle :clean
175
205
 
176
- out.should == "Removing foo (1.0 #{revision[0..11]})"
206
+ out.should eq("Removing foo (1.0 #{revision[0..11]})")
177
207
 
178
208
  vendored_gems("gems/rack-1.0.0").should exist
179
209
  vendored_gems("bundler/gems/foo-1.0-#{revision[0..11]}").should_not exist
@@ -184,6 +214,24 @@ describe "bundle clean" do
184
214
  vendored_gems("bin/rackup").should exist
185
215
  end
186
216
 
217
+ it "does not remove nested gems in a git repo" do
218
+ build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport")
219
+ build_git "rails", "3.0", :path => lib_path("rails") do |s|
220
+ s.add_dependency "activesupport", "= 3.0"
221
+ end
222
+ revision = revision_for(lib_path("rails"))
223
+
224
+ gemfile <<-G
225
+ gem "activesupport", :git => "#{lib_path('rails')}", :ref => '#{revision}'
226
+ G
227
+
228
+ bundle "install --path vendor/bundle --no-clean"
229
+ bundle :clean
230
+ out.should eq("")
231
+
232
+ vendored_gems("bundler/gems/rails-#{revision[0..11]}").should exist
233
+ end
234
+
187
235
  it "displays an error when used without --path" do
188
236
  install_gemfile <<-G
189
237
  source "file://#{gem_repo1}"
@@ -193,6 +241,157 @@ describe "bundle clean" do
193
241
 
194
242
  bundle :clean
195
243
 
196
- out.should == "Can only use bundle clean when --path is set"
244
+ out.should == "Can only use bundle clean when --path is set or --force is set"
245
+ end
246
+
247
+ # handling bundle clean upgrade path from the pre's
248
+ it "removes .gem/.gemspec file even if there's no corresponding gem dir is already moved" do
249
+ gemfile <<-G
250
+ source "file://#{gem_repo1}"
251
+
252
+ gem "thin"
253
+ gem "foo"
254
+ G
255
+
256
+ bundle "install --path vendor/bundle --no-clean"
257
+
258
+ gemfile <<-G
259
+ source "file://#{gem_repo1}"
260
+
261
+ gem "foo"
262
+ G
263
+ bundle "install --no-clean"
264
+
265
+ FileUtils.rm(vendored_gems("bin/rackup"))
266
+ FileUtils.rm_rf(vendored_gems("gems/thin-1.0"))
267
+ FileUtils.rm_rf(vendored_gems("gems/rack-1.0.0"))
268
+
269
+ bundle :clean
270
+
271
+ should_not_have_gems 'thin-1.0', 'rack-1.0'
272
+ should_have_gems 'foo-1.0'
273
+
274
+ vendored_gems("bin/rackup").should_not exist
275
+ end
276
+
277
+ it "does not call clean automatically when using system gems" do
278
+ gemfile <<-G
279
+ source "file://#{gem_repo1}"
280
+
281
+ gem "thin"
282
+ gem "rack"
283
+ G
284
+ bundle :install
285
+
286
+ gemfile <<-G
287
+ source "file://#{gem_repo1}"
288
+
289
+ gem "rack"
290
+ G
291
+ bundle :install
292
+
293
+ sys_exec "gem list"
294
+ out.should include("rack (1.0.0)")
295
+ out.should include("thin (1.0)")
296
+ end
297
+
298
+ it "--clean should override the bundle setting" do
299
+ gemfile <<-G
300
+ source "file://#{gem_repo1}"
301
+
302
+ gem "thin"
303
+ gem "rack"
304
+ G
305
+ bundle "install --path vendor/bundle --no-clean"
306
+
307
+ gemfile <<-G
308
+ source "file://#{gem_repo1}"
309
+
310
+ gem "rack"
311
+ G
312
+ bundle "install --clean"
313
+
314
+ should_have_gems 'rack-1.0.0'
315
+ should_not_have_gems 'thin-1.0'
316
+ end
317
+
318
+ it "clean automatically on --path" do
319
+ gemfile <<-G
320
+ source "file://#{gem_repo1}"
321
+
322
+ gem "thin"
323
+ gem "rack"
324
+ G
325
+ bundle "install --path vendor/bundle"
326
+
327
+ gemfile <<-G
328
+ source "file://#{gem_repo1}"
329
+
330
+ gem "rack"
331
+ G
332
+ bundle "install"
333
+
334
+ should_have_gems 'rack-1.0.0'
335
+ should_not_have_gems 'thin-1.0'
336
+ end
337
+
338
+ it "cleans on bundle update with --path" do
339
+ build_repo2
340
+
341
+ gemfile <<-G
342
+ source "file://#{gem_repo2}"
343
+
344
+ gem "foo"
345
+ G
346
+ bundle "install --path vendor/bundle"
347
+
348
+ update_repo2 do
349
+ build_gem 'foo', '1.0.1'
350
+ end
351
+
352
+ bundle :update
353
+ should_not_have_gems 'foo-1.0'
354
+ end
355
+
356
+ it "does not clean on bundle update when using --system" do
357
+ build_repo2
358
+
359
+ gemfile <<-G
360
+ source "file://#{gem_repo2}"
361
+
362
+ gem "foo"
363
+ G
364
+ bundle "install"
365
+
366
+ update_repo2 do
367
+ build_gem 'foo', '1.0.1'
368
+ end
369
+ bundle :update
370
+
371
+ sys_exec "gem list"
372
+ out.should include("foo (1.0.1, 1.0)")
373
+ end
374
+
375
+ it "cleans system gems when --force is used" do
376
+ gemfile <<-G
377
+ source "file://#{gem_repo1}"
378
+
379
+ gem "foo"
380
+ gem "rack"
381
+ G
382
+ bundle :install
383
+
384
+ gemfile <<-G
385
+ source "file://#{gem_repo1}"
386
+
387
+ gem "rack"
388
+ G
389
+ bundle :install
390
+ bundle "clean --force"
391
+
392
+ out.should eq("Removing foo (1.0)")
393
+ sys_exec "gem list"
394
+ out.should_not include("foo (1.0)")
395
+ out.should include("rack (1.0.0)")
197
396
  end
198
397
  end