import org.scalatra.test.scalatest.ScalatraFunSuite class ExtremeStartupServletTest extends ScalatraFunSuite { test("what is your name") { answerTo("fc480360: what is your name") should be("Mikkel") } test("my name is") { answerTo("ff4970f0: my name is bob. what is my name") should be ("bob") } test("addition") { answerTo("05450bb0: what is 9 plus 9") should be("18") } test("multiplication") { answerTo("05450bb0: what is 4 multiplied by 4") should be("16") } test("subtraction") { answerTo("05450bb0: what is 9 minus 17") should be("-8") } test("largest number") { answerTo("05450bb0: which of the following numbers is the largest: 12, 15, 31, 17") should be ("31") } test("prime numbers") { answerTo("05450bb0: which of the following numbers are primes: 5, 7, 149, 720, 553, 257") should be ("5, 7, 149, 257") } test("fibonacci") { answerTo("0b6768b0: what is the 14th number in the Fibonacci sequence") should be ("377") } test("square and cube") { answerTo("05450bb0: which of the following numbers is both a square and a cube: 729, 303") should be ("729") } addServlet(classOf[ExtremeStartupServlet], "/*") def question(q: String) : (String, String) = ("q", q) def answerTo(q: String) : String = { get("/", question(q)) { status should be(200) body } } }