Permalink
Browse files

update core/common tests to use specs2

  • Loading branch information...
indrajitr committed Mar 9, 2011
1 parent 51e851d commit d45eaccd7b25a025a754f3f9408cd47ed865c4db
@@ -17,11 +17,10 @@
package net.liftweb
package common
-import org.specs2.mutable._
+import org.specs2.mutable.Specification
import org.specs2.ScalaCheck
-import org.scalacheck.{Arbitrary, Gen, Prop}
+import org.scalacheck.{Arbitrary, Gen}
import Gen._
-import Prop.forAll
import Box._
@@ -292,26 +291,25 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator {
"A Box equals method" should {
- "return true with comparing two identical Box messages" in {
- val equality = (c1: Box[Int], c2: Box[Int]) => (c1, c2) match {
- case (Empty, Empty) => c1 == c2
- case (Full(x), Full(y)) => (c1 == c2) == (x == y)
- case (Failure(m1, e1, l1), Failure(m2, e2, l2)) => (c1 == c2) == ((m1, e1, l1) == (m2, e2, l2))
- case _ => c1 != c2
+ "return true with comparing two identical Box messages" in check {
+ (c1: Box[Int], c2: Box[Int]) => (c1, c2) match {
+ case (Empty, Empty) => c1 must_== c2
+ case (Full(x), Full(y)) => (c1 == c2) must_== (x == y)
+ case (Failure(m1, e1, l1), Failure(m2, e2, l2)) => (c1 == c2) must_== ((m1, e1, l1) == (m2, e2, l2))
+ case _ => c1 must be_!=(c2)
}
- forAll(equality)
}
"return false with comparing one Full and another object" in {
- Full(1) must not be "hello"
+ Full(1) must be_!=("hello")
}
"return false with comparing one Empty and another object" in {
- Empty must not be "hello"
+ Empty must be_!=("hello")
}
"return false with comparing one Failure and another object" in {
- Failure("", Empty, Empty) must not be "hello"
+ Failure("", Empty, Empty) must be_!=("hello")
}
}
@@ -17,7 +17,7 @@
package net.liftweb
package common
-import xml._
+import xml.{NodeSeq, Text}
import org.specs2.mutable.Specification
@@ -36,7 +36,7 @@ class ConversionsSpec extends Specification {
"convert from an Elem" in {
val sns: StringOrNodeSeq = <b/>
- sns.nodeSeq must ==/ ( <b/> )
+ sns.nodeSeq must ==/ (<b/>)
}
"convert from a Seq[Node]" in {
@@ -17,13 +17,13 @@
package net.liftweb
package common
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for Heterogeneous List.
*/
-object HListSpec extends Specification("HList Specification") {
+object HListSpec extends Specification {
"An HList" should {
@@ -49,8 +49,8 @@ object HListSpec extends Specification("HList Specification") {
// result in a failure
x match {
- case Left(_) => true must_== true
- case _ => fail("Full elements available")
+ case Left(_) => success
+ case _ => failure
}
}
@@ -69,9 +69,9 @@ object HListSpec extends Specification("HList Specification") {
val onei: Int = one
val lstl: List[Int] = lst
- true must_== true
+ success
}
- case Left(_) => fail("Failure elements available")
+ case Left(_) => failure
}
}
@@ -17,15 +17,15 @@
package net.liftweb
package common
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for Logging.
*
* Tests rely on logback being in the classpath, so no configuration should be necessary.
*/
-object LoggingSpec extends Specification("Logging Specification") {
+object LoggingSpec extends Specification {
"Logging" can {
"be mixed directly into object" in {
object MyObj extends Logger {
@@ -52,7 +52,7 @@ object LoggingSpec extends Specification("Logging Specification") {
val logger = Logger("MyLogger")
logger.info("Logged with my named logger")
- 1 must_== 1
+ success
}
"log static MDC values" in {
@@ -69,7 +69,7 @@ object LoggingSpec extends Specification("Logging Specification") {
logger.info("Logged with mdc2=yy")
MDC.clear()
logger.info("Logged with no MDC")
- 1 must_== 1
+ success
}
"save MDC context with logWith" in {
@@ -88,7 +88,7 @@ object LoggingSpec extends Specification("Logging Specification") {
logger.info("Logged with mdc1=(1,2), mdc2=yy")
MDC.clear
logger.info("No MDC values")
- 1 must_== 1
+ success
}
"trace function results" in {
object MyObj extends Logger {
@@ -98,6 +98,7 @@ object LoggingSpec extends Specification("Logging Specification") {
val x = 1
}
MyObj.x
+ success
}
"be used in different levels and yield different loggers" in {
@@ -17,13 +17,13 @@
package net.liftweb
package common
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* Systems under specification for LRU Map.
*/
-object LruMapSpec extends Specification("LRU Map Specification") {
+object LruMapSpec extends Specification {
"An LRU Map" should {
@@ -39,7 +39,7 @@ object LruMapSpec extends Specification("LRU Map Specification") {
for (i <- 1 to 20) lru(i) = i
lru.size must_== 10
- for (i <- 11 to 20) lru(i) must_== i
+ ((i:Int) => lru(i) must_== i).forall(11 to 20)
}
"expire elements to func" in {
@@ -49,7 +49,7 @@ object LruMapSpec extends Specification("LRU Map Specification") {
lru.size must_== 10
expCnt must_== 10
- for (i <- 11 to 20) lru(i) must_== i
+ ((i:Int) => lru(i) must_== i).forall(11 to 20)
}
"not expire the recently accessed elements" in {
@@ -90,7 +90,7 @@ class LiftFrameworkProject(info: ProjectInfo) extends ParentProject(info) with L
class FrameworkProject(info: ProjectInfo, libs: ModuleID*) extends DefaultProject(info) with LiftDefaultProject {
// override def libraryDependencies = super.libraryDependencies ++ libs
- override def libraryDependencies = super.libraryDependencies ++ libs ++ Seq("org.specs2" %% "specs2" % "1.0.1" % "test")
+ override def libraryDependencies = super.libraryDependencies ++ libs ++ Seq("org.specs2" %% "specs2" % "1.1-SNAPSHOT" % "test")
def specs2Framework = new TestFramework("org.specs2.runner.SpecsFramework")

0 comments on commit d45eacc

Please sign in to comment.