Permalink
Browse files

Add test for create

update gitignore
  • Loading branch information...
1 parent c2e8546 commit 2c1b714ea2a2a273b4c1a8ec673cefd12abc0aee @lynxor lynxor committed Dec 21, 2011
View
@@ -30,7 +30,7 @@ target
lib_managed
src_managed
project/boot
-
+bin/
# db
lift_proto*
View
@@ -1,6 +0,0 @@
-[submodule "src/main/resources/static/timo"]
- path = src/main/resources/static/timo
- url = git@github.com:nicokruger/timo-js
-[submodule "src/main/resources/static/vendor"]
- path = src/main/resources/static/vendor
- url = git@github.com:nicokruger/common-js-libs
View
@@ -22,7 +22,7 @@ libraryDependencies ++= Seq(
"net.liftweb" %% "lift-json" % "2.4-M4",
"org.specs2" %% "specs2" % "1.6.1" % "test",
"org.specs2" %% "specs2-scalaz-core" % "6.0.1" % "test",
- "org.mockito" % "mockito-all" % "1.9.0-rc1" % "test",
- "net.databinder" %% "unfiltered-spec" % "0.5.3",
+ "org.mockito" % "mockito-all" % "1.8.5" % "test",
+ "net.databinder" %% "unfiltered-spec" % "0.5.3" % "test",
"org.scalaz" %% "scalaz-core" % "6.0.3"
)
@@ -1,10 +1,6 @@
package za.co.whenis.main
-import java.net.URL
-import unfiltered.jetty.ContextBuilder
-import java.io.File
import unfiltered.jetty.Server
-import com.mongodb.casbah.MongoConnection._
import com.mongodb.casbah.MongoConnection
import za.co.whenis.{Search, Create, Lookup}
import za.co.whenis.counter.CountdownService
@@ -82,7 +82,7 @@ class Search(countdownService: CountdownService) extends CountdownPlan {
class Create(countdownService: CountdownService) extends CountdownPlan {
def intent = {
- case req@POST(Path(Seg("countdown" :: "new" :: Nil))) =>
+ case req@ POST(Path(Seg("countdown" :: "new" :: Nil))) =>
val Params(p) = req
newCountdown(p)
case req@POST(Path(Seg("countdown" :: "upsert" :: Nil))) =>
@@ -1,34 +1,29 @@
package za.co.whenis
-import org.specs2.mutable._
import org.specs2.mock._
- import counter.CountdownService
-import unfiltered.spec.jetty.Served
- import unfiltered.filter.Planify
-import unfiltered.request.{GET, Path}
-import org.joda.time.DateTime
+import counter.CountdownService
import dispatch._
import unfiltered.jetty.Server
+import com.mongodb.casbah.MongoDB
+import org.joda.time.DateTime
+import unfiltered.spec.jetty.Served
/**
- * User: dawidmalan
- * Date: 2011/12/20
- * Time: 11:04 AM
- */
-
-class PlanTest extends unfiltered.spec.jetty.Served with Mockito {
+* User: dawidmalan
+* Date: 2011/12/20
+* Time: 11:04 AM
+*/
+class PlanTest extends Served with Mockito {
val service : CountdownService = mock[CountdownService]
- val lookup = new Lookup(service)
val url = :/ ("localhost", server.port)
def setup = (server:Server) => {
//breaks when folding for some reason
server.filter(new Lookup(service)).filter(new Create(service)).filter(new Search(service))
}
-
- "The correct json " should {
+ "The correct json " should{
"be returned for week" in {
service.week returns Seq(Countdown("flavour of the week", "url", new DateTime(1324465548583L), List("whatever")))
val body = Http(url / "week" >- {r => r})
@@ -58,26 +53,19 @@ class PlanTest extends unfiltered.spec.jetty.Served with Mockito {
body must_== """{"countdowns":[{"name":"keep dreaming","eventDate":7,"tags":["nopain"],"url":"404"}]}"""
}
+}
- }
+ "requesting the creation urls" should {
+ "actually call the service " in {
+ service.insertCountdown(any[AspiringCountdown]) returns Some(Countdown("new countdown to be","awesome url",new DateTime(1324465548583L), List("awesome tag") ))
+ val params = Map("name" -> "new countdown to be", "eventDate" -> "23", "tags" -> "new,countdown")
-// "requesting the creation urls" should {
-// "actually call the service " in {
-// val s = c().verify.isSuccess
-// println("SUCCESS OR NOT YPOU FSADJFASDFASDFASDFASDFASDFDASF "+s)
-// 1 must_== 2
-//
-// }
-// }
-
- case class c() extends Mockito {
+ val body = Http( (url / "countdown" / "new").POST <<? params >- {r => r})
+ body must_== """{"countdowns":[{"name":"new countdown to be","eventDate":1324465548583,"tags":["awesome tag"],"url":"awesome url"}]}"""
- def verify = {
- service.insertCountdown(any[AspiringCountdown]) returns Some(Countdown("a","b",new DateTime(1324465548583L), List("c") ))
- val params = Map("name" -> "new countdown to be", "eventDate" -> "23", "tags" -> "new,countdown")
- Http(url / "countdown" / "new" <<? params >- {r => r})
- (there was no(service).upsertCountdown(any[AspiringCountdown]))
}
}
-}
+
+}
+

0 comments on commit 2c1b714

Please sign in to comment.