class RangeTest
Public Instance Methods
test_cover_is_not_override()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 86 def test_cover_is_not_override range = (1..3) assert range.method(:include?) != range.method(:cover?) end
test_date_range()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 24 def test_date_range assert_instance_of Range, DateTime.new..DateTime.new assert_instance_of Range, DateTime::Infinity.new..DateTime::Infinity.new assert_instance_of Range, DateTime.new..DateTime::Infinity.new end
test_date_time_with_each()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 124 def test_date_time_with_each datetime = DateTime.now assert(((datetime - 1.hour)..datetime).each {}) end
test_date_time_with_step()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 129 def test_date_time_with_step datetime = DateTime.now assert(((datetime - 1.hour)..datetime).step(1) {}) end
test_each_on_time_with_zone()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 103 def test_each_on_time_with_zone twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"] , Time.utc(2006, 11, 28, 10, 30)) assert_raises TypeError do ((twz - 1.hour)..twz).each {} end end
test_exclusive_end_should_not_include_identical_with_inclusive_end()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 70 def test_exclusive_end_should_not_include_identical_with_inclusive_end assert_not_includes (1...10), 1..10 end
test_include_on_time_with_zone()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 117 def test_include_on_time_with_zone twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"] , Time.utc(2006, 11, 28, 10, 30)) assert_raises TypeError do ((twz - 1.hour)..twz).include?(twz) end end
test_no_overlaps_on_time()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 97 def test_no_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, 31)..Time.utc(2005, 12, 10, 18, 00) assert !time_range_1.overlaps?(time_range_2) end
test_overlaps_first_exclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 42 def test_overlaps_first_exclusive assert !(5..10).overlaps?(1...5) end
test_overlaps_first_inclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 38 def test_overlaps_first_inclusive assert((5..10).overlaps?(1..5)) end
test_overlaps_last_exclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 34 def test_overlaps_last_exclusive assert !(1...5).overlaps?(5..10) end
test_overlaps_last_inclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 30 def test_overlaps_last_inclusive assert((1..5).overlaps?(5..10)) end
test_overlaps_on_time()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 91 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) assert time_range_1.overlaps?(time_range_2) end
test_should_compare_identical_exclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 62 def test_should_compare_identical_exclusive assert((1...10) === (1...10)) end
test_should_compare_identical_inclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 58 def test_should_compare_identical_inclusive assert((1..10) === (1..10)) end
test_should_compare_other_with_exclusive_end()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 66 def test_should_compare_other_with_exclusive_end assert((1..10) === (1...10)) end
test_should_include_identical_exclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 50 def test_should_include_identical_exclusive assert((1...10).include?(1...10)) end
test_should_include_identical_exclusive_with_floats()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 82 def test_should_include_identical_exclusive_with_floats assert((1.0...10.0).include?(1.0...10.0)) end
test_should_include_identical_inclusive()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 46 def test_should_include_identical_inclusive assert((1..10).include?(1..10)) end
test_should_include_other_with_exclusive_end()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 54 def test_should_include_other_with_exclusive_end assert((1..10).include?(1...10)) end
test_should_not_include_overlapping_first()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 74 def test_should_not_include_overlapping_first assert_not_includes (2..8), 1..3 end
test_should_not_include_overlapping_last()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 78 def test_should_not_include_overlapping_last assert_not_includes (2..8), 5..9 end
test_step_on_time_with_zone()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 110 def test_step_on_time_with_zone twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"] , Time.utc(2006, 11, 28, 10, 30)) assert_raises TypeError do ((twz - 1.hour)..twz).step(1) {} end end
test_to_s_from_dates()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 9 def test_to_s_from_dates date_range = Date.new(2005, 12, 10)..Date.new(2005, 12, 12) assert_equal "BETWEEN '2005-12-10' AND '2005-12-12'", date_range.to_s(:db) end
test_to_s_from_times()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 14 def test_to_s_from_times date_range = Time.utc(2005, 12, 10, 15, 30)..Time.utc(2005, 12, 10, 17, 30) assert_equal "BETWEEN '2005-12-10 15:30:00' AND '2005-12-10 17:30:00'", date_range.to_s(:db) end
test_to_s_with_numeric()
click to toggle source
# File activesupport/test/core_ext/range_ext_test.rb, line 19 def test_to_s_with_numeric number_range = (1..100) assert_equal "BETWEEN '1' AND '100'", number_range.to_s(:db) end