From 5aae2b27832abb0f2238300d055fbb5fe461e8f7 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 29 Jan 2020 09:31:00 +0900 Subject: [PATCH] Simplify RUBY_VERSION checking in tests --- .../test/cases/adapters/postgresql/range_test.rb | 2 +- .../test/cases/arel/attributes/attribute_test.rb | 8 ++++---- activesupport/test/core_ext/range_ext_test.rb | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/activerecord/test/cases/adapters/postgresql/range_test.rb b/activerecord/test/cases/adapters/postgresql/range_test.rb index 068f1e8bea..ca57bc2154 100644 --- a/activerecord/test/cases/adapters/postgresql/range_test.rb +++ b/activerecord/test/cases/adapters/postgresql/range_test.rb @@ -375,7 +375,7 @@ class PostgresqlRangeTest < ActiveRecord::PostgreSQLTestCase assert_equal(-Float::INFINITY...Float::INFINITY, record.float_range) end - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0") + if RUBY_VERSION >= "2.6" def test_endless_range_values record = PostgresqlRange.create!( int4_range: eval("1.."), diff --git a/activerecord/test/cases/arel/attributes/attribute_test.rb b/activerecord/test/cases/arel/attributes/attribute_test.rb index 05dbb25857..97d22fa493 100644 --- a/activerecord/test/cases/arel/attributes/attribute_test.rb +++ b/activerecord/test/cases/arel/attributes/attribute_test.rb @@ -638,7 +638,7 @@ module Arel ) end - if Gem::Version.new("2.7.0") <= Gem::Version.new(RUBY_VERSION) + if RUBY_VERSION >= "2.7" it "can be constructed with a range implicitly starting at Infinity" do attribute = Attribute.new nil, nil node = attribute.between(eval("..0")) # eval for backwards compatibility @@ -650,7 +650,7 @@ module Arel end end - if Gem::Version.new("2.6.0") <= Gem::Version.new(RUBY_VERSION) + if RUBY_VERSION >= "2.6" it "can be constructed with a range implicitly ending at Infinity" do attribute = Attribute.new nil, nil node = attribute.between(eval("0..")) # Use eval for compatibility with Ruby < 2.6 parser @@ -851,7 +851,7 @@ module Arel ) end - if Gem::Version.new("2.7.0") <= Gem::Version.new(RUBY_VERSION) + if RUBY_VERSION >= "2.7" it "can be constructed with a range implicitly starting at Infinity" do attribute = Attribute.new nil, nil node = attribute.not_between(eval("..0")) # eval for backwards compatibility @@ -863,7 +863,7 @@ module Arel end end - if Gem::Version.new("2.6.0") <= Gem::Version.new(RUBY_VERSION) + if RUBY_VERSION >= "2.6" it "can be constructed with a range implicitly ending at Infinity" do attribute = Attribute.new nil, nil node = attribute.not_between(eval("0..")) # Use eval for compatibility with Ruby < 2.6 parser diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb index 4d2a302e6b..4ef2b22642 100644 --- a/activesupport/test/core_ext/range_ext_test.rb +++ b/activesupport/test/core_ext/range_ext_test.rb @@ -60,7 +60,7 @@ class RangeTest < ActiveSupport::TestCase assert((1..10).include?(1...11)) end - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0") + if RUBY_VERSION >= "2.6" def test_include_with_endless_range assert(eval("1..").include?(2)) end @@ -74,7 +74,7 @@ class RangeTest < ActiveSupport::TestCase end end - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0") + if RUBY_VERSION >= "2.7" def test_include_with_beginless_range assert(eval("..2").include?(1)) end @@ -100,7 +100,7 @@ class RangeTest < ActiveSupport::TestCase assert((1..10) === (1...11)) end - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0") + if RUBY_VERSION >= "2.6" def test_should_compare_range_with_endless_range assert(eval("1..") === (2..4)) end @@ -110,7 +110,7 @@ class RangeTest < ActiveSupport::TestCase end end - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0") + if RUBY_VERSION >= "2.7" def test_should_compare_range_with_beginless_range assert(eval("..2") === (-1..1)) end @@ -145,7 +145,7 @@ class RangeTest < ActiveSupport::TestCase assert((1..10).cover?(1...11)) end - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0") + if RUBY_VERSION >= "2.6" def test_should_cover_range_with_endless_range assert(eval("1..").cover?(2..4)) end @@ -155,7 +155,7 @@ class RangeTest < ActiveSupport::TestCase end end - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0") + if RUBY_VERSION >= "2.7" def test_should_cover_range_with_beginless_range assert(eval("..2").cover?(-1..1)) end