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

Simplify RUBY_VERSION checking in tests

This commit is contained in:
Ryuta Kamizono 2020-01-29 09:31:00 +09:00
parent df9b61f38f
commit 5aae2b2783
3 changed files with 11 additions and 11 deletions

View file

@ -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.."),

View file

@ -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

View file

@ -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