Permalink
Browse files

A las Barricadas! Upgraded to specs2 and rejiggered specs to comply w…

…ith structural and syntax changes.
  • Loading branch information...
rktoomey committed Mar 10, 2011
1 parent bd86c3b commit 493247fb8d9d5eeafb50f44fbceab1a0e6107af5
Showing with 234 additions and 230 deletions.
  1. +4 −4 pom.xml
  2. +9 −2 project/build/SalatProject.scala
  3. +3 −3 salat-core/src/test/scala/com/novus/salat/test/BasicCaseObjectSpec.scala
  4. +15 −18 salat-core/src/test/scala/com/novus/salat/test/BigDecimalPrecisionTest.scala
  5. +1 −2 salat-core/src/test/scala/com/novus/salat/test/BigIntSpec.scala
  6. +8 −5 salat-core/src/test/scala/com/novus/salat/test/CaseObjectSupport.scala
  7. +1 −2 salat-core/src/test/scala/com/novus/salat/test/CharacterSpec.scala
  8. +3 −3 salat-core/src/test/scala/com/novus/salat/test/ContextSpec.scala
  9. +17 −18 salat-core/src/test/scala/com/novus/salat/test/CustomContextSpec.scala
  10. +3 −4 salat-core/src/test/scala/com/novus/salat/test/DateTimeSpec.scala
  11. +10 −10 salat-core/src/test/scala/com/novus/salat/test/EnumSupportSpec.scala
  12. +1 −3 salat-core/src/test/scala/com/novus/salat/test/KeyAnnotationSpec.scala
  13. +5 −5 salat-core/src/test/scala/com/novus/salat/test/LazyValSpec.scala
  14. +66 −64 salat-core/src/test/scala/com/novus/salat/test/ListOfCommonTraitSpec.scala
  15. +4 −2 salat-core/src/test/scala/com/novus/salat/test/ObjectIdSpec.scala
  16. +14 −16 salat-core/src/test/scala/com/novus/salat/test/PersistAnnotationSpec.scala
  17. +8 −10 salat-core/src/test/scala/com/novus/salat/test/SalatSpec.scala
  18. +4 −5 salat-core/src/test/scala/com/novus/salat/test/SalatTraitSpec.scala
  19. +9 −9 salat-core/src/test/scala/com/novus/salat/test/SortedSeqSpec.scala
  20. +46 −41 salat-core/src/test/scala/com/novus/salat/test/TimingSpec.scala
  21. +3 −4 salat-core/src/test/scala/com/novus/salat/test/UUIDSupportSpec.scala
View
@@ -33,7 +33,7 @@
<commons.lang.version>2.5</commons.lang.version>
<slf4j.simple.version>1.6.0</slf4j.simple.version>
<!-- Test dependencies -->
- <specs.version>1.6.7</specs.version>
+ <specs2.version>1.0.1</specs2.version>
<!-- Build properties -->
<maven-jar-plugin.version>2.2</maven-jar-plugin.version>
<jar.dependency.dist.dir>lib</jar.dependency.dist.dir>
@@ -101,9 +101,9 @@
</dependency>
<!-- Test dependencies -->
<dependency>
- <groupId>org.scala-tools.testing</groupId>
- <artifactId>specs_2.8.1</artifactId>
- <version>${specs.version}</version>
+ <groupId>org.specs2</groupId>
+ <artifactId>specs2_2.8.1</artifactId>
+ <version>${specs2.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -11,12 +11,19 @@ class SalatProject(info: ProjectInfo) extends ParentProject(info) with posterous
abstract class BaseSalatProject(info: ProjectInfo) extends DefaultProject(info) {
override def compileOptions = super.compileOptions ++ Seq(Unchecked, Deprecation)
- val specs = "org.scala-tools.testing" %% "specs" % "1.6.7" % "test->default" withSources()
+ // val specs = "org.scala-tools.testing" %% "specs" % "1.6.7" % "test->default" withSources()
+ val specs2 = "org.specs2" %% "specs2" % "1.0.1" % "test->default"
val commonsLang = "commons-lang" % "commons-lang" % "2.5" % "test->default" withSources()
val slf4jSimple = "org.slf4j" % "slf4j-simple" % "1.6.0" % "test->default" withSources()
- override def packageSrcJar= defaultJarPath("-sources.jar")
+ override def packageSrcJar = defaultJarPath("-sources.jar")
+
override def packageToPublishActions = super.packageToPublishActions ++ Seq(packageSrc)
+
+ def specs2Framework = new TestFramework("org.specs2.runner.SpecsFramework")
+
+ override def testFrameworks = super.testFrameworks ++ Seq(specs2Framework)
+
}
class SalatCoreProject(info: ProjectInfo) extends BaseSalatProject(info) {
@@ -36,15 +36,15 @@ class BasicCaseObjectSpec extends SalatSpec {
log.info("after : %s", dbo.asDBObject)
dbo must havePair("a" -> e.a)
- dbo must notHaveKey("aa")
+ dbo must not have key("aa")
dbo must havePair("aaa" -> e.aaa.get)
dbo must havePair("b" -> e.b)
- dbo must notHaveKey("bb")
+ dbo must not have key("bb")
dbo must havePair("bbb" -> e.bbb.get)
dbo must havePair("c" -> e.c)
- dbo must notHaveKey("cc")
+ dbo must not have key("cc")
dbo must havePair("ccc" -> e.ccc.get)
}
@@ -26,12 +26,9 @@ import com.novus.salat.test.model._
import com.mongodb.casbah.Imports._
import com.mongodb.casbah.Implicits._
import java.math.{RoundingMode, MathContext}
-import org.specs.specification.PendingUntilFixed
import scala.math.{BigDecimal => ScalaBigDecimal}
-class BigDecimalPrecisionTest extends SalatSpec with PendingUntilFixed {
-
-
+class BigDecimalPrecisionTest extends SalatSpec {
"Salat grater" should {
"preserve ScalaBigDecimal precision to 16 places" in {
@@ -46,19 +43,19 @@ class BigDecimalPrecisionTest extends SalatSpec with PendingUntilFixed {
val dbo: MongoDBObject = grater[George].asDBObject(g)
dbo must havePair("number" -> PrecisePi)
dbo must havePair("someNumber" -> PrecisePi)
- dbo must notHaveKey("noNumber")
+ dbo must not have key("noNumber")
val coll = MongoConnection()(SalatSpecDb)("scala_math_big_decimal_precision_test")
val wr = coll.insert(dbo)
// println("WR: %s".format(wr))
val g_* = grater[George].asObject(coll.findOne().get)
- g_* mustEqual g
- g_*.number.precision mustEqual 16
- g_*.someNumber.get.precision mustEqual 16
+ g_* must_== g
+ g_*.number.precision must_== 16
+ g_*.someNumber.get.precision must_== 16
- g_*.number mustNotEq MorePrecisePi
- g_*.number mustEqual MorePrecisePi(mc)
+ g_*.number must not be equalTo(MorePrecisePi)
+ g_*.number must_== MorePrecisePi(mc)
}
@@ -74,19 +71,19 @@ class BigDecimalPrecisionTest extends SalatSpec with PendingUntilFixed {
val dbo: MongoDBObject = grater[George2].asDBObject(h)
dbo must havePair("number" -> PrecisePi)
dbo must havePair("someNumber" -> PrecisePi)
- dbo must notHaveKey("noNumber")
+ dbo must not have key("noNumber")
val coll = MongoConnection()(SalatSpecDb)("scala_big_decimal_precision_test")
val wr = coll.insert(dbo)
// println("WR: %s".format(wr))
val h_* = grater[George2].asObject(coll.findOne().get)
- h_* mustEqual h
- h_*.number.precision mustEqual 16
- h_*.someNumber.get.precision mustEqual 16
+ h_* must_== h
+ h_*.number.precision must_== 16
+ h_*.someNumber.get.precision must_== 16
- h_*.number mustNotEq MorePrecisePi
- h_*.number mustEqual MorePrecisePi(mc)
+ h_*.number must not be equalTo(MorePrecisePi)
+ h_*.number must_== MorePrecisePi(mc)
}
}
@@ -106,7 +103,7 @@ class BigDecimalPrecisionTest extends SalatSpec with PendingUntilFixed {
// println("WR: %s".format(wr))
val i_* = grater[Ida].asObject(coll.findOne().get)
- i_* mustEqual i
+ i_* must_== i
}
@@ -122,7 +119,7 @@ class BigDecimalPrecisionTest extends SalatSpec with PendingUntilFixed {
// println("WR: %s".format(wr))
val i_* = grater[Ida].asObject(coll.findOne().get)
- i_* mustEqual i
+ i_* must_== i
}
}
@@ -21,7 +21,6 @@
package com.novus.salat.test
import com.novus.salat._
-import com.novus.salat.util._
import com.novus.salat.global._
import com.novus.salat.test.model._
import com.mongodb.casbah.Imports._
@@ -42,7 +41,7 @@ class BigIntSpec extends SalatSpec {
val l_* = grater[Leo].asObject(coll.findOne().get)
// println(MapPrettyPrinter(l_*))
- l_* mustEqual l
+ l_* must_== l
}
}
}
@@ -35,12 +35,15 @@ class CaseObjectSupport extends SalatSpec {
val dbo: MongoDBObject = grater[Wardrobe].asDBObject(mine)
log.info("dbo : %s", dbo)
val suits = dbo.expand[BasicDBList]("suits")
- suits must beSome[BasicDBList].which {
- suits => val suit: MongoDBObject = suits(0).asInstanceOf[DBObject]
- val th = suit.expand[String]("_typeHint")
- th must beSome[String].which {
- th => th == Zoot.getClass.getName
+ suits must beSome[BasicDBList]
+ suits.getOrElse(throw new Exception("argh, someone stole my wardrobe")) // TODO: where did which go?
+ suits match {
+ case Some(suits) => {
+ val suit: MongoDBObject = suits(0).asInstanceOf[DBObject]
+ val th = suit.expand[String]("_typeHint")
+ th must beSome(Zoot.getClass.getName)
}
+ case None => throw new Exception("where are my suits?") // TODO: where did fail go?
}
}
@@ -21,7 +21,6 @@
package com.novus.salat.test
import com.novus.salat._
-import com.novus.salat.util._
import com.novus.salat.global._
import com.novus.salat.test.model._
import com.mongodb.casbah.Imports._
@@ -42,7 +41,7 @@ class CharacterSpec extends SalatSpec {
// println("WR: %s".format(wr))
val k_* = grater[Kate].asObject(coll.findOne().get)
- k_* mustEqual k
+ k_* must_== k
}
}
@@ -43,7 +43,7 @@ class ContextSpec extends SalatSpec {
}
"by type" in {
- ctx.lookup_![James] mustEqual grater[James]
+ ctx.lookup_![James] must_== grater[James]
}
}
}
@@ -63,7 +63,7 @@ class ContextSpec extends SalatSpec {
}
"by type" in {
- ctx.lookup_![James] mustEqual grater[James]
+ ctx.lookup_![James] must_== grater[James]
}
}
}
@@ -90,7 +90,7 @@ class ContextSpec extends SalatSpec {
}
"by type" in {
- ctx.lookup_![James] mustEqual grater[James]
+ ctx.lookup_![James] must_== grater[James]
}
}
@@ -20,15 +20,13 @@
*/
package com.novus.salat.test
-import org.specs.specification.PendingUntilFixed
import com.novus.salat._
import scala.tools.nsc.util.ScalaClassLoader
import com.mongodb.casbah.Imports._
-import scala.reflect.Manifest
import com.novus.salat.util.MapPrettyPrinter
-import com.novus.salat.test.model.{Ida, James, Alice, Walrus}
+import com.novus.salat.test.model.{Ida, Alice, Walrus}
-class CustomContextSpec extends SalatSpec with PendingUntilFixed {
+class CustomContextSpec extends SalatSpec {
"Salat context" should {
@@ -40,16 +38,17 @@ class CustomContextSpec extends SalatSpec with PendingUntilFixed {
ctx.name must beSome("CustomContextSpec-1")
// this custom context is using the default classloader
ctx.classLoaders must haveSize(1)
- ctx.classLoaders(0) mustEqual ctx.getClass.getClassLoader
+ ctx.classLoaders(0) must_== ctx.getClass.getClassLoader
// members of com.novus.salat.test.model can be resolved as expected
- ctx.classLoaders(0) mustEqual Alice.getClass.getClassLoader
+ ctx.classLoaders(0) must_== Alice.getClass.getClassLoader
getClassNamed(Alice.getClass.getName)(ctx) must beSome(Alice.getClass)
}
"provide flexible classloader handling" in {
- val TestClassName = "com.novus.salat.test.CustomContextSpec$$anonfun$1$$anonfun$apply$10$$anon$2$Ida"
+ // TODO: somewhat contrived but...
+ val TestClassName = "com.novus.salat.test.CustomContextSpec$$anonfun$1$$anonfun$apply$15$$anon$2$Ida"
val customCl = new ScalaClassLoader() {
case class Ida(lake: Int = 10, drowned: Boolean = true)
@@ -76,8 +75,8 @@ class CustomContextSpec extends SalatSpec with PendingUntilFixed {
val custom = ctx.classLoaders(0)
val default = ctx.classLoaders(1)
- custom mustEqual customCl
- default mustEqual ctx.getClass.getClassLoader
+ custom must_== customCl
+ default must_== ctx.getClass.getClassLoader
// we can resolve a class from the default classloader
getClassNamed(Alice.getClass.getName)(ctx) must beSome(Alice.getClass)
@@ -116,23 +115,23 @@ class CustomContextSpec extends SalatSpec with PendingUntilFixed {
ctx.name must beSome(CustomContextName)
ctx.classLoaders must haveSize(1)
- ctx.classLoaders(0) mustEqual customCl
- ctx.classLoaders must notContain(ctx.getClass.getClassLoader)
+ ctx.classLoaders(0) must_== customCl
+ ctx.classLoaders must not contain(ctx.getClass.getClassLoader)
// try to register another classloader and confirm it didn't work, because we overrode the default impl
val customCl2: ClassLoader = new ScalaClassLoader() {
// some impl
}
ctx.registerClassLoader(customCl2)
ctx.classLoaders must haveSize(1)
- ctx.classLoaders(0) mustEqual customCl
- ctx.classLoaders must notContain(customCl2)
- ctx.classLoaders must notContain(ctx.getClass.getClassLoader)
+ ctx.classLoaders(0) must_== customCl
+ ctx.classLoaders must not contain(customCl2)
+ ctx.classLoaders must not contain(ctx.getClass.getClassLoader)
// resolving a class from the default classloader doesn't work
getClassNamed(Alice.getClass.getName)(ctx) must beNone
// resolving a class from our custom classloader does
- getClassNamed(TestClassName)(ctx) must notBeEmpty
+ getClassNamed(TestClassName)(ctx) must not beEmpty
}
"percolate a custom context down the entire chain" in {
@@ -153,7 +152,7 @@ class CustomContextSpec extends SalatSpec with PendingUntilFixed {
val dbo: MongoDBObject = grater[Walrus[String]].asDBObject(w)
dbo.get("manyThings") must beSome[AnyRef]
val w_* = grater[Walrus[String]].asObject(dbo)
- w_* mustEqual w
+ w_* must_== w
// we can resolve a class from the custom classloader
getClassNamed(TestClassName) must beSome(testClassForName)
@@ -181,10 +180,10 @@ class CustomContextSpec extends SalatSpec with PendingUntilFixed {
log.info(MapPrettyPrinter(dbo))
// our global key remap transformed "lake" to "swamp"
dbo must havePair(swamp, 3.14)
- dbo must notHaveKey(lake)
+ dbo must not have key(lake)
val i_* = grater[Ida].asObject(dbo)
- i_* mustEqual i
+ i_* must_== i
}
}
@@ -21,7 +21,6 @@
package com.novus.salat.test
import com.novus.salat._
-import com.novus.salat.util._
import com.novus.salat.global._
import com.novus.salat.test.model._
@@ -43,7 +42,7 @@ class DateTimeSpec extends SalatSpec {
val coll = MongoConnection()(SalatSpecDb)("scala_date_test_1")
val wr = coll.insert(dbo)
val n_* = grater[Neville].asObject(coll.findOne().get)
- n_* mustEqual n
+ n_* must_== n
}
"support org.joda.time.DateTime" in {
@@ -58,15 +57,15 @@ class DateTimeSpec extends SalatSpec {
val coll = MongoConnection()(SalatSpecDb)("scala_date_test_2")
val wr = coll.insert(dbo)
val n_* = grater[Neville].asObject(coll.findOne().get)
- n_* mustEqual n
+ n_* must_== n
}
"support dates parsed from JSON" in {
val n = Neville(asOf = new org.joda.time.DateMidnight().toDateTime)
val json = grater[Neville].asDBObject(n).toString
log.info(json)
val n_* = grater[Neville].asObject(parse(json).asInstanceOf[DBObject])
- n_* mustEqual n
+ n_* must_== n
}
}
Oops, something went wrong.

0 comments on commit 493247f

Please sign in to comment.