From 62012eaeb61937961941dc778a95d05ff7d4f637 Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Thu, 23 Jan 2025 14:57:31 +0100 Subject: [PATCH 1/3] Add ruby_34 and ruby_35 as valid platform: - Fix #8427 - Similar to 7cd19d824d1765fc9980b4e92c12470741d2e402. Tweaked a bit the test supposed to prevent this error by checking whether the dep respond to these methods. --- bundler/lib/bundler/current_ruby.rb | 2 ++ bundler/spec/bundler/dependency_spec.rb | 12 ++++++++++++ bundler/spec/bundler/dsl_spec.rb | 8 +++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bundler/lib/bundler/current_ruby.rb b/bundler/lib/bundler/current_ruby.rb index 93e0c401c056..1ba33c09e7c0 100644 --- a/bundler/lib/bundler/current_ruby.rb +++ b/bundler/lib/bundler/current_ruby.rb @@ -24,6 +24,8 @@ class CurrentRuby 3.1 3.2 3.3 + 3.4 + 3.5 ].freeze KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze diff --git a/bundler/spec/bundler/dependency_spec.rb b/bundler/spec/bundler/dependency_spec.rb index 1185c4e5dd04..a3b1f0ffa27c 100644 --- a/bundler/spec/bundler/dependency_spec.rb +++ b/bundler/spec/bundler/dependency_spec.rb @@ -170,5 +170,17 @@ it "includes all platforms" do expect(subject).to eq(platforms.merge(deprecated)) end + + it "is on the current platform" do + engine = Gem.win_platform? ? "windows" : RUBY_ENGINE + + dep = described_class.new( + "test_gem", + "1.0.0", + { "platforms" => "#{engine}_#{RbConfig::CONFIG["MAJOR"]}#{RbConfig::CONFIG["MINOR"]}" }, + ) + + expect(dep.current_platform?).to be_truthy + end end end diff --git a/bundler/spec/bundler/dsl_spec.rb b/bundler/spec/bundler/dsl_spec.rb index c4f9d0dbb5d6..f5fc0c7bbee4 100644 --- a/bundler/spec/bundler/dsl_spec.rb +++ b/bundler/spec/bundler/dsl_spec.rb @@ -201,8 +201,8 @@ describe "#gem" do # rubocop:disable Naming/VariableNumber [:ruby, :ruby_18, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25, :ruby_26, :ruby_27, - :ruby_30, :ruby_31, :ruby_32, :ruby_33, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24, - :mri_25, :mri_26, :mri_27, :mri_30, :mri_31, :mri_32, :mri_33, :jruby, :rbx, :truffleruby].each do |platform| + :ruby_30, :ruby_31, :ruby_32, :ruby_33, :ruby_34, :ruby_35, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24, + :mri_25, :mri_26, :mri_27, :mri_30, :mri_31, :mri_32, :mri_33, :mri_34, :mri_35, :jruby, :rbx, :truffleruby].each do |platform| it "allows #{platform} as a valid platform" do subject.gem("foo", platform: platform) end @@ -211,7 +211,9 @@ it "allows platforms matching the running Ruby version" do platform = "ruby_#{RbConfig::CONFIG["MAJOR"]}#{RbConfig::CONFIG["MINOR"]}" - subject.gem("foo", platform: platform) + + expect { subject.gem("foo", platform: platform) }.not_to raise_error + expect(Bundler.current_ruby.respond_to?("#{platform}?")).to be_truthy end it "rejects invalid platforms" do From a91edd6c1ff726495edaf8e628b4eabf30f0da9a Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Thu, 23 Jan 2025 15:45:48 +0100 Subject: [PATCH 2/3] Consolidated the Ruby version list: - We keep 2 list of supported ruby versions and each time a new ruby version is released we need to maintain both list. Forgetting to update one would prevent users from adding gem for a specific plaftorm (i.e. 7cd19d824d1765fc9980b4e92c12470741d2e402 and 5462322f8f0c2664f1f961b77a14a7c6ba2ca4b7). Extracted the list from the Dependency class and moved it to the CurrentRuby class (which I believe was originally added for that reason). --- bundler/lib/bundler/current_ruby.rb | 23 +++-------------------- bundler/lib/bundler/dependency.rb | 15 +++++++-------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/bundler/lib/bundler/current_ruby.rb b/bundler/lib/bundler/current_ruby.rb index 1ba33c09e7c0..a4c87dfd57cc 100644 --- a/bundler/lib/bundler/current_ruby.rb +++ b/bundler/lib/bundler/current_ruby.rb @@ -9,26 +9,9 @@ def self.current_ruby end class CurrentRuby - KNOWN_MINOR_VERSIONS = %w[ - 1.8 - 1.9 - 2.0 - 2.1 - 2.2 - 2.3 - 2.4 - 2.5 - 2.6 - 2.7 - 3.0 - 3.1 - 3.2 - 3.3 - 3.4 - 3.5 - ].freeze - - KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze + ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze + KNOWN_MINOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze + KNOWN_MAJOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze KNOWN_PLATFORMS = %w[ jruby diff --git a/bundler/lib/bundler/dependency.rb b/bundler/lib/bundler/dependency.rb index 09a145b8c8eb..a31a77517765 100644 --- a/bundler/lib/bundler/dependency.rb +++ b/bundler/lib/bundler/dependency.rb @@ -9,19 +9,18 @@ class Dependency < Gem::Dependency attr_reader :autorequire attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :glob - ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze PLATFORM_MAP = { - ruby: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], - mri: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], + ruby: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS], + mri: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS], rbx: [Gem::Platform::RUBY], truffleruby: [Gem::Platform::RUBY], jruby: [Gem::Platform::JAVA, [18, 19]], - windows: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS], + windows: [Gem::Platform::WINDOWS, CurrentRuby::ALL_RUBY_VERSIONS], # deprecated - mswin: [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS], - mswin64: [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]], - mingw: [Gem::Platform::MINGW, ALL_RUBY_VERSIONS], - x64_mingw: [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]], + mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS], + mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]], + mingw: [Gem::Platform::MINGW, CurrentRuby::ALL_RUBY_VERSIONS], + x64_mingw: [Gem::Platform::X64_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]], }.each_with_object({}) do |(platform, spec), hash| hash[platform] = spec[0] spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] } From 29e219ebcf208263bb7effae80219160fcc27485 Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Thu, 23 Jan 2025 15:58:37 +0100 Subject: [PATCH 3/3] Consolidate the platform into a single list: - Similar change than 29a1be0008e6a2505aa321c66d770e0ce9817190, keep a single source of truth where we store the platform. The only change worth highlighing is the platform "maglev". It was not part of the supported platform of dependencies, so calling `gem 'foo', plaftorm: 'maglev'` would not work. However, it was supposed to according to 45ec86e2e5288cc0302783a1c9ad9c5a15b4a6a2. That's why it was possible to do `Bundler.current_ruby.maglev?` or `Bundler.current_ruby.maglev_30?`. I didn't change the current behaviour and maglev is not supported, though I kept the `*maglev` methods as I believe CurrentRuby is public API. --- bundler/lib/bundler/current_ruby.rb | 35 ++--- bundler/lib/bundler/dependency.rb | 20 +-- bundler/lib/bundler/dsl.rb | 2 +- bundler/spec/bundler/current_ruby_spec.rb | 140 ++++++++++++++++++++ bundler/spec/bundler/dependency_spec.rb | 153 ++-------------------- 5 files changed, 170 insertions(+), 180 deletions(-) create mode 100644 bundler/spec/bundler/current_ruby_spec.rb diff --git a/bundler/lib/bundler/current_ruby.rb b/bundler/lib/bundler/current_ruby.rb index a4c87dfd57cc..9cd08f4d09fd 100644 --- a/bundler/lib/bundler/current_ruby.rb +++ b/bundler/lib/bundler/current_ruby.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative "rubygems_ext" + module Bundler # Returns current version of Ruby # @@ -12,20 +14,22 @@ class CurrentRuby ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze KNOWN_MINOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze KNOWN_MAJOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze - - KNOWN_PLATFORMS = %w[ - jruby - maglev - mingw - mri - mswin - mswin64 - rbx - ruby - truffleruby - windows - x64_mingw - ].freeze + PLATFORM_MAP = { + ruby: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS], + mri: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS], + rbx: [Gem::Platform::RUBY], + truffleruby: [Gem::Platform::RUBY], + jruby: [Gem::Platform::JAVA, [18, 19]], + windows: [Gem::Platform::WINDOWS, CurrentRuby::ALL_RUBY_VERSIONS], + # deprecated + mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS], + mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]], + mingw: [Gem::Platform::MINGW, CurrentRuby::ALL_RUBY_VERSIONS], + x64_mingw: [Gem::Platform::X64_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]], + }.each_with_object({}) do |(platform, spec), hash| + hash[platform] = spec[0] + spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] } + end.freeze def ruby? return true if Bundler::GemHelpers.generic_local_platform_is_ruby? @@ -67,7 +71,8 @@ def windows? RUBY_VERSION.start_with?("#{version}.") end - KNOWN_PLATFORMS.each do |platform| + all_platforms = PLATFORM_MAP.keys << "maglev" + all_platforms.each do |platform| define_method(:"#{platform}_#{trimmed_version}?") do send(:"#{platform}?") && send(:"on_#{trimmed_version}?") end diff --git a/bundler/lib/bundler/dependency.rb b/bundler/lib/bundler/dependency.rb index a31a77517765..45d74c5ba71f 100644 --- a/bundler/lib/bundler/dependency.rb +++ b/bundler/lib/bundler/dependency.rb @@ -2,30 +2,12 @@ require "rubygems/dependency" require_relative "shared_helpers" -require_relative "rubygems_ext" module Bundler class Dependency < Gem::Dependency attr_reader :autorequire attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :glob - PLATFORM_MAP = { - ruby: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS], - mri: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS], - rbx: [Gem::Platform::RUBY], - truffleruby: [Gem::Platform::RUBY], - jruby: [Gem::Platform::JAVA, [18, 19]], - windows: [Gem::Platform::WINDOWS, CurrentRuby::ALL_RUBY_VERSIONS], - # deprecated - mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS], - mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]], - mingw: [Gem::Platform::MINGW, CurrentRuby::ALL_RUBY_VERSIONS], - x64_mingw: [Gem::Platform::X64_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]], - }.each_with_object({}) do |(platform, spec), hash| - hash[platform] = spec[0] - spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] } - end.freeze - def initialize(name, version, options = {}, &blk) type = options["type"] || :runtime super(name, version, type) @@ -61,7 +43,7 @@ def gem_platforms(valid_platforms) end def expanded_platforms - @expanded_platforms ||= @platforms.filter_map {|pl| PLATFORM_MAP[pl] }.flatten.uniq + @expanded_platforms ||= @platforms.filter_map {|pl| CurrentRuby::PLATFORM_MAP[pl] }.flatten.uniq end def should_include? diff --git a/bundler/lib/bundler/dsl.rb b/bundler/lib/bundler/dsl.rb index 05c60f2f1aab..08fdacb991ef 100644 --- a/bundler/lib/bundler/dsl.rb +++ b/bundler/lib/bundler/dsl.rb @@ -13,7 +13,7 @@ def self.evaluate(gemfile, lockfile, unlock) builder.to_definition(lockfile, unlock) end - VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze + VALID_PLATFORMS = Bundler::CurrentRuby::PLATFORM_MAP.keys.freeze VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules platform platforms type source install_if gemfile force_ruby_platform].freeze diff --git a/bundler/spec/bundler/current_ruby_spec.rb b/bundler/spec/bundler/current_ruby_spec.rb new file mode 100644 index 000000000000..e0498d5a9e99 --- /dev/null +++ b/bundler/spec/bundler/current_ruby_spec.rb @@ -0,0 +1,140 @@ +# frozen_string_literal: true + +RSpec.describe Bundler::CurrentRuby do + describe "PLATFORM_MAP" do + subject { described_class::PLATFORM_MAP } + + # rubocop:disable Naming/VariableNumber + let(:platforms) do + { ruby: Gem::Platform::RUBY, + ruby_18: Gem::Platform::RUBY, + ruby_19: Gem::Platform::RUBY, + ruby_20: Gem::Platform::RUBY, + ruby_21: Gem::Platform::RUBY, + ruby_22: Gem::Platform::RUBY, + ruby_23: Gem::Platform::RUBY, + ruby_24: Gem::Platform::RUBY, + ruby_25: Gem::Platform::RUBY, + ruby_26: Gem::Platform::RUBY, + ruby_27: Gem::Platform::RUBY, + ruby_30: Gem::Platform::RUBY, + ruby_31: Gem::Platform::RUBY, + ruby_32: Gem::Platform::RUBY, + ruby_33: Gem::Platform::RUBY, + ruby_34: Gem::Platform::RUBY, + ruby_35: Gem::Platform::RUBY, + mri: Gem::Platform::RUBY, + mri_18: Gem::Platform::RUBY, + mri_19: Gem::Platform::RUBY, + mri_20: Gem::Platform::RUBY, + mri_21: Gem::Platform::RUBY, + mri_22: Gem::Platform::RUBY, + mri_23: Gem::Platform::RUBY, + mri_24: Gem::Platform::RUBY, + mri_25: Gem::Platform::RUBY, + mri_26: Gem::Platform::RUBY, + mri_27: Gem::Platform::RUBY, + mri_30: Gem::Platform::RUBY, + mri_31: Gem::Platform::RUBY, + mri_32: Gem::Platform::RUBY, + mri_33: Gem::Platform::RUBY, + mri_34: Gem::Platform::RUBY, + mri_35: Gem::Platform::RUBY, + rbx: Gem::Platform::RUBY, + truffleruby: Gem::Platform::RUBY, + jruby: Gem::Platform::JAVA, + jruby_18: Gem::Platform::JAVA, + jruby_19: Gem::Platform::JAVA, + windows: Gem::Platform::WINDOWS, + windows_18: Gem::Platform::WINDOWS, + windows_19: Gem::Platform::WINDOWS, + windows_20: Gem::Platform::WINDOWS, + windows_21: Gem::Platform::WINDOWS, + windows_22: Gem::Platform::WINDOWS, + windows_23: Gem::Platform::WINDOWS, + windows_24: Gem::Platform::WINDOWS, + windows_25: Gem::Platform::WINDOWS, + windows_26: Gem::Platform::WINDOWS, + windows_27: Gem::Platform::WINDOWS, + windows_30: Gem::Platform::WINDOWS, + windows_31: Gem::Platform::WINDOWS, + windows_32: Gem::Platform::WINDOWS, + windows_33: Gem::Platform::WINDOWS, + windows_34: Gem::Platform::WINDOWS, + windows_35: Gem::Platform::WINDOWS } + end + + let(:deprecated) do + { mswin: Gem::Platform::MSWIN, + mswin_18: Gem::Platform::MSWIN, + mswin_19: Gem::Platform::MSWIN, + mswin_20: Gem::Platform::MSWIN, + mswin_21: Gem::Platform::MSWIN, + mswin_22: Gem::Platform::MSWIN, + mswin_23: Gem::Platform::MSWIN, + mswin_24: Gem::Platform::MSWIN, + mswin_25: Gem::Platform::MSWIN, + mswin_26: Gem::Platform::MSWIN, + mswin_27: Gem::Platform::MSWIN, + mswin_30: Gem::Platform::MSWIN, + mswin_31: Gem::Platform::MSWIN, + mswin_32: Gem::Platform::MSWIN, + mswin_33: Gem::Platform::MSWIN, + mswin_34: Gem::Platform::MSWIN, + mswin_35: Gem::Platform::MSWIN, + mswin64: Gem::Platform::MSWIN64, + mswin64_19: Gem::Platform::MSWIN64, + mswin64_20: Gem::Platform::MSWIN64, + mswin64_21: Gem::Platform::MSWIN64, + mswin64_22: Gem::Platform::MSWIN64, + mswin64_23: Gem::Platform::MSWIN64, + mswin64_24: Gem::Platform::MSWIN64, + mswin64_25: Gem::Platform::MSWIN64, + mswin64_26: Gem::Platform::MSWIN64, + mswin64_27: Gem::Platform::MSWIN64, + mswin64_30: Gem::Platform::MSWIN64, + mswin64_31: Gem::Platform::MSWIN64, + mswin64_32: Gem::Platform::MSWIN64, + mswin64_33: Gem::Platform::MSWIN64, + mswin64_34: Gem::Platform::MSWIN64, + mswin64_35: Gem::Platform::MSWIN64, + mingw: Gem::Platform::MINGW, + mingw_18: Gem::Platform::MINGW, + mingw_19: Gem::Platform::MINGW, + mingw_20: Gem::Platform::MINGW, + mingw_21: Gem::Platform::MINGW, + mingw_22: Gem::Platform::MINGW, + mingw_23: Gem::Platform::MINGW, + mingw_24: Gem::Platform::MINGW, + mingw_25: Gem::Platform::MINGW, + mingw_26: Gem::Platform::MINGW, + mingw_27: Gem::Platform::MINGW, + mingw_30: Gem::Platform::MINGW, + mingw_31: Gem::Platform::MINGW, + mingw_32: Gem::Platform::MINGW, + mingw_33: Gem::Platform::MINGW, + mingw_34: Gem::Platform::MINGW, + mingw_35: Gem::Platform::MINGW, + x64_mingw: Gem::Platform::X64_MINGW, + x64_mingw_20: Gem::Platform::X64_MINGW, + x64_mingw_21: Gem::Platform::X64_MINGW, + x64_mingw_22: Gem::Platform::X64_MINGW, + x64_mingw_23: Gem::Platform::X64_MINGW, + x64_mingw_24: Gem::Platform::X64_MINGW, + x64_mingw_25: Gem::Platform::X64_MINGW, + x64_mingw_26: Gem::Platform::X64_MINGW, + x64_mingw_27: Gem::Platform::X64_MINGW, + x64_mingw_30: Gem::Platform::X64_MINGW, + x64_mingw_31: Gem::Platform::X64_MINGW, + x64_mingw_32: Gem::Platform::X64_MINGW, + x64_mingw_33: Gem::Platform::X64_MINGW, + x64_mingw_34: Gem::Platform::X64_MINGW, + x64_mingw_35: Gem::Platform::X64_MINGW } + end + # rubocop:enable Naming/VariableNumber + + it "includes all platforms" do + expect(subject).to eq(platforms.merge(deprecated)) + end + end +end diff --git a/bundler/spec/bundler/dependency_spec.rb b/bundler/spec/bundler/dependency_spec.rb index a3b1f0ffa27c..f930459571da 100644 --- a/bundler/spec/bundler/dependency_spec.rb +++ b/bundler/spec/bundler/dependency_spec.rb @@ -35,152 +35,15 @@ end end - describe "PLATFORM_MAP" do - subject { described_class::PLATFORM_MAP } + it "is on the current platform" do + engine = Gem.win_platform? ? "windows" : RUBY_ENGINE - # rubocop:disable Naming/VariableNumber - let(:platforms) do - { ruby: Gem::Platform::RUBY, - ruby_18: Gem::Platform::RUBY, - ruby_19: Gem::Platform::RUBY, - ruby_20: Gem::Platform::RUBY, - ruby_21: Gem::Platform::RUBY, - ruby_22: Gem::Platform::RUBY, - ruby_23: Gem::Platform::RUBY, - ruby_24: Gem::Platform::RUBY, - ruby_25: Gem::Platform::RUBY, - ruby_26: Gem::Platform::RUBY, - ruby_27: Gem::Platform::RUBY, - ruby_30: Gem::Platform::RUBY, - ruby_31: Gem::Platform::RUBY, - ruby_32: Gem::Platform::RUBY, - ruby_33: Gem::Platform::RUBY, - ruby_34: Gem::Platform::RUBY, - ruby_35: Gem::Platform::RUBY, - mri: Gem::Platform::RUBY, - mri_18: Gem::Platform::RUBY, - mri_19: Gem::Platform::RUBY, - mri_20: Gem::Platform::RUBY, - mri_21: Gem::Platform::RUBY, - mri_22: Gem::Platform::RUBY, - mri_23: Gem::Platform::RUBY, - mri_24: Gem::Platform::RUBY, - mri_25: Gem::Platform::RUBY, - mri_26: Gem::Platform::RUBY, - mri_27: Gem::Platform::RUBY, - mri_30: Gem::Platform::RUBY, - mri_31: Gem::Platform::RUBY, - mri_32: Gem::Platform::RUBY, - mri_33: Gem::Platform::RUBY, - mri_34: Gem::Platform::RUBY, - mri_35: Gem::Platform::RUBY, - rbx: Gem::Platform::RUBY, - truffleruby: Gem::Platform::RUBY, - jruby: Gem::Platform::JAVA, - jruby_18: Gem::Platform::JAVA, - jruby_19: Gem::Platform::JAVA, - windows: Gem::Platform::WINDOWS, - windows_18: Gem::Platform::WINDOWS, - windows_19: Gem::Platform::WINDOWS, - windows_20: Gem::Platform::WINDOWS, - windows_21: Gem::Platform::WINDOWS, - windows_22: Gem::Platform::WINDOWS, - windows_23: Gem::Platform::WINDOWS, - windows_24: Gem::Platform::WINDOWS, - windows_25: Gem::Platform::WINDOWS, - windows_26: Gem::Platform::WINDOWS, - windows_27: Gem::Platform::WINDOWS, - windows_30: Gem::Platform::WINDOWS, - windows_31: Gem::Platform::WINDOWS, - windows_32: Gem::Platform::WINDOWS, - windows_33: Gem::Platform::WINDOWS, - windows_34: Gem::Platform::WINDOWS, - windows_35: Gem::Platform::WINDOWS } - end - - let(:deprecated) do - { mswin: Gem::Platform::MSWIN, - mswin_18: Gem::Platform::MSWIN, - mswin_19: Gem::Platform::MSWIN, - mswin_20: Gem::Platform::MSWIN, - mswin_21: Gem::Platform::MSWIN, - mswin_22: Gem::Platform::MSWIN, - mswin_23: Gem::Platform::MSWIN, - mswin_24: Gem::Platform::MSWIN, - mswin_25: Gem::Platform::MSWIN, - mswin_26: Gem::Platform::MSWIN, - mswin_27: Gem::Platform::MSWIN, - mswin_30: Gem::Platform::MSWIN, - mswin_31: Gem::Platform::MSWIN, - mswin_32: Gem::Platform::MSWIN, - mswin_33: Gem::Platform::MSWIN, - mswin_34: Gem::Platform::MSWIN, - mswin_35: Gem::Platform::MSWIN, - mswin64: Gem::Platform::MSWIN64, - mswin64_19: Gem::Platform::MSWIN64, - mswin64_20: Gem::Platform::MSWIN64, - mswin64_21: Gem::Platform::MSWIN64, - mswin64_22: Gem::Platform::MSWIN64, - mswin64_23: Gem::Platform::MSWIN64, - mswin64_24: Gem::Platform::MSWIN64, - mswin64_25: Gem::Platform::MSWIN64, - mswin64_26: Gem::Platform::MSWIN64, - mswin64_27: Gem::Platform::MSWIN64, - mswin64_30: Gem::Platform::MSWIN64, - mswin64_31: Gem::Platform::MSWIN64, - mswin64_32: Gem::Platform::MSWIN64, - mswin64_33: Gem::Platform::MSWIN64, - mswin64_34: Gem::Platform::MSWIN64, - mswin64_35: Gem::Platform::MSWIN64, - mingw: Gem::Platform::MINGW, - mingw_18: Gem::Platform::MINGW, - mingw_19: Gem::Platform::MINGW, - mingw_20: Gem::Platform::MINGW, - mingw_21: Gem::Platform::MINGW, - mingw_22: Gem::Platform::MINGW, - mingw_23: Gem::Platform::MINGW, - mingw_24: Gem::Platform::MINGW, - mingw_25: Gem::Platform::MINGW, - mingw_26: Gem::Platform::MINGW, - mingw_27: Gem::Platform::MINGW, - mingw_30: Gem::Platform::MINGW, - mingw_31: Gem::Platform::MINGW, - mingw_32: Gem::Platform::MINGW, - mingw_33: Gem::Platform::MINGW, - mingw_34: Gem::Platform::MINGW, - mingw_35: Gem::Platform::MINGW, - x64_mingw: Gem::Platform::X64_MINGW, - x64_mingw_20: Gem::Platform::X64_MINGW, - x64_mingw_21: Gem::Platform::X64_MINGW, - x64_mingw_22: Gem::Platform::X64_MINGW, - x64_mingw_23: Gem::Platform::X64_MINGW, - x64_mingw_24: Gem::Platform::X64_MINGW, - x64_mingw_25: Gem::Platform::X64_MINGW, - x64_mingw_26: Gem::Platform::X64_MINGW, - x64_mingw_27: Gem::Platform::X64_MINGW, - x64_mingw_30: Gem::Platform::X64_MINGW, - x64_mingw_31: Gem::Platform::X64_MINGW, - x64_mingw_32: Gem::Platform::X64_MINGW, - x64_mingw_33: Gem::Platform::X64_MINGW, - x64_mingw_34: Gem::Platform::X64_MINGW, - x64_mingw_35: Gem::Platform::X64_MINGW } - end - # rubocop:enable Naming/VariableNumber - - it "includes all platforms" do - expect(subject).to eq(platforms.merge(deprecated)) - end - - it "is on the current platform" do - engine = Gem.win_platform? ? "windows" : RUBY_ENGINE - - dep = described_class.new( - "test_gem", - "1.0.0", - { "platforms" => "#{engine}_#{RbConfig::CONFIG["MAJOR"]}#{RbConfig::CONFIG["MINOR"]}" }, - ) + dep = described_class.new( + "test_gem", + "1.0.0", + { "platforms" => "#{engine}_#{RbConfig::CONFIG["MAJOR"]}#{RbConfig::CONFIG["MINOR"]}" }, + ) - expect(dep.current_platform?).to be_truthy - end + expect(dep.current_platform?).to be_truthy end end