--- a/src/main/scala/Util.scala Wed Aug 24 14:33:51 2011 -0400
+++ b/src/main/scala/Util.scala Wed Aug 24 14:43:50 2011 -0400
@@ -7,6 +7,13 @@
import java.net.{URL, URLDecoder}
import org.slf4j.{Logger, LoggerFactory}
+object RequestHelper {
+ import dispatch._
+
+ def POST(req:Request, body:String) = (req <<< body).copy(method="POST")
+
+}
+
/** useful stuff to read resources from the classpath */
object ResourceManager {
--- a/src/test/scala/RecordAPISpec.scala Wed Aug 24 14:33:51 2011 -0400
+++ b/src/test/scala/RecordAPISpec.scala Wed Aug 24 14:43:50 2011 -0400
@@ -1,5 +1,7 @@
package org.w3.virtualtrainer
+import org.w3.virtualtrainer.util.RequestHelper
+
import org.specs._
import java.net.URL
@@ -35,12 +37,11 @@
]
}
"""
-
"POST record" should {
val POSTrun = host / "user" / "jdoe" / "run"
"return a location telling where the record is GETtable" in {
- val locationHeader:String = Http((POSTrun <<< record).copy(method="POST") >:> { headers =>
+ val locationHeader:String = Http(RequestHelper.POST(POSTrun, record) >:> { headers =>
headers get "Location" getOrElse sys.error("no Location header") head
})
val locationURL = new URL(locationHeader)