-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathupdate_spec.rb
More file actions
2093 lines (1655 loc) · 51.2 KB
/
Copy pathupdate_spec.rb
File metadata and controls
2093 lines (1655 loc) · 51.2 KB
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
# frozen_string_literal: true
RSpec.describe "bundle update" do
describe "with no arguments" do
before do
build_repo2
install_gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-obama"
gem "platform_specific"
G
end
it "updates the entire bundle" do
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
end
build_gem "activesupport", "3.0"
end
bundle "update"
expect(out).to include("Bundle updated!")
expect(the_bundle).to include_gems "myrack 1.2", "myrack-obama 1.0", "activesupport 3.0"
end
it "doesn't delete the Gemfile.lock file if something goes wrong" do
gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-obama"
exit!
G
bundle "update", raise_on_error: false
expect(bundled_app_lock).to exist
end
end
describe "with --verbose" do
before do
build_repo2
install_gemfile <<~G
source "https://gem.repo2"
gem "myrack"
G
end
it "logs the reason for re-resolving" do
bundle "update --verbose"
expect(out).not_to include("Found changes from the lockfile")
expect(out).to include("Re-resolving dependencies because bundler is unlocking")
end
end
describe "with --all" do
before do
build_repo2
install_gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-obama"
gem "platform_specific"
G
end
it "updates the entire bundle" do
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
end
build_gem "activesupport", "3.0"
end
bundle "update", all: true
expect(out).to include("Bundle updated!")
expect(the_bundle).to include_gems "myrack 1.2", "myrack-obama 1.0", "activesupport 3.0"
end
it "doesn't delete the Gemfile.lock file if something goes wrong" do
install_gemfile "source 'https://gem.repo1'"
gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-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 lockfiles based on the Gemfile name" do
gemfile bundled_app("OmgFile"), <<-G
source "https://gem.repo1"
gem "myrack", "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 "source 'https://gem.repo1'"
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 "source 'https://gem.repo1'"
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 "source 'https://gem.repo1'"
bundle "update --all"
expect(out).to include("Bundle updated!")
end
end
describe "--quiet argument" do
before do
build_repo2
install_gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-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 "https://gem.repo2"
gem "activesupport"
gem "myrack-obama"
gem "platform_specific"
G
end
it "unlocks all child dependencies that are unrelated to other locked dependencies" do
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
end
build_gem "activesupport", "3.0"
end
bundle "update myrack-obama"
expect(the_bundle).to include_gems "myrack 1.2", "myrack-obama 1.0", "activesupport 2.3.5"
end
end
describe "with an unknown dependency" do
before do
build_repo2
install_gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-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 "https://gem.repo2"
gem "activesupport"
gem "myrack-obama"
gem "platform_specific"
G
end
it "should update the child dependency" do
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
end
end
bundle "update myrack"
expect(the_bundle).to include_gems "myrack 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 "https://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")
build_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 "does not go to an older version, even if the version upgrade that could cause another gem to downgrade is activated first" do
build_repo4 do
# countries is processed before country_select by the resolver due to having less spec groups (groups of versions with the same dependencies) (2 vs 3)
build_gem "countries", "2.1.4"
build_gem "countries", "3.1.0"
build_gem "countries", "4.0.0" do |s|
s.add_dependency "sixarm_ruby_unaccent", "~> 1.1"
end
build_gem "country_select", "1.2.0"
build_gem "country_select", "2.1.4" do |s|
s.add_dependency "countries", "~> 2.0"
end
build_gem "country_select", "3.1.1" do |s|
s.add_dependency "countries", "~> 2.0"
end
build_gem "country_select", "5.1.0" do |s|
s.add_dependency "countries", "~> 3.0"
end
build_gem "sixarm_ruby_unaccent", "1.1.0"
end
gemfile <<~G
source "https://gem.repo4"
gem "country_select"
gem "countries"
G
checksums = checksums_section_when_enabled do |c|
c.checksum(gem_repo4, "countries", "3.1.0")
c.checksum(gem_repo4, "country_select", "5.1.0")
end
lockfile <<~L
GEM
remote: https://gem.repo4/
specs:
countries (3.1.0)
country_select (5.1.0)
countries (~> 3.0)
PLATFORMS
#{local_platform}
DEPENDENCIES
countries
country_select
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
L
previous_lockfile = lockfile
bundle "lock --update", env: { "DEBUG" => "1" }, verbose: true
expect(lockfile).to eq(previous_lockfile)
end
it "does not downgrade direct dependencies when run with --conservative" do
build_repo4 do
build_gem "oauth2", "2.0.6" do |s|
s.add_dependency "faraday", ">= 0.17.3", "< 3.0"
end
build_gem "oauth2", "1.4.10" do |s|
s.add_dependency "faraday", ">= 0.17.3", "< 3.0"
s.add_dependency "multi_json", "~> 1.3"
end
build_gem "faraday", "2.5.2"
build_gem "multi_json", "1.15.0"
build_gem "quickbooks-ruby", "1.0.19" do |s|
s.add_dependency "oauth2", "~> 1.4"
end
build_gem "quickbooks-ruby", "0.1.9" do |s|
s.add_dependency "oauth2"
end
end
gemfile <<-G
source "https://gem.repo4"
gem "oauth2"
gem "quickbooks-ruby"
G
lockfile <<~L
GEM
remote: https://gem.repo4/
specs:
faraday (2.5.2)
multi_json (1.15.0)
oauth2 (1.4.10)
faraday (>= 0.17.3, < 3.0)
multi_json (~> 1.3)
quickbooks-ruby (1.0.19)
oauth2 (~> 1.4)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
oauth2
quickbooks-ruby
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "update --conservative --verbose"
expect(out).not_to include("Installing quickbooks-ruby 0.1.9")
expect(out).to include("Installing quickbooks-ruby 1.0.19").and include("Installing oauth2 1.4.10")
end
it "does not downgrade direct dependencies when using gemspec sources" do
create_file("rails.gemspec", <<-G)
Gem::Specification.new do |gem|
gem.name = "rails"
gem.version = "7.1.0.alpha"
gem.author = "DHH"
gem.summary = "Full-stack web application framework."
end
G
build_repo4 do
build_gem "rake", "12.3.3"
build_gem "rake", "13.0.6"
build_gem "sneakers", "2.11.0" do |s|
s.add_dependency "rake"
end
build_gem "sneakers", "2.12.0" do |s|
s.add_dependency "rake", "~> 12.3"
end
end
gemfile <<-G
source "https://gem.repo4"
gemspec
gem "rake"
gem "sneakers"
G
lockfile <<~L
PATH
remote: .
specs:
GEM
remote: https://gem.repo4/
specs:
rake (13.0.6)
sneakers (2.11.0)
rake
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rake
sneakers
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "update --verbose"
expect(out).not_to include("Installing sneakers 2.12.0")
expect(out).not_to include("Installing rake 12.3.3")
expect(out).to include("Installing sneakers 2.11.0").and include("Installing rake 13.0.6")
end
it "downgrades indirect dependencies if required to fulfill an explicit upgrade request" do
build_repo4 do
build_gem "rbs", "3.6.1"
build_gem "rbs", "3.9.4"
build_gem "solargraph", "0.56.0" do |s|
s.add_dependency "rbs", "~> 3.3"
end
build_gem "solargraph", "0.56.2" do |s|
s.add_dependency "rbs", "~> 3.6.1"
end
end
gemfile <<~G
source "https://gem.repo4"
gem 'solargraph', '~> 0.56.0'
G
lockfile <<~L
GEM
remote: https://gem.repo4/
specs:
rbs (3.9.4)
solargraph (0.56.0)
rbs (~> 3.3)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
solargraph (~> 0.56.0)
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "lock --update solargraph"
expect(lockfile).to include("solargraph (0.56.2)")
end
it "does not downgrade direct dependencies unnecessarily" do
build_repo4 do
build_gem "redis", "4.8.1"
build_gem "redis", "5.3.0"
build_gem "sidekiq", "6.5.5" do |s|
s.add_dependency "redis", ">= 4.5.0"
end
build_gem "sidekiq", "6.5.12" do |s|
s.add_dependency "redis", ">= 4.5.0", "< 5"
end
# one version of sidekiq above Gemfile's range is needed to make the
# resolver choose `redis` first and trying to upgrade it, reproducing
# the accidental sidekiq downgrade as a result
build_gem "sidekiq", "7.0.0 " do |s|
s.add_dependency "redis", ">= 4.2.0"
end
build_gem "sentry-sidekiq", "5.22.0" do |s|
s.add_dependency "sidekiq", ">= 3.0"
end
build_gem "sentry-sidekiq", "5.22.4" do |s|
s.add_dependency "sidekiq", ">= 3.0"
end
end
gemfile <<~G
source "https://gem.repo4"
gem "redis"
gem "sidekiq", "~> 6.5"
gem "sentry-sidekiq"
G
original_lockfile = <<~L
GEM
remote: https://gem.repo4/
specs:
redis (4.8.1)
sentry-sidekiq (5.22.0)
sidekiq (>= 3.0)
sidekiq (6.5.12)
redis (>= 4.5.0, < 5)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
redis
sentry-sidekiq
sidekiq (~> 6.5)
BUNDLED WITH
#{Bundler::VERSION}
L
lockfile original_lockfile
bundle "lock --update sentry-sidekiq"
expect(lockfile).to eq(original_lockfile.sub("sentry-sidekiq (5.22.0)", "sentry-sidekiq (5.22.4)"))
end
it "does not downgrade indirect dependencies unnecessarily" do
build_repo4 do
build_gem "a" do |s|
s.add_dependency "b"
s.add_dependency "c"
end
build_gem "b"
build_gem "c"
build_gem "c", "2.0"
end
install_gemfile <<-G, verbose: true
source "https://gem.repo4"
gem "a"
G
expect(the_bundle).to include_gems("a 1.0", "b 1.0", "c 2.0")
build_repo4 do
build_gem "b", "2.0" do |s|
s.add_dependency "c", "< 2"
end
end
bundle "update", all: true, verbose: true
expect(the_bundle).to include_gems("a 1.0", "b 1.0", "c 2.0")
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 "https://gem.repo4"
gem "a"
gem "b"
G
expect(the_bundle).to include_gems("a 1.0", "b 2.0")
gemfile <<-G
source "https://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
it "should still downgrade if forced by the Gemfile, when transitive dependencies also need downgrade" do
build_repo4 do
build_gem "activesupport", "6.1.4.1" do |s|
s.add_dependency "tzinfo", "~> 2.0"
end
build_gem "activesupport", "6.0.4.1" do |s|
s.add_dependency "tzinfo", "~> 1.1"
end
build_gem "tzinfo", "2.0.4"
build_gem "tzinfo", "1.2.9"
end
install_gemfile <<-G
source "https://gem.repo4"
gem "activesupport", "~> 6.1.0"
G
expect(the_bundle).to include_gems("activesupport 6.1.4.1", "tzinfo 2.0.4")
gemfile <<-G
source "https://gem.repo4"
gem "activesupport", "~> 6.0.0"
G
original_lockfile = lockfile
checksums = checksums_section_when_enabled do |c|
c.checksum gem_repo4, "activesupport", "6.0.4.1"
c.checksum gem_repo4, "tzinfo", "1.2.9"
end
expected_lockfile = <<~L
GEM
remote: https://gem.repo4/
specs:
activesupport (6.0.4.1)
tzinfo (~> 1.1)
tzinfo (1.2.9)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
activesupport (~> 6.0.0)
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "update activesupport"
expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9")
expect(lockfile).to eq(expected_lockfile)
lockfile original_lockfile
bundle "update"
expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9")
expect(lockfile).to eq(expected_lockfile)
lockfile original_lockfile
bundle "lock --update"
expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9")
expect(lockfile).to eq(expected_lockfile)
end
end
describe "with --local option" do
before do
build_repo2
gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-obama"
gem "platform_specific"
G
end
it "doesn't hit repo2" do
simulate_platform "x86-darwin-100" do
lockfile <<~L
GEM
remote: https://gem.repo2/
specs:
activesupport (2.3.5)
platform_specific (1.0-x86-darwin-100)
myrack (1.0.0)
myrack-obama (1.0)
myrack
PLATFORMS
x86-darwin-100
DEPENDENCIES
activesupport
platform_specific
myrack-obama
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "install"
FileUtils.rm_r(gem_repo2)
bundle "update --local --all"
expect(out).not_to include("Fetching source index")
end
end
end
describe "with --group option" do
before do
build_repo2
end
it "should update only specified group gems" do
install_gemfile <<-G
source "https://gem.repo2"
gem "activesupport", :group => :development
gem "myrack"
G
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
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 "myrack 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 "https://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 "https://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 "https://gem.repo1"
gem "activesupport", :group => :development
gem "myrack"
G
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
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 "myrack 1.2"
end
end
end
describe "in a frozen bundle" do
before do
build_repo2
install_gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
gem "myrack-obama"
gem "platform_specific"
G
end
it "should fail loudly" do
bundle "config deployment true"
bundle "update", all: true, raise_on_error: false
expect(last_command).to be_failure
expect(err).to eq <<~ERROR.strip
Bundler is unlocking, but the lockfile can't be updated because frozen mode is set
If this is a development machine, remove the Gemfile.lock freeze by running `bundle config set frozen false`.
ERROR
end
it "should fail loudly when frozen is set globally" do
bundle "config set --global frozen 1"
bundle "update", all: true, raise_on_error: false
expect(err).to eq <<~ERROR.strip
Bundler is unlocking, but the lockfile can't be updated because frozen mode is set
If this is a development machine, remove the Gemfile.lock freeze by running `bundle config set frozen false`.
ERROR
end
it "should fail loudly when deployment is set globally" do
bundle "config set --global deployment true"
bundle "update", all: true, raise_on_error: false
expect(err).to eq <<~ERROR.strip
Bundler is unlocking, but the lockfile can't be updated because frozen mode is set
If this is a development machine, remove the Gemfile.lock freeze by running `bundle config set frozen false`.
ERROR
end
it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do
bundle "update", all: true, raise_on_error: false, env: { "BUNDLE_FROZEN" => "true" }
expect(err).to eq("Bundler is unlocking, but the lockfile can't be updated because frozen mode is set")
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" do
install_gemfile <<-G
source "https://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
it "should not update gems not included in the source that happen to have the same name" do
install_gemfile <<-G
source "https://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
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 "https://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" 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 "https://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" 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" do
build_repo2
install_gemfile <<-G
source "https://gem.repo2"
gem "activesupport"
G
bundle "update", all: true, verbose: 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
it "only prints `Using` for versions that have changed" do
build_repo4 do
build_gem "bar"
build_gem "foo"
end
install_gemfile <<-G
source "https://gem.repo4"
gem "bar"
gem "foo"
G
bundle "update", all: true
expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/)
build_repo4 do
build_gem "foo", "2.0"
end
bundle "update", all: true
expect(out.sub("Removing foo (1.0)\n", "")).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/)
end
it "shows error message when Gemfile.lock is not preset and gem is specified" do
gemfile <<-G
source "https://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 sources and caching enabled" do
before do
build_repo2 do