Created
July 26, 2013 21:32
-
-
Save anthonycrumley/6092393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../test_helper' | |
class RangeTest < ActiveSupport::TestCase | |
test "Range#coinsides_with?" do | |
range_1 = Time.zone.now..Time.zone.now | |
range_2 = range_1 | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 | | |
2 | | |
MESSAGE | |
range_1 = 1.hour.ago..Time.zone.now | |
range_2 = range_1 | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |----| | |
2 |----| | |
MESSAGE | |
consistent_time = 1.hour.ago | |
range_1 = consistent_time..Time.zone.now | |
range_2 = consistent_time..1.hour.from_now | |
refute (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |----| | |
2 |--------| | |
MESSAGE | |
consistent_time = 1.hour.ago | |
range_1 = consistent_time..1.hour.from_now | |
range_2 = consistent_time..Time.zone.now | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |--------| | |
2 |----| | |
MESSAGE | |
consistent_time = Time.zone.now | |
range_1 = 1.hour.ago..consistent_time | |
range_2 = 2.hours.ago..consistent_time | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |----| | |
2 |---------| | |
MESSAGE | |
consistent_time = Time.zone.now | |
range_1 = 2.hours.ago..consistent_time | |
range_2 = 1.hour.ago..consistent_time | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |--------| | |
2 |----| | |
MESSAGE | |
consistent_time = Time.zone.now | |
range_1 = 1.hour.ago..consistent_time | |
range_2 = consistent_time..1.hour.from_now | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |----| | |
2 |----| | |
MESSAGE | |
consistent_time = Time.zone.now | |
range_1 = consistent_time..1.hour.from_now | |
range_2 = 1.hour.ago..consistent_time | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |----| | |
2 |----| | |
MESSAGE | |
range_1 = 1.hour.ago..1.hour.from_now | |
range_2 = 2.hours.ago..Time.zone.now | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |---------| | |
2 |---------| | |
MESSAGE | |
range_1 = 2.hours.ago..Time.zone.now | |
range_2 = 1.hour.ago..1.hour.from_now | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |---------| | |
2 |---------| | |
MESSAGE | |
range_1 = 1.hour.ago..Time.zone.now | |
range_2 = 2.hours.ago..1.hour.from_now | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |----| | |
2 |--------------| | |
MESSAGE | |
range_1 = 2.hours.ago..1.hour.from_now | |
range_2 = 1.hour.ago..Time.zone.now | |
assert (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges should coincide but don't! | |
1 |--------------| | |
2 |----| | |
MESSAGE | |
range_1 = 1.hour.ago..Time.zone.now | |
range_2 = 1.hour.from_now..2.hours.from_now | |
refute (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges coinside but should not! | |
1 |----| | |
2 |----| | |
MESSAGE | |
range_1 = 1.hour.from_now..2.hours.from_now | |
range_2 = 1.hour.ago..Time.zone.now | |
refute (range_1).coinsides_with?(range_2), <<-MESSAGE | |
Ranges coinside but should not! | |
1 |----| | |
2 |----| | |
MESSAGE | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment