aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorOwen Stephens <owen@owenstephens.co.uk>2019-03-28 00:57:05 +0000
committerOwen Stephens <owen@owenstephens.co.uk>2019-03-28 00:57:05 +0000
commitca2a3bcaad04b522a08b89aafaf0ecb6db7d05ca (patch)
tree004f91e60a6d2d67c158cee6138a827cb8bc671e /activesupport/test
parent5f043c0094173a26bea1cfc15c6d3bdbe8c9954b (diff)
downloadrails-ca2a3bcaad04b522a08b89aafaf0ecb6db7d05ca.tar.gz
rails-ca2a3bcaad04b522a08b89aafaf0ecb6db7d05ca.tar.bz2
rails-ca2a3bcaad04b522a08b89aafaf0ecb6db7d05ca.zip
Fix bug in Range comparisons when comparing to excluded-end Range
Before: ```ruby (1..10).cover?(1...11) => false ``` After: ```ruby (1..10).cover?(1...11) => true ``` See https://git.io/fjTtz for the commit against Ruby core that added support for Range arguments, with similar handling of this case.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/range_ext_test.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb
index 4b8efb8a93..16d6a4c2f2 100644
--- a/activesupport/test/core_ext/range_ext_test.rb
+++ b/activesupport/test/core_ext/range_ext_test.rb
@@ -57,7 +57,7 @@ class RangeTest < ActiveSupport::TestCase
end
def test_should_include_other_with_exclusive_end
- assert((1..10).include?(1...10))
+ assert((1..10).include?(1...11))
end
def test_should_compare_identical_inclusive
@@ -69,7 +69,7 @@ class RangeTest < ActiveSupport::TestCase
end
def test_should_compare_other_with_exclusive_end
- assert((1..10) === (1...10))
+ assert((1..10) === (1...11))
end
def test_exclusive_end_should_not_include_identical_with_inclusive_end
@@ -93,6 +93,10 @@ class RangeTest < ActiveSupport::TestCase
assert range.method(:include?) != range.method(:cover?)
end
+ def test_should_cover_other_with_exclusive_end
+ assert((1..10).cover?(1...11))
+ end
+
def test_overlaps_on_time
time_range_1 = Time.utc(2005, 12, 10, 15, 30)..Time.utc(2005, 12, 10, 17, 30)
time_range_2 = Time.utc(2005, 12, 10, 17, 00)..Time.utc(2005, 12, 10, 18, 00)