Skip to content

Instantly share code, notes, and snippets.

@tolitius
Created January 24, 2013 15:57
Show Gist options
  • Save tolitius/4623700 to your computer and use it in GitHub Desktop.
Save tolitius/4623700 to your computer and use it in GitHub Desktop.
едем из Харькова в Париж через Сан Франциско
package com.typesafe.training.scalatrain
import org.specs2.mutable._
class TrainSpec extends Specification {
val kharkovStation = Station("Харьков")
val sfStation = Station("Сан Франциско")
val parisStation = Station("Париж")
val t1 = Time(11, 11)
val t2 = Time(12, 12)
val t3 = Time(13, 13)
"Train" should {
"throw IllegalArgumentException schedules that have less than 2 stations" in {
Train(1, "Hogwarts", Vector()) must throwA[IllegalArgumentException]
Train(2, "Hogwarts", Vector(t1 -> kharkovStation)) must throwA[IllegalArgumentException]
}
"be created properly with 2 or more schedule entries" in {
Train(3, "Hogwarts", Vector(t1 -> kharkovStation, t2 -> sfStation)).schedule.size ==== 2
Train(4, "Hogwarts", Vector(t1 -> kharkovStation, t2 -> sfStation, t3 -> parisStation)).schedule.size ==== 3
}
"be created properly with stations initialized correctly" in {
Train(3, "Hogwarts", Vector(t1 -> kharkovStation, t2 -> sfStation)).stations ==== List(Station("Харьков"), Station("Сан Франциско"))
Train(4, "Hogwarts", Vector(t1 -> kharkovStation, t2 -> sfStation, t3 -> parisStation)).stations ==== List(Station("Харьков"), Station("Сан Франциско"), Station("Париж"))
}
}
}
@dsklyut
Copy link

dsklyut commented Jan 24, 2013

I like this syntax a bit more:
train.stations must contain(st1, st2).inOrder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment