Skip to content

Commit 1d97c46

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Minor Bundler spec improvements
While working on something else I noticed: * Usage of uppercased "RUBY" and "JAVA" as platforms, when those don't really exist. * Usage of some test gems with "1.0" as gemspec version and "1.0.0" as actual version. This commit fixes both inconsistencies to make things more expectable. rubygems/rubygems@e3ec32e247
1 parent ac0e0f0 commit 1d97c46

File tree

10 files changed

+50
-86
lines changed

10 files changed

+50
-86
lines changed

spec/bundler/commands/cache_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,7 @@
479479
source "https://gem.repo1"
480480
gem "platform_specific"
481481
G
482-
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
483-
expect(out).to eq("1.0.0 RUBY")
482+
expect(the_bundle).to include_gems("platform_specific 1.0 ruby")
484483
end
485484

486485
it "does not update the cache if --no-cache is passed" do

spec/bundler/commands/install_spec.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,12 @@
249249

250250
describe "with a gem that installs multiple platforms" do
251251
it "installs gems for the local platform as first choice" do
252-
skip "version is 1.0, not 1.0.0" if Gem.win_platform?
253-
254252
install_gemfile <<-G
255253
source "https://gem.repo1"
256254
gem "platform_specific"
257255
G
258256

259-
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
260-
expect(out).to eq("1.0.0 #{Bundler.local_platform}")
257+
expect(the_bundle).to include_gems("platform_specific 1.0 #{Bundler.local_platform}")
261258
end
262259

263260
it "falls back on plain ruby" do
@@ -267,8 +264,7 @@
267264
gem "platform_specific"
268265
G
269266

270-
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
271-
expect(out).to eq("1.0.0 RUBY")
267+
expect(the_bundle).to include_gems("platform_specific 1.0 ruby")
272268
end
273269

274270
it "installs gems for java" do
@@ -278,8 +274,7 @@
278274
gem "platform_specific"
279275
G
280276

281-
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
282-
expect(out).to eq("1.0.0 JAVA")
277+
expect(the_bundle).to include_gems("platform_specific 1.0 java")
283278
end
284279

285280
it "installs gems for windows" do
@@ -290,8 +285,7 @@
290285
gem "platform_specific"
291286
G
292287

293-
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
294-
expect(out).to eq("1.0 x86-mswin32")
288+
expect(the_bundle).to include_gems("platform_specific 1.0 x86-mswin32")
295289
end
296290
end
297291

spec/bundler/install/gemfile/force_ruby_platform_spec.rb

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@
55
before do
66
build_repo4 do
77
# Build a gem with platform specific versions
8-
build_gem("platform_specific") do |s|
9-
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'"
10-
end
8+
build_gem("platform_specific")
119

1210
build_gem("platform_specific") do |s|
1311
s.platform = Bundler.local_platform
14-
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'"
1512
end
1613

1714
# Build the exact same gem with a different name to compare using vs not using the option
18-
build_gem("platform_specific_forced") do |s|
19-
s.write "lib/platform_specific_forced.rb", "PLATFORM_SPECIFIC_FORCED = '1.0.0 RUBY'"
20-
end
15+
build_gem("platform_specific_forced")
2116

2217
build_gem("platform_specific_forced") do |s|
2318
s.platform = Bundler.local_platform
24-
s.write "lib/platform_specific_forced.rb", "PLATFORM_SPECIFIC_FORCED = '1.0.0 #{Bundler.local_platform}'"
2519
end
2620
end
2721
end
@@ -34,8 +28,8 @@
3428
gem "platform_specific"
3529
G
3630

37-
expect(the_bundle).to include_gems "platform_specific_forced 1.0.0 RUBY"
38-
expect(the_bundle).to include_gems "platform_specific 1.0.0 #{Bundler.local_platform}"
31+
expect(the_bundle).to include_gems "platform_specific_forced 1.0 ruby"
32+
expect(the_bundle).to include_gems "platform_specific 1.0 #{Bundler.local_platform}"
3933
end
4034

4135
it "still respects a global `force_ruby_platform` config" do
@@ -46,8 +40,8 @@
4640
gem "platform_specific"
4741
G
4842

49-
expect(the_bundle).to include_gems "platform_specific_forced 1.0.0 RUBY"
50-
expect(the_bundle).to include_gems "platform_specific 1.0.0 RUBY"
43+
expect(the_bundle).to include_gems "platform_specific_forced 1.0 ruby"
44+
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
5145
end
5246
end
5347

@@ -56,13 +50,10 @@
5650
build_repo4 do
5751
build_gem("depends_on_platform_specific") {|s| s.add_dependency "platform_specific" }
5852

59-
build_gem("platform_specific") do |s|
60-
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'"
61-
end
53+
build_gem("platform_specific")
6254

6355
build_gem("platform_specific") do |s|
6456
s.platform = Bundler.local_platform
65-
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'"
6657
end
6758
end
6859
end
@@ -75,7 +66,7 @@
7566
gem "platform_specific", :force_ruby_platform => true
7667
G
7768

78-
expect(the_bundle).to include_gems "platform_specific 1.0.0 RUBY"
69+
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
7970
end
8071
end
8172

@@ -84,22 +75,17 @@
8475
build_repo4 do
8576
build_gem("depends_on_platform_specific") do |s|
8677
s.add_dependency "platform_specific"
87-
s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 RUBY'"
8878
end
8979

9080
build_gem("depends_on_platform_specific") do |s|
9181
s.add_dependency "platform_specific"
9282
s.platform = Bundler.local_platform
93-
s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'"
9483
end
9584

96-
build_gem("platform_specific") do |s|
97-
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'"
98-
end
85+
build_gem("platform_specific")
9986

10087
build_gem("platform_specific") do |s|
10188
s.platform = Bundler.local_platform
102-
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'"
10389
end
10490
end
10591
end
@@ -111,11 +97,11 @@
11197
gem "depends_on_platform_specific", :force_ruby_platform => true
11298
G
11399

114-
expect(the_bundle).to include_gems "depends_on_platform_specific 1.0.0 RUBY"
115-
expect(the_bundle).to include_gems "platform_specific 1.0.0 #{Bundler.local_platform}"
100+
expect(the_bundle).to include_gems "depends_on_platform_specific 1.0 ruby"
101+
expect(the_bundle).to include_gems "platform_specific 1.0 #{Bundler.local_platform}"
116102
end
117103

118-
it "reinstalls the ruby variant when a platform specific variant is already installed, the lockile has only RUBY platform, and :force_ruby_platform is used in the Gemfile" do
104+
it "reinstalls the ruby variant when a platform specific variant is already installed, the lockile has only ruby platform, and :force_ruby_platform is used in the Gemfile" do
119105
lockfile <<-L
120106
GEM
121107
remote: https://gem.repo4
@@ -140,7 +126,7 @@
140126
gem "platform_specific", :force_ruby_platform => true
141127
G
142128

143-
expect(the_bundle).to include_gems "platform_specific 1.0.0 RUBY"
129+
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
144130
end
145131
end
146132
end

spec/bundler/install/gemfile/gemspec_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def x64_mingw_checksums(checksums)
210210
G
211211

212212
bundle "update --bundler", artifice: "compact_index", verbose: true
213-
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 JAVA"
213+
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 java"
214214
end
215215

216216
it "should evaluate the gemspec in its directory" do
@@ -461,7 +461,7 @@ def x64_mingw_checksums(checksums)
461461

462462
context "as a runtime dependency" do
463463
it "keeps all platform dependencies in the lockfile" do
464-
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
464+
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 ruby"
465465

466466
checksums = checksums_section_when_existing do |c|
467467
c.no_checksum "foo", "1.0"
@@ -502,7 +502,7 @@ def x64_mingw_checksums(checksums)
502502
let(:platform_specific_type) { :development }
503503

504504
it "keeps all platform dependencies in the lockfile" do
505-
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
505+
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 ruby"
506506

507507
checksums = checksums_section_when_existing do |c|
508508
c.no_checksum "foo", "1.0"
@@ -544,7 +544,7 @@ def x64_mingw_checksums(checksums)
544544
let(:dependency) { "indirect_platform_specific" }
545545

546546
it "keeps all platform dependencies in the lockfile" do
547-
expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
547+
expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 ruby"
548548

549549
checksums = checksums_section_when_existing do |c|
550550
c.no_checksum "foo", "1.0"

spec/bundler/install/gemfile/platform_spec.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
gem "platform_specific"
4848
G
4949

50-
expect(the_bundle).to include_gems "platform_specific 1.0 JAVA"
50+
expect(the_bundle).to include_gems "platform_specific 1.0 java"
5151
end
5252

5353
it "pulls the pure ruby version on jruby if the java platform is not present in the lockfile and bundler is run in frozen mode", :jruby_only do
@@ -72,23 +72,20 @@
7272
gem "platform_specific"
7373
G
7474

75-
expect(the_bundle).to include_gems "platform_specific 1.0 RUBY"
75+
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
7676
end
7777

7878
context "on universal Rubies" do
7979
before do
8080
build_repo4 do
8181
build_gem "darwin_single_arch" do |s|
8282
s.platform = "ruby"
83-
s.write "lib/darwin_single_arch.rb", "DARWIN_SINGLE_ARCH = '1.0 RUBY'"
8483
end
8584
build_gem "darwin_single_arch" do |s|
8685
s.platform = "arm64-darwin"
87-
s.write "lib/darwin_single_arch.rb", "DARWIN_SINGLE_ARCH = '1.0 arm64-darwin'"
8886
end
8987
build_gem "darwin_single_arch" do |s|
9088
s.platform = "x86_64-darwin"
91-
s.write "lib/darwin_single_arch.rb", "DARWIN_SINGLE_ARCH = '1.0 x86_64-darwin'"
9289
end
9390
end
9491
end
@@ -158,7 +155,7 @@
158155
gem "nokogiri"
159156
G
160157

161-
expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
158+
expect(the_bundle).to include_gems "nokogiri 1.4.2 java", "weakling 0.0.3"
162159

163160
simulate_new_machine
164161
bundle "config set --local force_ruby_platform true"
@@ -171,7 +168,7 @@
171168
simulate_platform "java"
172169
bundle "install"
173170

174-
expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
171+
expect(the_bundle).to include_gems "nokogiri 1.4.2 java", "weakling 0.0.3"
175172
end
176173

177174
it "does not keep unneeded platforms for gems that are used" do
@@ -400,7 +397,7 @@
400397

401398
checksums.checksum gem_repo1, "platform_specific", "1.0"
402399

403-
expect(the_bundle).to include_gem "platform_specific 1.0 RUBY"
400+
expect(the_bundle).to include_gem "platform_specific 1.0 ruby"
404401

405402
expect(lockfile).to eq <<~G
406403
GEM

spec/bundler/install/gemfile/specific_platform_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
end
5656
end
5757

58-
it "understands that a non-platform specific gem in a new lockfile locked only to RUBY doesn't necessarily mean installing the non-specific variant" do
58+
it "understands that a non-platform specific gem in a new lockfile locked only to ruby doesn't necessarily mean installing the non-specific variant" do
5959
simulate_platform "x86_64-darwin-15" do
6060
setup_multiplatform_gem
6161

@@ -113,7 +113,7 @@
113113
end
114114
end
115115

116-
context "when running on a legacy lockfile locked only to RUBY" do
116+
context "when running on a legacy lockfile locked only to ruby" do
117117
around do |example|
118118
build_repo4 do
119119
build_gem "nokogiri", "1.3.10"
@@ -148,12 +148,12 @@
148148
simulate_platform "arm64-darwin-22", &example
149149
end
150150

151-
it "still installs the generic RUBY variant if necessary" do
151+
it "still installs the generic ruby variant if necessary" do
152152
bundle "install --verbose", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
153153
expect(out).to include("Installing nokogiri 1.3.10")
154154
end
155155

156-
it "still installs the generic RUBY variant if necessary, even in frozen mode" do
156+
it "still installs the generic ruby variant if necessary, even in frozen mode" do
157157
bundle "install --verbose", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "BUNDLE_FROZEN" => "true" }
158158
expect(out).to include("Installing nokogiri 1.3.10")
159159
end
@@ -459,7 +459,7 @@
459459
expect(err).to include(error_message).once
460460
end
461461

462-
it "does not generate a lockfile if RUBY platform is forced and some gem has no RUBY variant available" do
462+
it "does not generate a lockfile if ruby platform is forced and some gem has no ruby variant available" do
463463
build_repo4 do
464464
build_gem("sorbet-static", "0.5.9889") {|s| s.platform = Gem::Platform.local }
465465
end
@@ -480,7 +480,7 @@
480480
ERROR
481481
end
482482

483-
it "automatically fixes the lockfile if RUBY platform is locked and some gem has no RUBY variant available" do
483+
it "automatically fixes the lockfile if ruby platform is locked and some gem has no ruby variant available" do
484484
build_repo4 do
485485
build_gem("sorbet-static-and-runtime", "0.5.10160") do |s|
486486
s.add_dependency "sorbet", "= 0.5.10160"
@@ -558,7 +558,7 @@
558558
L
559559
end
560560

561-
it "automatically fixes the lockfile if both RUBY platform and a more specific platform are locked, and some gem has no RUBY variant available" do
561+
it "automatically fixes the lockfile if both ruby platform and a more specific platform are locked, and some gem has no ruby variant available" do
562562
build_repo4 do
563563
build_gem "nokogiri", "1.12.0"
564564
build_gem "nokogiri", "1.12.0" do |s|
@@ -632,7 +632,7 @@
632632
L
633633
end
634634

635-
it "automatically fixes the lockfile if only RUBY platform is locked and some gem has no RUBY variant available" do
635+
it "automatically fixes the lockfile if only ruby platform is locked and some gem has no ruby variant available" do
636636
build_repo4 do
637637
build_gem("sorbet-static-and-runtime", "0.5.10160") do |s|
638638
s.add_dependency "sorbet", "= 0.5.10160"
@@ -844,7 +844,7 @@
844844
end
845845
end
846846

847-
it "automatically fixes the lockfile if locked only to RUBY, and some locked specs don't meed locked dependencies" do
847+
it "automatically fixes the lockfile if locked only to ruby, and some locked specs don't meed locked dependencies" do
848848
simulate_platform "x86_64-linux" do
849849
build_repo4 do
850850
build_gem("ibandit", "0.7.0") do |s|
@@ -1119,7 +1119,7 @@
11191119
end
11201120
end
11211121

1122-
it "automatically fixes the lockfile when only RUBY platform locked, and adding a dependency with subdependencies not valid for RUBY" do
1122+
it "automatically fixes the lockfile when only ruby platform locked, and adding a dependency with subdependencies not valid for ruby" do
11231123
simulate_platform "x86_64-linux" do
11241124
build_repo4 do
11251125
build_gem("sorbet", "0.5.10160") do |s|

spec/bundler/lock/lockfile_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@
13211321
G
13221322
end
13231323

1324-
it "adds compatible platform specific variants to the lockfile, even if resolution fallback to RUBY due to some other incompatible platform specific variant" do
1324+
it "adds compatible platform specific variants to the lockfile, even if resolution fallback to ruby due to some other incompatible platform specific variant" do
13251325
simulate_platform "arm64-darwin-23" do
13261326
build_repo4 do
13271327
build_gem "google-protobuf", "3.25.1"

0 commit comments

Comments
 (0)