1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
|
# frozen_string_literal: true
RSpec.describe "bundle update" do
describe "with no arguments" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "updates the entire bundle" do
update_repo2 do
build_gem "rack", "1.2" do |s|
s.executables = "rackup"
end
build_gem "activesupport", "3.0"
end
bundle "update"
expect(out).to include("Bundle updated!")
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
it "doesn't delete the Gemfile.lock file if something goes wrong" do
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
exit!
G
bundle "update", :raise_on_error => false
expect(bundled_app_lock).to exist
end
end
describe "with --all" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "updates the entire bundle" do
update_repo2 do
build_gem "rack", "1.2" do |s|
s.executables = "rackup"
end
build_gem "activesupport", "3.0"
end
bundle "update", :all => true
expect(out).to include("Bundle updated!")
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
it "doesn't delete the Gemfile.lock file if something goes wrong" do
install_gemfile ""
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
exit!
G
bundle "update", :all => true, :raise_on_error => false
expect(bundled_app_lock).to exist
end
end
describe "with --gemfile" do
it "creates lock files based on the Gemfile name" do
gemfile bundled_app("OmgFile"), <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack", "1.0"
G
bundle "update --gemfile OmgFile", :all => true
expect(bundled_app("OmgFile.lock")).to exist
end
end
context "when update_requires_all_flag is set" do
before { bundle "config set update_requires_all_flag true" }
it "errors when passed nothing" do
install_gemfile ""
bundle :update, :raise_on_error => false
expect(err).to eq("To update everything, pass the `--all` flag.")
end
it "errors when passed --all and another option" do
install_gemfile ""
bundle "update --all foo", :raise_on_error => false
expect(err).to eq("Cannot specify --all along with specific options.")
end
it "updates everything when passed --all" do
install_gemfile ""
bundle "update --all"
expect(out).to include("Bundle updated!")
end
end
describe "--quiet argument" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "hides UI messages" do
bundle "update --quiet"
expect(out).not_to include("Bundle updated!")
end
end
describe "with a top level dependency" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "unlocks all child dependencies that are unrelated to other locked dependencies" do
update_repo2 do
build_gem "rack", "1.2" do |s|
s.executables = "rackup"
end
build_gem "activesupport", "3.0"
end
bundle "update rack-obama"
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 2.3.5"
end
end
describe "with an unknown dependency" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "should inform the user" do
bundle "update halting-problem-solver", :raise_on_error => false
expect(err).to include "Could not find gem 'halting-problem-solver'"
end
it "should suggest alternatives" do
bundle "update platformspecific", :raise_on_error => false
expect(err).to include "Did you mean platform_specific?"
end
end
describe "with a child dependency" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "should update the child dependency" do
update_repo2 do
build_gem "rack", "1.2" do |s|
s.executables = "rackup"
end
end
bundle "update rack"
expect(the_bundle).to include_gems "rack 1.2"
end
end
describe "when a possible resolve requires an older version of a locked gem" do
it "does not go to an older version" do
build_repo4 do
build_gem "tilt", "2.0.8"
build_gem "slim", "3.0.9" do |s|
s.add_dependency "tilt", [">= 1.3.3", "< 2.1"]
end
build_gem "slim_lint", "0.16.1" do |s|
s.add_dependency "slim", [">= 3.0", "< 5.0"]
end
build_gem "slim-rails", "0.2.1" do |s|
s.add_dependency "slim", ">= 0.9.2"
end
build_gem "slim-rails", "3.1.3" do |s|
s.add_dependency "slim", "~> 3.0"
end
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "slim-rails"
gem "slim_lint"
G
expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")
update_repo4 do
build_gem "slim", "4.0.0" do |s|
s.add_dependency "tilt", [">= 2.0.6", "< 2.1"]
end
end
bundle "update", :all => true
expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")
end
it "should still downgrade if forced by the Gemfile" do
build_repo4 do
build_gem "a"
build_gem "b", "1.0"
build_gem "b", "2.0"
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "a"
gem "b"
G
expect(the_bundle).to include_gems("a 1.0", "b 2.0")
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "a"
gem "b", "1.0"
G
bundle "update b"
expect(the_bundle).to include_gems("a 1.0", "b 1.0")
end
end
describe "with --local option" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "doesn't hit repo2" do
FileUtils.rm_rf(gem_repo2)
bundle "update --local --all"
expect(out).not_to include("Fetching source index")
end
end
describe "with --group option" do
before do
build_repo2
end
it "should update only specified group gems" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport", :group => :development
gem "rack"
G
update_repo2 do
build_gem "rack", "1.2" do |s|
s.executables = "rackup"
end
build_gem "activesupport", "3.0"
end
bundle "update --group development"
expect(the_bundle).to include_gems "activesupport 3.0"
expect(the_bundle).not_to include_gems "rack 1.2"
end
context "when conservatively updating a group with non-group sub-deps" do
it "should update only specified group gems" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activemerchant", :group => :development
gem "activesupport"
G
update_repo2 do
build_gem "activemerchant", "2.0"
build_gem "activesupport", "3.0"
end
bundle "update --conservative --group development"
expect(the_bundle).to include_gems "activemerchant 2.0"
expect(the_bundle).not_to include_gems "activesupport 3.0"
end
end
context "when there is a source with the same name as a gem in a group" do
before do
build_git "foo", :path => lib_path("activesupport")
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport", :group => :development
gem "foo", :git => "#{lib_path("activesupport")}"
G
end
it "should not update the gems from that source" do
update_repo2 { build_gem "activesupport", "3.0" }
update_git "foo", "2.0", :path => lib_path("activesupport")
bundle "update --group development"
expect(the_bundle).to include_gems "activesupport 3.0"
expect(the_bundle).not_to include_gems "foo 2.0"
end
end
context "when bundler itself is a transitive dependency" do
it "executes without error" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "activesupport", :group => :development
gem "rack"
G
update_repo2 do
build_gem "rack", "1.2" do |s|
s.executables = "rackup"
end
build_gem "activesupport", "3.0"
end
bundle "update --group development"
expect(the_bundle).to include_gems "activesupport 2.3.5"
expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}"
expect(the_bundle).not_to include_gems "rack 1.2"
end
end
end
describe "in a frozen bundle" do
before do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
gem "rack-obama"
gem "platform_specific"
G
end
it "should fail loudly", :bundler => "< 3" do
bundle "install --deployment"
bundle "update", :all => true, :raise_on_error => false
expect(last_command).to be_failure
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
expect(err).to match(/freeze \nby running `bundle config unset deployment`./m)
end
it "should suggest different command when frozen is set globally", :bundler => "< 3" do
bundle "config set --global frozen 1"
bundle "update", :all => true, :raise_on_error => false
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config unset frozen`./m)
end
it "should suggest different command when frozen is set globally", :bundler => "3" do
bundle "config set --global deployment true"
bundle "update", :all => true, :raise_on_error => false
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config unset deployment`./m)
end
end
describe "with --source option" do
before do
build_repo2
end
it "should not update gems not included in the source that happen to have the same name", :bundler => "< 3" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
G
update_repo2 { build_gem "activesupport", "3.0" }
bundle "update --source activesupport"
expect(the_bundle).to include_gem "activesupport 3.0"
end
it "should not update gems not included in the source that happen to have the same name", :bundler => "3" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
G
update_repo2 { build_gem "activesupport", "3.0" }
bundle "update --source activesupport"
expect(the_bundle).not_to include_gem "activesupport 3.0"
end
context "with unlock_source_unlocks_spec set to false" do
before { bundle "config set unlock_source_unlocks_spec false" }
it "should not update gems not included in the source that happen to have the same name" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
G
update_repo2 { build_gem "activesupport", "3.0" }
bundle "update --source activesupport"
expect(the_bundle).not_to include_gems "activesupport 3.0"
end
end
end
context "when there is a child dependency that is also in the gemfile" do
before do
build_repo2 do
build_gem "fred", "1.0"
build_gem "harry", "1.0" do |s|
s.add_dependency "fred"
end
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "harry"
gem "fred"
G
end
it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do
update_repo2 do
build_gem "fred", "2.0"
build_gem "harry", "2.0" do |s|
s.add_dependency "fred"
end
end
bundle "update --source harry"
expect(the_bundle).to include_gems "harry 2.0"
expect(the_bundle).to include_gems "fred 1.0"
end
it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do
update_repo2 do
build_gem "fred", "2.0"
build_gem "harry", "2.0" do |s|
s.add_dependency "fred"
end
end
bundle "update --source harry"
expect(the_bundle).to include_gems "harry 1.0", "fred 1.0"
end
end
context "when there is a child dependency that appears elsewhere in the dependency graph" do
before do
build_repo2 do
build_gem "fred", "1.0" do |s|
s.add_dependency "george"
end
build_gem "george", "1.0"
build_gem "harry", "1.0" do |s|
s.add_dependency "george"
end
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "harry"
gem "fred"
G
end
it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do
update_repo2 do
build_gem "george", "2.0"
build_gem "harry", "2.0" do |s|
s.add_dependency "george"
end
end
bundle "update --source harry"
expect(the_bundle).to include_gems "harry 2.0"
expect(the_bundle).to include_gems "fred 1.0"
expect(the_bundle).to include_gems "george 1.0"
end
it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do
update_repo2 do
build_gem "george", "2.0"
build_gem "harry", "2.0" do |s|
s.add_dependency "george"
end
end
bundle "update --source harry"
expect(the_bundle).to include_gems "harry 1.0", "fred 1.0", "george 1.0"
end
end
it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
G
bundle "update", :all => true
expect(out).to include("Using activesupport 2.3.5")
update_repo2 do
build_gem "activesupport", "3.0"
end
bundle "update", :all => true
expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
end
context "with suppress_install_using_messages set" do
before { bundle "config set suppress_install_using_messages true" }
it "only prints `Using` for versions that have changed" do
build_repo4 do
build_gem "bar"
build_gem "foo"
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "bar"
gem "foo"
G
bundle "update", :all => true
expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/)
update_repo4 do
build_gem "foo", "2.0"
end
bundle "update", :all => true
out.sub!("Removing foo (1.0)\n", "")
expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/)
end
end
it "shows error message when Gemfile.lock is not preset and gem is specified" do
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "activesupport"
G
bundle "update nonexisting", :raise_on_error => false
expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
expect(exitstatus).to eq(22)
end
context "with multiple, duplicated sources, with lockfile in old format", :bundler => "< 3" do
before do
build_repo2 do
build_gem "dotenv", "2.7.6"
build_gem "oj", "3.11.3"
build_gem "oj", "3.11.5"
build_gem "vcr", "6.0.0"
end
build_repo gem_repo3 do
build_gem "pkg-gem-flowbyte-with-dep", "1.0.0" do |s|
s.add_dependency "oj"
end
end
gemfile <<~G
source "https://gem.repo2"
gem "dotenv"
source "https://gem.repo3" do
gem 'pkg-gem-flowbyte-with-dep'
end
gem "vcr",source: "https://gem.repo2"
G
lockfile <<~L
GEM
remote: https://gem.repo2/
remote: https://gem.repo3/
specs:
dotenv (2.7.6)
oj (3.11.3)
pkg-gem-flowbyte-with-dep (1.0.0)
oj
vcr (6.0.0)
PLATFORMS
#{specific_local_platform}
DEPENDENCIES
dotenv
pkg-gem-flowbyte-with-dep!
vcr!
BUNDLED WITH
#{Bundler::VERSION}
L
end
it "works" do
bundle :install, :artifice => "compact_index"
bundle "update oj", :artifice => "compact_index"
expect(out).to include("Bundle updated!")
expect(the_bundle).to include_gems "oj 3.11.5"
end
end
end
RSpec.describe "bundle update in more complicated situations" do
before do
build_repo2
end
it "will eagerly unlock dependencies of a specified gem" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "thin"
gem "rack-obama"
G
update_repo2 do
build_gem "rack", "1.2" do |s|
s.executables = "rackup"
end
build_gem "thin", "2.0" do |s|
s.add_dependency "rack"
end
end
bundle "update thin"
expect(the_bundle).to include_gems "thin 2.0", "rack 1.2", "rack-obama 1.0"
end
it "will warn when some explicitly updated gems are not updated" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "thin"
gem "rack-obama"
G
update_repo2 do
build_gem("thin", "2.0") {|s| s.add_dependency "rack" }
build_gem "rack", "10.0"
end
bundle "update thin rack-obama"
expect(last_command.stdboth).to include "Bundler attempted to update rack-obama but its version stayed the same"
expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0"
end
it "will not warn when an explicitly updated git gem changes sha but not version" do
build_git "foo"
install_gemfile <<-G
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
update_git "foo" do |s|
s.write "lib/foo2.rb", "puts :foo2"
end
bundle "update foo"
expect(last_command.stdboth).not_to include "attempted to update"
end
it "will not warn when changing gem sources but not versions" do
build_git "rack"
install_gemfile <<-G
gem "rack", :git => '#{lib_path("rack-1.0")}'
G
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G
bundle "update rack"
expect(last_command.stdboth).not_to include "attempted to update"
end
it "will update only from pinned source" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
source "#{file_uri_for(gem_repo1)}" do
gem "thin"
end
G
update_repo2 do
build_gem "thin", "2.0"
end
bundle "update"
expect(the_bundle).to include_gems "thin 1.0"
end
context "when the lockfile is for a different platform" do
before do
build_repo4 do
build_gem("a", "0.9")
build_gem("a", "0.9") {|s| s.platform = "java" }
build_gem("a", "1.1")
build_gem("a", "1.1") {|s| s.platform = "java" }
end
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "a"
G
lockfile <<-L
GEM
remote: #{file_uri_for(gem_repo4)}
specs:
a (0.9-java)
PLATFORMS
java
DEPENDENCIES
a
L
simulate_platform linux
end
it "allows updating" do
bundle :update, :all => true
expect(the_bundle).to include_gem "a 1.1"
end
it "allows updating a specific gem" do
bundle "update a"
expect(the_bundle).to include_gem "a 1.1"
end
end
context "when the dependency is for a different platform" do
before do
build_repo4 do
build_gem("a", "0.9") {|s| s.platform = "java" }
build_gem("a", "1.1") {|s| s.platform = "java" }
end
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "a", platform: :jruby
G
lockfile <<-L
GEM
remote: #{file_uri_for(gem_repo4)}
specs:
a (0.9-java)
PLATFORMS
java
DEPENDENCIES
a
L
simulate_platform linux
end
it "is not updated because it is not actually included in the bundle" do
bundle "update a"
expect(last_command.stdboth).to include "Bundler attempted to update a but it was not considered because it is for a different platform from the current one"
expect(the_bundle).to_not include_gem "a"
end
end
end
RSpec.describe "bundle update without a Gemfile.lock" do
it "should not explode" do
build_repo2
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rack", "1.0"
G
bundle "update", :all => true
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
RSpec.describe "bundle update when a gem depends on a newer version of bundler" do
before do
build_repo2 do
build_gem "rails", "3.0.1" do |s|
s.add_dependency "bundler", Bundler::VERSION.succ
end
build_gem "bundler", Bundler::VERSION.succ
end
gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rails", "3.0.1"
G
end
it "should explain that bundler conflicted and how to resolve the conflict" do
bundle "update", :all => true, :raise_on_error => false
expect(last_command.stdboth).not_to match(/in snapshot/i)
expect(err).to match(/current Bundler version/i).
and match(/Install the necessary version with `gem install bundler:#{Bundler::VERSION.succ}`/i)
end
end
RSpec.describe "bundle update --ruby" do
before do
install_gemfile <<-G
::RUBY_VERSION = '2.1.3'
::RUBY_PATCHLEVEL = 100
ruby '~> 2.1.0'
G
end
context "when the Gemfile removes the ruby" do
before do
gemfile <<-G
::RUBY_VERSION = '2.1.4'
::RUBY_PATCHLEVEL = 222
G
end
it "removes the Ruby from the Gemfile.lock" do
bundle "update --ruby"
lockfile_should_be <<-L
GEM
specs:
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
BUNDLED WITH
#{Bundler::VERSION}
L
end
end
context "when the Gemfile specified an updated Ruby version" do
before do
gemfile <<-G
::RUBY_VERSION = '2.1.4'
::RUBY_PATCHLEVEL = 222
ruby '~> 2.1.0'
G
end
it "updates the Gemfile.lock with the latest version" do
bundle "update --ruby"
lockfile_should_be <<-L
GEM
specs:
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
RUBY VERSION
ruby 2.1.4p222
BUNDLED WITH
#{Bundler::VERSION}
L
end
end
context "when a different Ruby is being used than has been versioned" do
before do
gemfile <<-G
::RUBY_VERSION = '2.2.2'
::RUBY_PATCHLEVEL = 505
ruby '~> 2.1.0'
G
end
it "shows a helpful error message" do
bundle "update --ruby", :raise_on_error => false
expect(err).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
end
end
context "when updating Ruby version and Gemfile `ruby`" do
before do
gemfile <<-G
::RUBY_VERSION = '1.8.3'
::RUBY_PATCHLEVEL = 55
ruby '~> 1.8.0'
G
end
it "updates the Gemfile.lock with the latest version" do
bundle "update --ruby"
lockfile_should_be <<-L
GEM
specs:
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
RUBY VERSION
ruby 1.8.3p55
BUNDLED WITH
#{Bundler::VERSION}
L
end
end
end
RSpec.describe "bundle update --bundler" do
it "updates the bundler version in the lockfile without re-resolving" do
build_repo4 do
build_gem "rack", "1.0"
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "rack"
G
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2')
FileUtils.rm_r gem_repo4
bundle :update, :bundler => true, :verbose => true
expect(the_bundle).to include_gem "rack 1.0"
expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION)
end
end
# these specs are slow and focus on integration and therefore are not exhaustive. unit specs elsewhere handle that.
RSpec.describe "bundle update conservative" do
context "patch and minor options" do
before do
build_repo4 do
build_gem "foo", %w[1.4.3 1.4.4] do |s|
s.add_dependency "bar", "~> 2.0"
end
build_gem "foo", %w[1.4.5 1.5.0] do |s|
s.add_dependency "bar", "~> 2.1"
end
build_gem "foo", %w[1.5.1] do |s|
s.add_dependency "bar", "~> 3.0"
end
build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
build_gem "qux", %w[1.0.0 1.0.1 1.1.0 2.0.0]
end
# establish a lockfile set to 1.4.3
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'foo', '1.4.3'
gem 'bar', '2.0.3'
gem 'qux', '1.0.0'
G
# remove 1.4.3 requirement and bar altogether
# to setup update specs below
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'foo'
gem 'qux'
G
end
context "with patch set as default update level in config" do
it "should do a patch level update" do
bundle "config set --local prefer_patch true"
bundle "update foo"
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
end
end
context "patch preferred" do
it "single gem updates dependent gem to minor" do
bundle "update --patch foo"
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
end
it "update all" do
bundle "update --patch", :all => true
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.1"
end
end
context "minor preferred" do
it "single gem updates dependent gem to major" do
bundle "update --minor foo"
expect(the_bundle).to include_gems "foo 1.5.1", "bar 3.0.0", "qux 1.0.0"
end
end
context "strict" do
it "patch preferred" do
bundle "update --patch foo bar --strict"
expect(the_bundle).to include_gems "foo 1.4.4", "bar 2.0.5", "qux 1.0.0"
end
it "minor preferred" do
bundle "update --minor --strict", :all => true
expect(the_bundle).to include_gems "foo 1.5.0", "bar 2.1.1", "qux 1.1.0"
end
end
end
context "eager unlocking" do
before do
build_repo4 do
build_gem "isolated_owner", %w[1.0.1 1.0.2] do |s|
s.add_dependency "isolated_dep", "~> 2.0"
end
build_gem "isolated_dep", %w[2.0.1 2.0.2]
build_gem "shared_owner_a", %w[3.0.1 3.0.2] do |s|
s.add_dependency "shared_dep", "~> 5.0"
end
build_gem "shared_owner_b", %w[4.0.1 4.0.2] do |s|
s.add_dependency "shared_dep", "~> 5.0"
end
build_gem "shared_dep", %w[5.0.1 5.0.2]
end
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'isolated_owner'
gem 'shared_owner_a'
gem 'shared_owner_b'
G
lockfile <<-L
GEM
remote: #{file_uri_for(gem_repo4)}
specs:
isolated_dep (2.0.1)
isolated_owner (1.0.1)
isolated_dep (~> 2.0)
shared_dep (5.0.1)
shared_owner_a (3.0.1)
shared_dep (~> 5.0)
shared_owner_b (4.0.1)
shared_dep (~> 5.0)
PLATFORMS
ruby
DEPENDENCIES
shared_owner_a
shared_owner_b
isolated_owner
BUNDLED WITH
#{Bundler::VERSION}
L
end
it "should eagerly unlock isolated dependency" do
bundle "update isolated_owner"
expect(the_bundle).to include_gems "isolated_owner 1.0.2", "isolated_dep 2.0.2", "shared_dep 5.0.1", "shared_owner_a 3.0.1", "shared_owner_b 4.0.1"
end
it "should eagerly unlock shared dependency" do
bundle "update shared_owner_a"
expect(the_bundle).to include_gems "isolated_owner 1.0.1", "isolated_dep 2.0.1", "shared_dep 5.0.2", "shared_owner_a 3.0.2", "shared_owner_b 4.0.1"
end
it "should not eagerly unlock with --conservative" do
bundle "update --conservative shared_owner_a isolated_owner"
expect(the_bundle).to include_gems "isolated_owner 1.0.2", "isolated_dep 2.0.2", "shared_dep 5.0.1", "shared_owner_a 3.0.2", "shared_owner_b 4.0.1"
end
it "should match bundle install conservative update behavior when not eagerly unlocking" do
gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'isolated_owner', '1.0.2'
gem 'shared_owner_a', '3.0.2'
gem 'shared_owner_b'
G
bundle "install"
expect(the_bundle).to include_gems "isolated_owner 1.0.2", "isolated_dep 2.0.2", "shared_dep 5.0.1", "shared_owner_a 3.0.2", "shared_owner_b 4.0.1"
end
end
context "error handling" do
before do
gemfile ""
end
it "raises if too many flags are provided" do
bundle "update --patch --minor", :all => true, :raise_on_error => false
expect(err).to eq "Provide only one of the following options: minor, patch"
end
end
end
|