1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[bundler/bundler] Use the standard RUBY_ENGINE_VERSION instead of JRUBY_VERSION

* RUBY_ENGINE and RUBY_ENGINE_VERSION are defined on every modern Ruby.
* There is no such constant as TRUFFLERUBY_VERSION or RBX_VERSION.

f9d910403b
This commit is contained in:
Benoit Daloze 2019-08-04 14:52:15 +02:00 committed by SHIBATA Hiroshi
parent 6711343d5a
commit 2b0f3aa095
Notes: git 2019-08-31 04:40:14 +09:00
4 changed files with 14 additions and 35 deletions

View file

@ -103,18 +103,8 @@ module Bundler
def self.system def self.system
ruby_engine = RUBY_ENGINE.dup ruby_engine = RUBY_ENGINE.dup
# :sob: mocking RUBY_VERSION breaks stuff on 1.8.7
ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
ruby_engine_version = case ruby_engine ruby_engine_version = RUBY_ENGINE_VERSION.dup
when "ruby"
ruby_version
when "rbx"
Rubinius::VERSION.dup
when "jruby"
JRUBY_VERSION.dup
else
RUBY_ENGINE_VERSION.dup
end
patchlevel = RUBY_PATCHLEVEL.to_s patchlevel = RUBY_PATCHLEVEL.to_s
@ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version) @ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)

View file

@ -427,7 +427,7 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do
describe "#engine" do describe "#engine" do
before { stub_const("RUBY_ENGINE", "jruby") } before { stub_const("RUBY_ENGINE", "jruby") }
before { stub_const("JRUBY_VERSION", "2.1.1") } before { stub_const("RUBY_ENGINE_VERSION", "2.1.1") }
it "should return a copy of the value of RUBY_ENGINE" do it "should return a copy of the value of RUBY_ENGINE" do
expect(subject.engine).to eq("jruby") expect(subject.engine).to eq("jruby")
@ -438,37 +438,37 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do
describe "#engine_version" do describe "#engine_version" do
context "engine is ruby" do context "engine is ruby" do
before do before do
stub_const("RUBY_VERSION", "2.2.4") stub_const("RUBY_ENGINE_VERSION", "2.2.4")
stub_const("RUBY_ENGINE", "ruby") stub_const("RUBY_ENGINE", "ruby")
end end
it "should return a copy of the value of RUBY_VERSION" do it "should return a copy of the value of RUBY_ENGINE_VERSION" do
expect(bundler_system_ruby_version.engine_versions).to eq(["2.2.4"]) expect(bundler_system_ruby_version.engine_versions).to eq(["2.2.4"])
expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_VERSION) expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
end end
end end
context "engine is rbx" do context "engine is rbx" do
before do before do
stub_const("RUBY_ENGINE", "rbx") stub_const("RUBY_ENGINE", "rbx")
stub_const("Rubinius::VERSION", "2.0.0") stub_const("RUBY_ENGINE_VERSION", "2.0.0")
end end
it "should return a copy of the value of Rubinius::VERSION" do it "should return a copy of the value of RUBY_ENGINE_VERSION" do
expect(bundler_system_ruby_version.engine_versions).to eq(["2.0.0"]) expect(bundler_system_ruby_version.engine_versions).to eq(["2.0.0"])
expect(bundler_system_ruby_version.engine_versions.first).to_not be(Rubinius::VERSION) expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
end end
end end
context "engine is jruby" do context "engine is jruby" do
before do before do
stub_const("RUBY_ENGINE", "jruby") stub_const("RUBY_ENGINE", "jruby")
stub_const("JRUBY_VERSION", "2.1.1") stub_const("RUBY_ENGINE_VERSION", "2.1.1")
end end
it "should return a copy of the value of JRUBY_VERSION" do it "should return a copy of the value of RUBY_ENGINE_VERSION" do
expect(subject.engine_versions).to eq(["2.1.1"]) expect(subject.engine_versions).to eq(["2.1.1"])
expect(bundler_system_ruby_version.engine_versions.first).to_not be(JRUBY_VERSION) expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
end end
end end

View file

@ -53,9 +53,7 @@ class Object
remove_const :RUBY_ENGINE remove_const :RUBY_ENGINE
RUBY_ENGINE = ENV["BUNDLER_SPEC_RUBY_ENGINE"] RUBY_ENGINE = ENV["BUNDLER_SPEC_RUBY_ENGINE"]
if RUBY_ENGINE == "jruby" remove_const :RUBY_ENGINE_VERSION
remove_const :JRUBY_VERSION if defined?(JRUBY_VERSION) RUBY_ENGINE_VERSION = ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
JRUBY_VERSION = ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
end
end end
end end

View file

@ -71,16 +71,7 @@ module Spec
def local_engine_version def local_engine_version
return ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"] if ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"] return ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"] if ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
case local_ruby_engine RUBY_ENGINE_VERSION
when "ruby"
RUBY_VERSION
when "rbx"
Rubinius::VERSION
when "jruby"
JRUBY_VERSION
else
RUBY_ENGINE_VERSION
end
end end
def not_local_engine_version def not_local_engine_version