-
-
Save tmiller/6092290 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 < Test::Unit::TestCase | |
test <<-TEST do | |
Range#coinsides_with? | |
| | |
| | |
TEST | |
range = Time.zone.now..Time.zone.now | |
assert (range).coinsides_with?(range) | |
end | |
test <<-TEST do | |
Range#coinsides_with? | |
|----| | |
|----| | |
TEST | |
range = 1.hour.ago..Time.zone.now | |
assert (range).coinsides_with?(range) | |
end | |
test "Range#coinsides_with?" do | |
message = <<-MESSAGE | |
This should coinside: | |
| | |
| | |
MESSAGE | |
range = Time.zone.now..Time.zone.now | |
refute (range).coinsides_with?(range), message | |
range = 1.hour.ago..Time.zone.now | |
refute (range).coinsides_with?(range), <<-MESSAGE | |
This should coinside: | |
|----| | |
|----| | |
MESSAGE | |
consistent_time = 1.hour.ago | |
foo = consistent_time..Time.zone.now | |
bar = consistent_time..1.hour.from_now | |
refute (foo).coinsides_with?(bar), <<-MESSAGE | |
This should coinside: | |
|----| | |
|--------| | |
MESSAGE | |
# | | |
# | | |
range = Time.zone.now..Time.zone.now | |
assert (range).coinsides_with?(range) | |
# |----| | |
# |----| | |
range = 1.hour.ago..Time.zone.now | |
assert (range).coinsides_with?(range) | |
# |----| | |
# |--------| | |
consistent_time = 1.hour.ago | |
assert (consistent_time..Time.zone.now).coinsides_with?(consistent_time..1.hour.from_now) | |
# |--------| | |
# |----| | |
consistent_time = 1.hour.ago | |
assert (consistent_time..1.hour.from_now).coinsides_with?(consistent_time..Time.zone.now) | |
# |----| | |
# |---------| | |
consistent_time = Time.zone.now | |
assert (1.hour.ago..consistent_time).coinsides_with?(2.hours.ago..consistent_time) | |
# |--------| | |
# |----| | |
consistent_time = Time.zone.now | |
assert (2.hours.ago..consistent_time).coinsides_with?(1.hour.ago..consistent_time) | |
# |----| | |
# |----| | |
consistent_time = Time.zone.now | |
assert (1.hour.ago..consistent_time).coinsides_with?(consistent_time..1.hour.from_now) | |
# |----| | |
# |----| | |
consistent_time = Time.zone.now | |
assert (consistent_time..1.hour.from_now).coinsides_with?(1.hour.ago..consistent_time) | |
# |---------| | |
# |---------| | |
assert (1.hour.ago..1.hour.from_now).coinsides_with?(2.hours.ago..Time.zone.now) | |
# |---------| | |
# |---------| | |
assert (2.hours.ago..Time.zone.now).coinsides_with?(1.hour.ago..1.hour.from_now) | |
# |----| | |
# |--------------| | |
assert (1.hour.ago..Time.zone.now).coinsides_with?(2.hours.ago..1.hour.from_now) | |
# |--------------| | |
# |----| | |
assert (2.hours.ago..1.hour.from_now).coinsides_with?(1.hour.ago..Time.zone.now) | |
# |----| | |
# |----| | |
refute (1.hour.ago..Time.zone.now).coinsides_with?(1.hour.from_now..2.hours.from_now) | |
# |----| | |
# |----| | |
refute (1.hour.from_now..2.hours.from_now).coinsides_with?(1.hour.ago..Time.zone.now) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment