Permalink
Browse files

Deprecate Specs, port to Specs2.

  • Loading branch information...
1 parent 6a543b2 commit 0153c36f2579b74ad8214f524d3e102b9e6775b0 @rossabaker rossabaker committed Nov 23, 2012
@@ -1,6 +1,6 @@
package org.scalatra.akka
-import org.scalatra.test.specs.ScalatraSpecification
+import org.scalatra.test.specs2.MutableScalatraSpec
import org.scalatra.ScalatraFilter
import akka.actor.ActorSystem
import akka.dispatch.Future
@@ -57,7 +57,7 @@ class AkkaSupportAfterFilterFilter extends ScalatraFilter with AkkaSupport {
}
}
-class AkkaSupportAfterFilterForFiltersSpec extends ScalatraSpecification {
+class AkkaSupportAfterFilterForFiltersSpec extends MutableScalatraSpec {
sequential
val filter = new AkkaSupportAfterFilterFilter()
@@ -1,6 +1,6 @@
package org.scalatra.akka
-import org.scalatra.test.specs.ScalatraSpecification
+import org.scalatra.test.specs2.MutableScalatraSpec
import org.scalatra.ScalatraServlet
import akka.actor.ActorSystem
import akka.dispatch.Future
@@ -57,7 +57,7 @@ class AkkaSupportAfterFilterServlet extends ScalatraServlet with AkkaSupport {
}
}
-class AkkaSupportAfterFilterSpec extends ScalatraSpecification {
+class AkkaSupportAfterFilterSpec extends MutableScalatraSpec {
sequential
val servlet = new AkkaSupportAfterFilterServlet()
@@ -8,7 +8,7 @@ import _root_.akka.actor.SupervisorStrategy._
import _root_.akka.util.duration._
import _root_.akka.util.Timeout
-import test.specs.ScalatraSpecification
+import test.specs2.MutableScalatraSpec
class AkkaSupportServlet extends ScalatraServlet with AkkaSupport {
val system = ActorSystem()
@@ -48,7 +48,7 @@ class AkkaSupportServlet extends ScalatraServlet with AkkaSupport {
}
}
-class AkkaSupportSpec extends ScalatraSpecification {
+class AkkaSupportSpec extends MutableScalatraSpec {
addServlet(new AkkaSupportServlet, "/*")
"The AkkaSupport" should {
@@ -67,7 +67,7 @@ class AkkaSupportSpec extends ScalatraSpecification {
"handle an async exception" in {
get("/fail") {
- body must include("caught")
+ body must contain("caught")
}
}
@@ -1,16 +1,16 @@
package org.scalatra
package auth
-import org.specs._
-import mock.Mockito
+import org.specs2.mutable._
import org.mockito.Matchers._
-import runner.{ScalaTest, JUnit}
import javax.servlet.http.{Cookie, HttpServletResponse, HttpServletRequest, HttpSession}
-import org.scalatra.SweetCookies
import auth.ScentryAuthStore.SessionAuthStore
+import org.specs2.mock.Mockito
+
+object ScentrySpec extends Specification with Mockito {
+ sequential
+ isolated
-object ScentrySpec extends Specification with Mockito with JUnit with ScalaTest {
- detailedDiffs
case class User(id: String)
"The scentry" should {
@@ -20,13 +20,13 @@ object ScentrySpec extends Specification with Mockito with JUnit with ScalaTest
private[this] val sessionMap = scala.collection.mutable.HashMap[String, Any](Scentry.scentryAuthKey -> "6789")
override val session = smartMock[HttpSession]
session.getAttribute(anyString) answers { k => sessionMap.getOrElse(k.asInstanceOf[String], null).asInstanceOf[AnyRef] }
- session.setAttribute(anyString(), anyObject()) answers { kv =>
- val kvArray = kv.asInstanceOf[Array[AnyRef]]
- sessionMap(kvArray(0).asInstanceOf[String]) = kvArray(1)
+ session.setAttribute(anyString, anyObject) answers { (kv, wtfIsThis) =>
+ val Array(k: String, v: Any) = kv
+ sessionMap(k) = v
}
- session.invalidate() answers {
+ session.invalidate() answers { k =>
invalidateCalled = true
- k => sessionMap.clear()
+ sessionMap.clear()
}
}
val theScentry = new Scentry[User](context, { case User(id) => id }, { case s: String => User(s)}, new SessionAuthStore(context.session))
@@ -1,6 +1,6 @@
package org.scalatra
-import test.specs.ScalatraSpecification
+import test.specs2.MutableScalatraSpec
class ApiFormatsServlet extends ScalatraServlet with ApiFormats {
override protected implicit def string2RouteMatcher(path: String): RouteMatcher = RailsPathPatternParser(path)
@@ -16,7 +16,7 @@ class ApiFormatsServlet extends ScalatraServlet with ApiFormats {
}
-class ApiFormatsSpec extends ScalatraSpecification {
+class ApiFormatsSpec extends MutableScalatraSpec {
addServlet(new ApiFormatsServlet, "/*")
@@ -2,7 +2,7 @@ package org.scalatra
import org.scalatra._
-import test.specs.ScalatraSpecification
+import test.specs2.MutableScalatraSpec
class CsrfTokenServlet extends ScalatraServlet with CsrfTokenSupport {
get("/renderForm") {
@@ -18,14 +18,14 @@ class CsrfTokenServlet extends ScalatraServlet with CsrfTokenSupport {
}
}
-object CsrfTokenSpec extends ScalatraSpecification {
+object CsrfTokenSpec extends MutableScalatraSpec {
addServlet(classOf[CsrfTokenServlet], "/*")
"the get request should include the CSRF token" in {
get("/renderForm") {
- body must beMatching("""value="\w+""")
+ body must beMatching("""(?s).*value="\w+".*""")
}
}
@@ -47,7 +47,7 @@ object CsrfTokenSpec extends ScalatraSpecification {
}
post("/renderForm", CsrfTokenSupport.DefaultKey -> "Hey I'm different") {
status must be_==(403)
- body mustNot be_==("SUCCESS")
+ body must not be_==("SUCCESS")
}
}
}
@@ -1,6 +1,6 @@
package org.scalatra
-import test.specs.ScalatraSpecification
+import test.specs2.MutableScalatraSpec
import java.net.HttpCookie
import collection.JavaConverters._
@@ -17,7 +17,7 @@ class XsrfTokenServlet extends ScalatraServlet with CookieSupport with XsrfToken
}
}
-object XsrfTokenSpec extends ScalatraSpecification {
+object XsrfTokenSpec extends MutableScalatraSpec {
addServlet(classOf[XsrfTokenServlet], "/*")
@@ -29,8 +29,8 @@ object XsrfTokenSpec extends ScalatraSpecification {
"the get request should include the CSRF token" in {
get("/renderForm") {
- tokenFromCookie mustNot beNull
- tokenFromCookie mustNot beEmpty
+ tokenFromCookie must not be null
+ tokenFromCookie must not be empty
body must beMatching("GO")
}
}
@@ -55,7 +55,7 @@ object XsrfTokenSpec extends ScalatraSpecification {
}
post("/renderForm", headers = Map(XsrfTokenSupport.HeaderNames.head -> "Hey I'm different")) {
status must be_==(403)
- body mustNot be_==("SUCCESS")
+ body must not be_==("SUCCESS")
}
}
}
@@ -1,7 +1,7 @@
package org.scalatra
package json
-import test.specs.ScalatraSpecification
+import test.specs2.MutableScalatraSpec
import org.json4s._
class NativeJsonSupportServlet extends ScalatraServlet with NativeJsonSupport {
@@ -20,7 +20,7 @@ class NativeJsonSupportServlet extends ScalatraServlet with NativeJsonSupport {
}
-class NativeJsonRequestBodySpec extends ScalatraSpecification {
+class NativeJsonRequestBodySpec extends MutableScalatraSpec {
addServlet(new NativeJsonSupportServlet, "/*")
@@ -66,7 +66,7 @@ class JacksonSupportServlet extends ScalatraServlet with JacksonJsonSupport {
}
}
-class JacksonRequestBodySpec extends ScalatraSpecification {
+class JacksonRequestBodySpec extends MutableScalatraSpec {
addServlet(new JacksonSupportServlet, "/*")
View
@@ -0,0 +1,3 @@
+## scalatra-specs
+
+* Deprecate scalatra-specs in anticipation of Scala 2.10 support.
@@ -6,6 +6,7 @@ import org.specs._
/**
* A Specification that starts the tester before the specification and stops it afterward.
*/
+@deprecated("Upgrade to Specs2.", "2.2.0")
trait ScalatraSpecification extends Specification with ScalatraTests {
doBeforeSpec { start() }
doAfterSpec { stop() }

0 comments on commit 0153c36

Please sign in to comment.