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:
parent
df9b61f38f
commit
5aae2b2783
3 changed files with 11 additions and 11 deletions
|
@ -375,7 +375,7 @@ class PostgresqlRangeTest < ActiveRecord::PostgreSQLTestCase
|
||||||
assert_equal(-Float::INFINITY...Float::INFINITY, record.float_range)
|
assert_equal(-Float::INFINITY...Float::INFINITY, record.float_range)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
|
if RUBY_VERSION >= "2.6"
|
||||||
def test_endless_range_values
|
def test_endless_range_values
|
||||||
record = PostgresqlRange.create!(
|
record = PostgresqlRange.create!(
|
||||||
int4_range: eval("1.."),
|
int4_range: eval("1.."),
|
||||||
|
|
|
@ -638,7 +638,7 @@ module Arel
|
||||||
)
|
)
|
||||||
end
|
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
|
it "can be constructed with a range implicitly starting at Infinity" do
|
||||||
attribute = Attribute.new nil, nil
|
attribute = Attribute.new nil, nil
|
||||||
node = attribute.between(eval("..0")) # eval for backwards compatibility
|
node = attribute.between(eval("..0")) # eval for backwards compatibility
|
||||||
|
@ -650,7 +650,7 @@ module Arel
|
||||||
end
|
end
|
||||||
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
|
it "can be constructed with a range implicitly ending at Infinity" do
|
||||||
attribute = Attribute.new nil, nil
|
attribute = Attribute.new nil, nil
|
||||||
node = attribute.between(eval("0..")) # Use eval for compatibility with Ruby < 2.6 parser
|
node = attribute.between(eval("0..")) # Use eval for compatibility with Ruby < 2.6 parser
|
||||||
|
@ -851,7 +851,7 @@ module Arel
|
||||||
)
|
)
|
||||||
end
|
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
|
it "can be constructed with a range implicitly starting at Infinity" do
|
||||||
attribute = Attribute.new nil, nil
|
attribute = Attribute.new nil, nil
|
||||||
node = attribute.not_between(eval("..0")) # eval for backwards compatibility
|
node = attribute.not_between(eval("..0")) # eval for backwards compatibility
|
||||||
|
@ -863,7 +863,7 @@ module Arel
|
||||||
end
|
end
|
||||||
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
|
it "can be constructed with a range implicitly ending at Infinity" do
|
||||||
attribute = Attribute.new nil, nil
|
attribute = Attribute.new nil, nil
|
||||||
node = attribute.not_between(eval("0..")) # Use eval for compatibility with Ruby < 2.6 parser
|
node = attribute.not_between(eval("0..")) # Use eval for compatibility with Ruby < 2.6 parser
|
||||||
|
|
|
@ -60,7 +60,7 @@ class RangeTest < ActiveSupport::TestCase
|
||||||
assert((1..10).include?(1...11))
|
assert((1..10).include?(1...11))
|
||||||
end
|
end
|
||||||
|
|
||||||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
|
if RUBY_VERSION >= "2.6"
|
||||||
def test_include_with_endless_range
|
def test_include_with_endless_range
|
||||||
assert(eval("1..").include?(2))
|
assert(eval("1..").include?(2))
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ class RangeTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
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
|
def test_include_with_beginless_range
|
||||||
assert(eval("..2").include?(1))
|
assert(eval("..2").include?(1))
|
||||||
end
|
end
|
||||||
|
@ -100,7 +100,7 @@ class RangeTest < ActiveSupport::TestCase
|
||||||
assert((1..10) === (1...11))
|
assert((1..10) === (1...11))
|
||||||
end
|
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
|
def test_should_compare_range_with_endless_range
|
||||||
assert(eval("1..") === (2..4))
|
assert(eval("1..") === (2..4))
|
||||||
end
|
end
|
||||||
|
@ -110,7 +110,7 @@ class RangeTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
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
|
def test_should_compare_range_with_beginless_range
|
||||||
assert(eval("..2") === (-1..1))
|
assert(eval("..2") === (-1..1))
|
||||||
end
|
end
|
||||||
|
@ -145,7 +145,7 @@ class RangeTest < ActiveSupport::TestCase
|
||||||
assert((1..10).cover?(1...11))
|
assert((1..10).cover?(1...11))
|
||||||
end
|
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
|
def test_should_cover_range_with_endless_range
|
||||||
assert(eval("1..").cover?(2..4))
|
assert(eval("1..").cover?(2..4))
|
||||||
end
|
end
|
||||||
|
@ -155,7 +155,7 @@ class RangeTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
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
|
def test_should_cover_range_with_beginless_range
|
||||||
assert(eval("..2").cover?(-1..1))
|
assert(eval("..2").cover?(-1..1))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue