Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Use the standard RUBY_ENGINE_VERSION instead of JRUBY_VERSION
Browse files Browse the repository at this point in the history
* RUBY_ENGINE and RUBY_ENGINE_VERSION are defined on every modern Ruby.
* There is no such constant as TRUFFLERUBY_VERSION or RBX_VERSION.
  • Loading branch information
eregon committed Aug 4, 2019
1 parent e1c5183 commit f9d9104
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 35 deletions.
12 changes: 1 addition & 11 deletions lib/bundler/ruby_version.rb
Expand Up @@ -103,18 +103,8 @@ def versions_string(versions)

def self.system
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_engine_version = case ruby_engine
when "ruby"
ruby_version
when "rbx"
Rubinius::VERSION.dup
when "jruby"
JRUBY_VERSION.dup
else
RUBY_ENGINE_VERSION.dup
end
ruby_engine_version = RUBY_ENGINE_VERSION.dup
patchlevel = RUBY_PATCHLEVEL.to_s

@ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
Expand Down
20 changes: 10 additions & 10 deletions spec/bundler/ruby_version_spec.rb
Expand Up @@ -427,7 +427,7 @@

describe "#engine" do
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
expect(subject.engine).to eq("jruby")
Expand All @@ -438,37 +438,37 @@
describe "#engine_version" do
context "engine is ruby" do
before do
stub_const("RUBY_VERSION", "2.2.4")
stub_const("RUBY_ENGINE_VERSION", "2.2.4")
stub_const("RUBY_ENGINE", "ruby")
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.first).to_not be(RUBY_VERSION)
expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
end
end

context "engine is rbx" do
before do
stub_const("RUBY_ENGINE", "rbx")
stub_const("Rubinius::VERSION", "2.0.0")
stub_const("RUBY_ENGINE_VERSION", "2.0.0")
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.first).to_not be(Rubinius::VERSION)
expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION)
end
end

context "engine is jruby" do
before do
stub_const("RUBY_ENGINE", "jruby")
stub_const("JRUBY_VERSION", "2.1.1")
stub_const("RUBY_ENGINE_VERSION", "2.1.1")
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(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

Expand Down
6 changes: 2 additions & 4 deletions spec/support/hax.rb
Expand Up @@ -53,9 +53,7 @@ class Object
remove_const :RUBY_ENGINE
RUBY_ENGINE = ENV["BUNDLER_SPEC_RUBY_ENGINE"]

if RUBY_ENGINE == "jruby"
remove_const :JRUBY_VERSION if defined?(JRUBY_VERSION)
JRUBY_VERSION = ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
end
remove_const :RUBY_ENGINE_VERSION
RUBY_ENGINE_VERSION = ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
end
end
11 changes: 1 addition & 10 deletions spec/support/platforms.rb
Expand Up @@ -71,16 +71,7 @@ def local_ruby_engine
def local_engine_version
return ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"] if ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]

case local_ruby_engine
when "ruby"
RUBY_VERSION
when "rbx"
Rubinius::VERSION
when "jruby"
JRUBY_VERSION
else
RUBY_ENGINE_VERSION
end
RUBY_ENGINE_VERSION
end

def not_local_engine_version
Expand Down

0 comments on commit f9d9104

Please sign in to comment.