Skip to content

Commit ec58eda

Browse files
Refactor platform test helpers
1 parent a57469e commit ec58eda

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

bundler/spec/commands/lock_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@
449449

450450
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
451451
lockfile = Bundler::LockfileParser.new(read_lockfile)
452-
expect(lockfile.platforms).to match_array([java, x86_mingw32, local_platform].uniq)
452+
expect(lockfile.platforms).to match_array(default_platform_list(java, x86_mingw32))
453453
end
454454

455455
it "supports adding new platforms with force_ruby_platform = true" do
@@ -481,7 +481,7 @@
481481

482482
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
483483
lockfile = Bundler::LockfileParser.new(read_lockfile)
484-
expect(lockfile.platforms).to match_array(["ruby", local_platform].uniq)
484+
expect(lockfile.platforms).to match_array(default_platform_list("ruby"))
485485
end
486486

487487
it "warns when adding an unknown platform" do
@@ -494,12 +494,12 @@
494494

495495
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
496496
lockfile = Bundler::LockfileParser.new(read_lockfile)
497-
expect(lockfile.platforms).to match_array([java, x86_mingw32, local_platform].uniq)
497+
expect(lockfile.platforms).to match_array(default_platform_list(java, x86_mingw32))
498498

499499
bundle "lock --remove-platform java"
500500

501501
lockfile = Bundler::LockfileParser.new(read_lockfile)
502-
expect(lockfile.platforms).to match_array([x86_mingw32, local_platform].uniq)
502+
expect(lockfile.platforms).to match_array(default_platform_list(x86_mingw32))
503503
end
504504

505505
it "also cleans up redundant platform gems when removing platforms" do

bundler/spec/install/gemfile/specific_platform_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@
956956
rack (3.0.7)
957957
958958
PLATFORMS
959-
#{formatted_lockfile_platforms(*["ruby", generic_local_platform].uniq)}
959+
#{lockfile_platforms("ruby", generic_local_platform, :defaults => [])}
960960
961961
DEPENDENCIES
962962
concurrent-ruby

bundler/spec/lock/lockfile_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@
15211521
indirect_dependency (1.2.3)
15221522
15231523
PLATFORMS
1524-
#{formatted_lockfile_platforms(*["ruby", generic_local_platform].uniq)}
1524+
#{lockfile_platforms("ruby", generic_local_platform, :defaults => [])}
15251525
15261526
DEPENDENCIES
15271527
direct_dependency

bundler/spec/support/platforms.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,17 @@ def not_local_patchlevel
9595
9999
9696
end
9797

98-
def lockfile_platforms(*extra)
99-
formatted_lockfile_platforms(local_platform, *extra)
98+
def default_platform_list(*extra, defaults: default_locked_platforms)
99+
defaults.concat(extra).uniq
100100
end
101101

102-
def formatted_lockfile_platforms(*platforms)
102+
def lockfile_platforms(*extra, defaults: default_locked_platforms)
103+
platforms = default_platform_list(*extra, :defaults => defaults)
103104
platforms.map(&:to_s).sort.join("\n ")
104105
end
106+
107+
def default_locked_platforms
108+
[local_platform]
109+
end
105110
end
106111
end

0 commit comments

Comments
 (0)