Skip to content

specs2 wip #1301

Merged
merged 17 commits into from Aug 27, 2012
Jump to file
+1,079 −900
View
2 build.sbt
@@ -14,7 +14,7 @@ organizationName in ThisBuild := "WorldWide Conferencing, LLC"
crossScalaVersions in ThisBuild := Seq("2.9.2", "2.9.1-1", "2.9.1", "2.9.0-1", "2.9.0")
-libraryDependencies in ThisBuild <++= scalaVersion { sv => Seq(specs, scalacheck).map(_(sv)) }
+libraryDependencies in ThisBuild ++= Seq(specs2, scalacheck)
// Settings for Sonatype compliance
pomIncludeRepository in ThisBuild := { _ => false }
View
8 core/actor/src/test/scala/net/liftweb/actor/ActorSpec.scala
@@ -17,16 +17,18 @@
package net.liftweb
package actor
-import org.specs.Specification
-import org.specs.util.TimeConversions._
+import org.specs2.mutable.Specification
+import org.specs2.time.TimeConversions._
import common._
/**
* Systems under specification for Lift Actor.
*/
-object ActorSpec extends Specification("Actor Specification") {
+class ActorSpec extends Specification {
+ "Actor Specification".title
+ sequential
"A Scala Actor" should {
"support common features" in commonFeatures(new MyScalaActor)
View
53 core/common/src/test/scala/net/liftweb/common/BoxSpec.scala
@@ -17,16 +17,18 @@
package net.liftweb
package common
-import org.specs.{ScalaCheck, Specification}
-import org.scalacheck.{Arbitrary, Gen, Prop}
+import org.specs2.mutable.Specification
+import org.specs2.ScalaCheck
+import org.scalacheck.{Arbitrary, Gen}
import Gen._
-import Prop.forAll
import Box._
/* commented out because it tests the compilation phase and we want the compiler to "do the right thing"
-object TypeBoundsTest extends Specification("Type Bounds Spec") with ScalaCheck {
+object TypeBoundsTest extends Specification with ScalaCheck {
+ "Type Bounds Spec".title
+
"Type bounds" can {
"do type testing" in {
def foo[T: ExcludeThisType.exclude[Nothing]#other](a: T) = a.toString
@@ -43,17 +45,17 @@ object TypeBoundsTest extends Specification("Type Bounds Spec") with ScalaCheck
/**
* System under specification for Box.
*/
-object BoxSpec extends Specification("Box Specification") with ScalaCheck with BoxGenerator {
+class BoxSpec extends Specification with ScalaCheck with BoxGenerator {
"A Box" can {
"be created from a Option. It is Empty if the option is None" in {
- Box(None) mustBe Empty
+ Box(None) must beEmpty
}
"be created from a Option. It is Full(x) if the option is Some(x)" in {
Box(Some(1)) must_== Full(1)
}
"be created from a List containing one element. It is Empty if the list is empty" in {
- Box(Nil) mustBe Empty
+ Box(Nil) must beEmpty
}
"be created from a List containing one element. It is Full(x) if the list is List(x)" in {
Box(List(1)) must_== Full(1)
@@ -96,10 +98,10 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
Full(1).isDefined must beTrue
}
"return its value when opened" in {
- Full(1).open_! mustBe 1
+ Full(1).open_! must_== 1
}
"return its value when opened with openOr(default value)" in {
- Full(1) openOr 0 mustBe 1
+ Full(1) openOr 0 must_== 1
}
"return itself when or'ed with another Box" in {
Full(1) or Full(2) must_== Full(1)
@@ -114,7 +116,7 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
Full(1) filter {_ > 0} must_== Full(1)
}
"define a 'filter' method, returning Empty if the filter is not satisfied" in {
- Full(1) filter {_ == 0} mustBe Empty
+ Full(1) filter {_ == 0} must beEmpty
}
"define a 'filterMsg' method, returning a Failure if the filter predicate is not satisfied" in {
Full(1).filterMsg("not equal to 0")(_ == 0) must_== Failure("not equal to 0", Empty, Empty)
@@ -131,7 +133,7 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
Full(1) flatMap { x: Int => if (x > 0) Full("full") else Empty } must_== Full("full")
}
"define a 'flatMap' method transforming its value in another Box. If the value is transformed in an Empty can, the total result is an Empty can" in {
- Full(0) flatMap { x: Int => if (x > 0) Full("full") else Empty } mustBe Empty
+ Full(0) flatMap { x: Int => if (x > 0) Full("full") else Empty } must beEmpty
}
"define an 'elements' method returning an iterator containing its value" in {
Full(1).elements.next must_== 1
@@ -224,22 +226,22 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
{Empty.open_!; ()} must throwA[NullPointerException]
}
"return a default value if opened with openOr" in {
- Empty.openOr(1) mustBe 1
+ Empty.openOr(1) must_== 1
}
"return the other Box if or'ed with another Box" in {
Empty.or(Full(1)) must_== Full(1)
}
"return itself if filtered with a predicate" in {
val empty: Box[Int] = Empty
- empty.filter {_ > 0} mustBe Empty
+ empty.filter {_ > 0} must beEmpty
}
"define an 'exists' method returning false" in {
val empty: Box[Int] = Empty
empty exists {_ > 0} must beFalse
}
"define a 'filter' method, returning Empty" in {
val empty: Box[Int] = Empty
- empty filter {_ > 0} mustBe Empty
+ empty filter {_ > 0} must beEmpty
}
"define a 'filterMsg' method, returning a Failure" in {
Empty.filterMsg("not equal to 0")(_ == 0) must_== Failure("not equal to 0", Empty, Empty)
@@ -251,10 +253,10 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
total must_== 0
}
"define a 'map' method returning Empty" in {
- Empty map {_.toString} mustBe Empty
+ Empty map {_.toString} must beEmpty
}
"define a 'flatMap' method returning Empty" in {
- Empty flatMap {x: Int => Full("full")} mustBe Empty
+ Empty flatMap {x: Int => Full("full")} must beEmpty
}
"define an 'elements' method returning an empty iterator" in {
Empty.elements.hasNext must beFalse
@@ -306,26 +308,25 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
"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) must pass
}
"return false with comparing one Full and another object" in {
- Full(1) must_!= "hello"
+ Full(1) must be_!=("hello")
}
"return false with comparing one Empty and another object" in {
- Empty must_!= "hello"
+ Empty must be_!=("hello")
}
"return false with comparing one Failure and another object" in {
- Failure("", Empty, Empty) must_!= "hello"
+ Failure("", Empty, Empty) must be_!=("hello")
}
}
View
8 core/common/src/test/scala/net/liftweb/common/ConversionsSpec.scala
@@ -17,15 +17,15 @@
package net.liftweb
package common
-import xml._
+import xml.{NodeSeq, Text}
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for Conversions.
*/
-object ConversionsSpec extends Specification("Conversions Specification") {
+class ConversionsSpec extends Specification {
"A StringOrNodeSeq" should {
@@ -36,7 +36,7 @@ object ConversionsSpec extends Specification("Conversions Specification") {
"convert from an Elem" in {
val sns: StringOrNodeSeq = <b/>
- sns.nodeSeq must ==/ ( <b/> )
+ sns.nodeSeq must ==/ (<b/>)
}
"convert from a Seq[Node]" in {
View
12 core/common/src/test/scala/net/liftweb/common/HListSpec.scala
@@ -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
}
}
View
11 core/common/src/test/scala/net/liftweb/common/LoggingSpec.scala
@@ -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 {
View
8 core/common/src/test/scala/net/liftweb/common/LruMapSpec.scala
@@ -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 {
View
5 core/json-ext/src/test/scala/net/liftweb/json/ext/JodaTimeSerializerSpec.scala
@@ -20,7 +20,7 @@ package ext
import org.joda.time._
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import json.Serialization.{read, write => swrite}
@@ -29,7 +29,8 @@ import json.Serialization.{read, write => swrite}
/**
* System under specification for JodaTimeSerializer.
*/
-object JodaTimeSerializerSpec extends Specification("JodaTimeSerializer Specification") {
+object JodaTimeSerializerSpec extends Specification {
+ "JodaTimeSerializer Specification".title
implicit val formats = Serialization.formats(NoTypeHints) ++ JodaTimeSerializers.all
View
5 core/json-ext/src/test/scala/net/liftweb/json/ext/JsonBoxSerializerSpec.scala
@@ -18,7 +18,7 @@ package net.liftweb
package json
package ext
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import json.Serialization.{read, write => swrite}
@@ -27,7 +27,8 @@ import json.Serialization.{read, write => swrite}
/**
* System under specification for JsonBoxSerializer.
*/
-object JsonBoxSerializerSpec extends Specification("JsonBoxSerializer Specification") {
+object JsonBoxSerializerSpec extends Specification {
+ "JsonBoxSerializer Specification".title
implicit val formats = net.liftweb.json.DefaultFormats + new JsonBoxSerializer
View
2 core/json-scalaz/src/test/scala/net/lifweb/json/scalaz/Example.scala
@@ -5,7 +5,7 @@ import Scalaz._
import JsonScalaz._
import net.liftweb.json._
-import org.specs.Specification
+import org.specs2.mutable.Specification
object Example extends Specification {
View
2 core/json-scalaz/src/test/scala/net/lifweb/json/scalaz/LottoExample.scala
@@ -5,7 +5,7 @@ import Scalaz._
import JsonScalaz._
import net.liftweb.json._
-import org.specs.Specification
+import org.specs2.mutable.Specification
object LottoExample extends Specification {
case class Winner(winnerId: Long, numbers: List[Int])
View
2 core/json-scalaz/src/test/scala/net/lifweb/json/scalaz/TupleExample.scala
@@ -5,7 +5,7 @@ import Scalaz._
import JsonScalaz._
import net.liftweb.json._
-import org.specs.Specification
+import org.specs2.mutable.Specification
object TupleExample extends Specification {
"Parse tuple from List" in {
View
8 core/json-scalaz/src/test/scala/net/lifweb/json/scalaz/ValidationExample.scala
@@ -5,7 +5,7 @@ import Scalaz._
import JsonScalaz._
import net.liftweb.json._
-import org.specs.Specification
+import org.specs2.mutable.Specification
object ValidationExample extends Specification {
@@ -30,9 +30,9 @@ object ValidationExample extends Specification {
"pass when age within limits" in {
// Age must be between 16 an 60
-// FIXME enable when 2.8 no longer supported, 2.9 needs: import Validation.Monad._
-// val person = Person.applyJSON(field("name"), validate[Int]("age") >=> min(16) >=> max(60) apply _)
-// person(json) mustEqual Success(Person("joe", 17))
+ import Validation.Monad._
+ val person = Person.applyJSON(field("name"), validate[Int]("age") >=> min(16) >=> max(60) apply _)
+ person(json) mustEqual Success(Person("joe", 17))
}
}
View
6 core/json/src/test/scala/net/liftweb/json/DiffExamples.scala
@@ -17,13 +17,15 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for Diff Examples.
*/
-object DiffExamples extends Specification("Diff Examples") {
+object DiffExamples extends Specification {
+ "Diff Examples".title
+
import MergeExamples.{scala1, scala2, lotto1, lotto2, mergedLottoResult}
"Diff example" in {
View
2 core/json/src/test/scala/net/liftweb/json/Examples.scala
@@ -17,7 +17,7 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
object Examples extends Specification {
View
10 core/json/src/test/scala/net/liftweb/json/ExtractionBugs.scala
@@ -17,13 +17,15 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
+
+object ExtractionBugs extends Specification {
+ "Extraction bugs Specification".title
-object ExtractionBugs extends Specification("Extraction bugs Specification") {
implicit val formats = DefaultFormats
-
+
"ClassCastException (BigInt) regression 2 must pass" in {
- val opt = OptionOfInt(Some(39))
+ val opt = OptionOfInt(Some(39))
Extraction.decompose(opt).extract[OptionOfInt].opt.get mustEqual 39
}
View
6 core/json/src/test/scala/net/liftweb/json/ExtractionExamplesSpec.scala
@@ -18,9 +18,11 @@ package net.liftweb
package json
import java.util.Date
-import org.specs.Specification
+import org.specs2.mutable.Specification
+
+object ExtractionExamples extends Specification {
+ "Extraction Examples Specification".title
-object ExtractionExamples extends Specification("Extraction Examples Specification") {
implicit val formats = DefaultFormats
"Extraction example" in {
View
2 core/json/src/test/scala/net/liftweb/json/FieldSerializerBugs.scala
@@ -17,7 +17,7 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
object FieldSerializerBugs extends Specification {
import Serialization.{read, write => swrite}
View
8 core/json/src/test/scala/net/liftweb/json/FieldSerializerExamples.scala
@@ -17,9 +17,9 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
-object FieldSerializerExamples extends Specification {
+object FieldSerializerExamples extends Specification {
import Serialization.{read, write => swrite}
import FieldSerializer._
@@ -33,7 +33,7 @@ object FieldSerializerExamples extends Specification {
"All fields are serialized by default" in {
implicit val formats = DefaultFormats + FieldSerializer[WildDog]()
val ser = swrite(dog)
- val dog2 = read[WildDog](ser)
+ val dog2 = read[WildDog](ser)
dog2.name mustEqual dog.name
dog2.color mustEqual dog.color
dog2.owner mustEqual dog.owner
@@ -49,7 +49,7 @@ object FieldSerializerExamples extends Specification {
implicit val formats = DefaultFormats + dogSerializer
val ser = swrite(dog)
- val dog2 = read[WildDog](ser)
+ val dog2 = read[WildDog](ser)
dog2.name mustEqual dog.name
dog2.color mustEqual dog.color
dog2.owner must beNull
View
39 core/json/src/test/scala/net/liftweb/json/JsonAstSpec.scala
@@ -17,84 +17,87 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.mutable.Specification
+import org.specs2.ScalaCheck
import org.scalacheck._
import org.scalacheck.Prop.{forAll, forAllNoShrink}
/**
* System under specification for JSON AST.
*/
-object JsonAstSpec extends Specification("JSON AST Specification") with JValueGen with ScalaCheck {
+object JsonAstSpec extends Specification with JValueGen with ScalaCheck {
+ "JSON AST Specification".title
+
"Functor identity" in {
val identityProp = (json: JValue) => json == (json map identity)
- forAll(identityProp) must pass
+ check(forAll(identityProp))
}
"Functor composition" in {
val compositionProp = (json: JValue, fa: JValue => JValue, fb: JValue => JValue) =>
json.map(fb).map(fa) == json.map(fa compose fb)
- forAll(compositionProp) must pass
+ check(forAll(compositionProp))
}
"Monoid identity" in {
val identityProp = (json: JValue) => (json ++ JNothing == json) && (JNothing ++ json == json)
- forAll(identityProp) must pass
+ check(forAll(identityProp))
}
"Monoid associativity" in {
val assocProp = (x: JValue, y: JValue, z: JValue) => x ++ (y ++ z) == (x ++ y) ++ z
- forAll(assocProp) must pass
+ check(forAll(assocProp))
}
"Merge identity" in {
val identityProp = (json: JValue) => (json merge JNothing) == json && (JNothing merge json) == json
- forAll(identityProp) must pass
+ check(forAll(identityProp))
}
"Merge idempotency" in {
val idempotencyProp = (x: JValue) => (x merge x) == x
- forAll(idempotencyProp) must pass
+ check(forAll(idempotencyProp))
}
"Diff identity" in {
val identityProp = (json: JValue) =>
(json diff JNothing) == Diff(JNothing, JNothing, json) &&
(JNothing diff json) == Diff(JNothing, json, JNothing)
- forAll(identityProp) must pass
+ check(forAll(identityProp))
}
"Diff with self is empty" in {
val emptyProp = (x: JValue) => (x diff x) == Diff(JNothing, JNothing, JNothing)
- forAll(emptyProp) must pass
+ check(forAll(emptyProp))
}
"Diff is subset of originals" in {
val subsetProp = (x: JObject, y: JObject) => {
val Diff(c, a, d) = x diff y
y == (y merge (c merge a))
}
- forAll(subsetProp) must pass
+ check(forAll(subsetProp))
}
"Diff result is same when fields are reordered" in {
val reorderProp = (x: JObject) => (x diff reorderFields(x)) == Diff(JNothing, JNothing, JNothing)
- forAll(reorderProp) must pass
+ check(forAll(reorderProp))
}
"Remove all" in {
val removeAllProp = (x: JValue) => (x remove { _ => true }) == JNothing
- forAll(removeAllProp) must pass
+ check(forAll(removeAllProp))
}
"Remove nothing" in {
val removeNothingProp = (x: JValue) => (x remove { _ => false }) == x
- forAll(removeNothingProp) must pass
+ check(forAll(removeNothingProp))
}
- "Remove removes only matching elements (in case of a field, its value is set to JNothing)" in {
+ "Remove removes only matching elements (in case of a field, its value is set to JNothing)" in check {
forAllNoShrink(genJValue, genJValueClass) { (json: JValue, x: Class[_ <: JValue]) => {
val removed = json remove typePredicate(x)
val Diff(c, a, d) = json diff removed
@@ -103,7 +106,7 @@ object JsonAstSpec extends Specification("JSON AST Specification") with JValueGe
case _ => true
}
c == JNothing && a == JNothing && elemsLeft.forall(_.getClass != x)
- }} must pass
+ }}
}
"Replace one" in {
@@ -142,8 +145,8 @@ object JsonAstSpec extends Specification("JSON AST Specification") with JValueGe
// ensure that we test some JObject instances
val fieldReplacement = (x: JObject, replacement: JObject) => anyReplacement(x, replacement)
- forAll(fieldReplacement) must pass
- forAll(anyReplacement) must pass
+ check(forAll(fieldReplacement))
+ check(forAll(anyReplacement))
}
private def reorderFields(json: JValue) = json map {
View
6 core/json/src/test/scala/net/liftweb/json/JsonFormatsSpec.scala
@@ -17,12 +17,14 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for JSON Formats.
*/
-object JsonFormatsSpec extends Specification("JsonFormats Specification") with TypeHintExamples {
+object JsonFormatsSpec extends Specification with TypeHintExamples {
+ "JsonFormats Specification".title
+
implicit val formats = ShortTypeHintExamples.formats + FullTypeHintExamples.formats.typeHints
val hintsForFish = ShortTypeHintExamples.formats.typeHints.hintFor(classOf[Fish])
View
11 core/json/src/test/scala/net/liftweb/json/JsonParserSpec.scala
@@ -17,24 +17,27 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.mutable.Specification
+import org.specs2.ScalaCheck
import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Prop._
/**
* System under specification for JSON Parser.
*/
-object JsonParserSpec extends Specification("JSON Parser Specification") with JValueGen with ScalaCheck {
+object JsonParserSpec extends Specification with JValueGen with ScalaCheck {
+ "JSON Parser Specification".title
+
"Any valid json can be parsed" in {
val parsing = (json: JValue) => { parse(Printer.pretty(render(json))); true }
- forAll(parsing) must pass
+ check(forAll(parsing))
}
"Buffer size does not change parsing result" in {
val bufSize = Gen.choose(2, 64)
val parsing = (x: JValue, s1: Int, s2: Int) => { parseVal(x, s1) == parseVal(x, s2) }
- forAll(genObject, bufSize, bufSize)(parsing) must pass
+ check(forAll(genObject, bufSize, bufSize)(parsing))
}
"Parsing is thread safe" in {
View
9 core/json/src/test/scala/net/liftweb/json/JsonPrintingSpec.scala
@@ -17,20 +17,23 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.mutable.Specification
+import org.specs2.ScalaCheck
import org.scalacheck.Arbitrary
import org.scalacheck.Prop.forAll
/**
* System under specification for JSON Printing.
*/
-object JsonPrintingSpec extends Specification("JSON Printing Specification") with JValueGen with ScalaCheck {
+object JsonPrintingSpec extends Specification with JValueGen with ScalaCheck {
+ "JSON Printing Specification".title
+
import scala.text.Document
"rendering does not change semantics" in {
val rendering = (json: Document) => parse(Printer.pretty(json)) == parse(Printer.compact(json))
- forAll(rendering) must pass
+ check(forAll(rendering))
}
private def parse(json: String) = scala.util.parsing.json.JSON.parse(json)
View
6 core/json/src/test/scala/net/liftweb/json/JsonQueryExamples.scala
@@ -17,13 +17,15 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for JSON Query Examples.
*/
-object JsonQueryExamples extends Specification("JSON Query Examples") {
+object JsonQueryExamples extends Specification {
+ "JSON Query Examples".title
+
"List of IPs" in {
val ips = for { JString(ip) <- json \\ "ip" } yield ip
ips mustEqual List("192.168.1.125", "192.168.1.126", "192.168.1.127", "192.168.2.125", "192.168.2.126")
View
11 core/json/src/test/scala/net/liftweb/json/JsonXmlSpec.scala
@@ -17,26 +17,29 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.mutable.Specification
+import org.specs2.ScalaCheck
import org.scalacheck.Arbitrary
import org.scalacheck.Prop.forAll
/**
* System under specification for JSON XML.
*/
-object JsonXmlSpec extends Specification("JSON XML Specification") with NodeGen with JValueGen with ScalaCheck {
+object JsonXmlSpec extends Specification with NodeGen with JValueGen with ScalaCheck {
+ "JSON XML Specification".title
+
import Xml._
import scala.xml.Node
"Valid XML can be converted to JSON and back (symmetric op)" in {
val conversion = (xml: Node) => { toXml(toJson(xml)).head == xml }
- forAll(conversion) must pass
+ check(forAll(conversion))
}
"JSON can be converted to XML, and back to valid JSON (non symmetric op)" in {
val conversion = (json: JValue) => { parse(compact(render(toJson(toXml(json))))); true }
- forAll(conversion) must pass
+ check(forAll(conversion))
}
implicit def arbXml: Arbitrary[Node] = Arbitrary(genXml)
View
6 core/json/src/test/scala/net/liftweb/json/LottoExample.scala
@@ -17,13 +17,15 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for Lotto Examples.
*/
-object LottoExample extends Specification("Lotto Examples") {
+object LottoExample extends Specification {
+ "Lotto Examples".title
+
import JsonDSL._
implicit val formats = DefaultFormats
View
6 core/json/src/test/scala/net/liftweb/json/MergeExamples.scala
@@ -17,11 +17,13 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
-object MergeExamples extends Specification("Merge Examples") {
+object MergeExamples extends Specification {
+ "Merge Examples".title
+
"Merge example" in {
(scala1 merge scala2) mustEqual expectedMergeResult
}
View
6 core/json/src/test/scala/net/liftweb/json/ParserBugs.scala
@@ -19,7 +19,7 @@ package json
import util.control.Exception._
-import org.specs.Specification
+import org.specs2.mutable.Specification
object ParserBugs extends Specification {
"Unicode ffff is a valid char in string literal" in {
@@ -40,8 +40,8 @@ object ParserBugs extends Specification {
}
"Solo quote mark should fail cleanly (not StringIndexOutOfBoundsException) (1041)" in {
- JsonParser.parse("\"", discardParser) must throwA(new Exception()).like {
- case e: JsonParser.ParseException => e.getMessage.startsWith("unexpected eof")
+ JsonParser.parse("\"", discardParser) must throwA[JsonParser.ParseException].like {
+ case e => e.getMessage must startWith("unexpected eof")
}
}
View
5 core/json/src/test/scala/net/liftweb/json/PullParserExamples.scala
@@ -17,13 +17,14 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for JSON Pull Parser.
*/
-object PullParserExamples extends Specification("JSON Pull Parser Examples") {
+object PullParserExamples extends Specification {
+ "JSON Pull Parser Examples".title
import JsonParser._
"Pull parsing example" in {
View
4 core/json/src/test/scala/net/liftweb/json/SerializationBugs.scala
@@ -17,7 +17,7 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
import java.util.UUID
object SerializationBugs extends Specification {
@@ -100,7 +100,7 @@ object SerializationBugs extends Specification {
case (TypeInfo(SeqClass, parameterizedType), JArray(xs)) =>
val typeInfo = TypeInfo(parameterizedType
.map(_.getActualTypeArguments()(0))
- .getOrElse(fail("No type parameter info for type Seq")).asInstanceOf[Class[_]], None)
+ .getOrElse(failure("No type parameter info for type Seq")).asInstanceOf[Class[_]], None)
xs.map(x => Extraction.extract(x, typeInfo))
}
}
View
8 core/json/src/test/scala/net/liftweb/json/SerializationExamples.scala
@@ -18,7 +18,7 @@ package net.liftweb
package json
import java.util.Date
-import org.specs.Specification
+import org.specs2.mutable.Specification
object SerializationExamples extends Specification {
import Serialization.{read, write => swrite}
@@ -288,10 +288,10 @@ object CustomSerializerExamples extends Specification {
i2.startTime mustEqual i.startTime
i2.endTime mustEqual i.endTime
- val p = Pattern.compile("^Curly")
- val pser = swrite(p)
+ val pat = Pattern.compile("^Curly")
+ val pser = swrite(pat)
pser mustEqual """{"$pattern":"^Curly"}"""
- read[Pattern](pser).pattern mustEqual p.pattern
+ read[Pattern](pser).pattern mustEqual pat.pattern
val d = new Date(0)
val dser = swrite(d)
View
2 core/json/src/test/scala/net/liftweb/json/XmlBugs.scala
@@ -17,7 +17,7 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
object XmlBugs extends Specification {
View
5 core/json/src/test/scala/net/liftweb/json/XmlExamples.scala
@@ -17,13 +17,14 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for Xml Examples.
*/
-object XmlExamples extends Specification("XML Examples") {
+object XmlExamples extends Specification {
+ "XML Examples".title
import JsonDSL._
import Xml._
import scala.xml.{Group, Text}
View
15 core/util/src/main/scala/net/liftweb/util/Props.scala
@@ -116,11 +116,16 @@ object Props extends Logger {
case Full("profile") => Profile
case Full("development") => Development
case _ => {
- val exp = new Exception
- exp.fillInStackTrace
- if (exp.getStackTrace.find(st => st.getClassName.indexOf("SurefireBooter") >= 0).isDefined) Test
- else if (exp.getStackTrace.find(st => st.getClassName.indexOf("sbt.TestRunner") >= 0).isDefined) Test
- else Development
+ val st = Thread.currentThread.getStackTrace
+ val names = List(
+ "org.apache.maven.surefire.booter.SurefireBooter",
+ "sbt.TestRunner",
+ "org.specs2.runner.TestInterfaceRunner" // sometimes specs2 runs tests on another thread
+ )
+ if(st.exists(e => names.exists(e.getClassName.startsWith)))
+ Test
+ else
+ Development
}
}
}
View
125 core/util/src/test/scala/net/liftweb/util/BasicTypesHelpersSpec.scala
@@ -19,8 +19,8 @@ package util
import java.io.ByteArrayInputStream
-import org.specs.Specification
-import org.specs.util.DataTables
+import org.specs2.mutable.Specification
+import org.specs2.matcher.DataTables
import common._
import BasicTypesHelpers._
@@ -29,7 +29,8 @@ import BasicTypesHelpers._
/**
* Systems under specification for BasicTypesHelpers.
*/
-object BasicTypesHelpersSpec extends Specification("BasicTypesHelpers Specification") with DataTables {
+object BasicTypesHelpersSpec extends Specification with DataTables {
+ "BasicTypesHelpers Specification".title
"Basic types helpers" should {
@@ -48,92 +49,92 @@ object BasicTypesHelpersSpec extends Specification("BasicTypesHelpers Specificat
}
val failure = Failure(null, null, null)
"have a toBoolean method converting any object to a reasonable Boolean value" in {
- "object value" | "boolean value" |>
- (0: Any) ! false |
- 1 ! true |
- (null:Any) ! false |
- true ! true |
- false ! false |
- "" ! false |
- "string" ! false |
- "t" ! true |
- "total" ! true |
- "T" ! true |
- "This" ! true |
- "0" ! false |
- None ! false |
- Some("t") ! true |
- Empty ! false |
- Full("t") ! true |
- failure ! false |
- List("t", "f") ! true | {
+ toBoolean(null) must_== false
+ "object value" ||"boolean value" |
+ (0: Any) !!false |
+ 1 !!true |
+ true !!true |
+ false !!false |
+ "" !!false |
+ "string" !!false |
+ "t" !!true |
+ "total" !!true |
+ "T" !!true |
+ "This" !!true |
+ "0" !!false |
+ None !!false |
+ Some("t") !!true |
+ Empty !!false |
+ Full("t") !!true |
+ failure !!false |
+ List("t", "f") !!true |> {
(o: Any, result: Boolean) => toBoolean(o) must_== result
}
}
"have a AsBoolean extractor converting any object to a reasonable Boolean value" in {
- "object value" | "boolean value" |>
- "t" ! Some(true) |
- "" ! None |
- "string" ! None |
- "total" ! None |
- "T" ! Some(true) |
- "This" ! None |
- "0" ! Some(false) | {
+ "object value" ||"boolean value" |>
+ "t" !!Some(true) |
+ "" !!None |
+ "string" !!None |
+ "total" !!None |
+ "T" !!Some(true) |
+ "This" !!None |
+ "0" !!Some(false) | {
(o: String, result: Option[Boolean]) => AsBoolean.unapply(o) must_== result
}
}
"have an AsInt extractor converting any String to a reasonable Int value" in {
- "object value" | "int value" |>
- "3" ! Some(3) |
- "n" ! None | {
+ "object value" ||"int value" |>
+ "3" !!Some(3) |
+ "n" !!None | {
(o: String, result: Option[Int]) => AsInt.unapply(o) must_== result
}
}
"have an AsLong extractor converting any String to a reasonable Long value" in {
- "object value" | "long value" |>
- "3" ! Some(3L) |
- "n" ! None | {
+ "object value" ||"long value" |>
+ "3" !!Some(3L) |
+ "n" !!None | {
(o: String, result: Option[Long]) => AsLong.unapply(o) must_== result
}
}
"have a toInt method converting any object to a reasonable Int value" in {
def date(t: Int) = new _root_.java.util.Date(t)
- "object value" | "int value" |>
- (null: Any) ! 0 |
- 1 ! 1 |
- 1L ! 1 |
- List(1, 2) ! 1 |
- Some(1) ! 1 |
- Full(1) ! 1 |
- None ! 0 |
- Empty ! 0 |
- failure ! 0 |
- "3" ! 3 |
- "n" ! 0 |
- date(3000) ! 3 | {
+ toInt(null) must_== 0
+ "object value" ||"int value" |>
+ 1 !!1 |
+ 1L !!1 |
+ List(1, 2) !!1 |
+ Some(1) !!1 |
+ Full(1) !!1 |
+ None !!0 |
+ Empty !!0 |
+ failure !!0 |
+ "3" !!3 |
+ "n" !!0 |
+ date(3000) !!3 | {
(o: Any, result: Int) => toInt(o) must_== result
}
}
"have a toLong method converting any object to a reasonable Long value" in {
def date(t: Int) = new _root_.java.util.Date(t)
- "object value" | "long value" |>
- (null: Any) ! 0L |
- 1 ! 1L |
- 1L ! 1L |
- List(1, 2) ! 1L |
- Some(1) ! 1L |
- Full(1) ! 1L |
- None ! 0L |
- Empty ! 0L |
- failure ! 0L |
- "3" ! 3L |
- "n" ! 0L |
- date(3000) ! 3000L | {
+ toLong(null) must_== 0L
+ "object value" ||"long value" |>
+ 1 !!1L |
+ 1L !!1L |
+ List(1, 2) !!1L |
+ Some(1) !!1L |
+ Full(1) !!1L |
+ None !!0L |
+ Empty !!0L |
+ failure !!0L |
+ "3" !!3L |
+ "n" !!0L |
+ date(3000) !!3000L | {
(o: Any, result: Long) => toLong(o) must_== result
}
}
View
20 core/util/src/test/scala/net/liftweb/util/BindHelpersSpec.scala
@@ -19,7 +19,7 @@ package util
import xml._
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import BindHelpers._
@@ -28,7 +28,8 @@ import BindHelpers._
/**
* Systems under specification for BindHelpers.
*/
-object BindHelpersSpec extends Specification("BindHelpers Specification") {
+object BindHelpersSpec extends Specification {
+ "BindHelpers Specification".title
"the mixinAttributes function" should {
"mixin in all the attributes" in {
@@ -403,6 +404,7 @@ object CssBindHelpersSpec extends Specification {
val xf = "* [id]" #> "xx" &
"* [style]" #> "border:thin solid black" &
"* *" #> <a/>
+ success
}
"not stack overflow on Elem" in {
@@ -411,6 +413,7 @@ object CssBindHelpersSpec extends Specification {
"* *+" #> <a/>
xf(<div/>)
+ success
}
"not stack overflow on Elem" in {
@@ -419,6 +422,7 @@ object CssBindHelpersSpec extends Specification {
"* -*" #> <a/>
xf(<div/>)
+ success
}
"support modifying attributes along with body" in {
@@ -525,7 +529,8 @@ object CssBindHelpersSpec extends Specification {
"substitute multiple Strings by id" in {
("#foo" #> "hello" &
- "#baz" #> "bye")(<b><div id="baz">Hello</div><span id="foo"/></b>) must ==/ (<b>{Text("bye")}{Text("hello")}</b>)
+ "#baz" #> "bye"
+ )(<b><div id="baz">Hello</div><span id="foo"/></b>) must be_== (NodeSeq fromSeq <b>{Text("bye")}{Text("hello")}</b>)
}
"bind href and None content" in {
@@ -654,17 +659,20 @@ object CssBindHelpersSpec extends Specification {
"substitute multiple Strings by id" in {
(("#foo" replaceWith "hello") &
- ("#baz" replaceWith "bye"))(<b><div id="baz">Hello</div><span id="foo"/></b>) must ==/ (<b>{Text("bye")}{Text("hello")}</b>)
+ ("#baz" replaceWith "bye")
+ )(
+ <b><div id="baz">Hello</div><span id="foo"/></b>
+ ) must_== (NodeSeq fromSeq <b>{Text("bye")}{Text("hello")}</b>)
}
"substitute multiple Strings with a List by id" in {
("#foo" #> "hello" &
- "#baz" #> List("bye", "bye"))(<b><div id="baz">Hello</div><span id="foo"/></b>) must ==/ (<b>{Text("bye")}{Text("bye")}{Text("hello")}</b>)
+ "#baz" #> List("bye", "bye"))(<b><div id="baz">Hello</div><span id="foo"/></b>) must_== (NodeSeq fromSeq <b>{Text("bye")}{Text("bye")}{Text("hello")}</b>)
}
"substitute multiple Strings with a List by id" in {
(("#foo" replaceWith "hello") &
- ("#baz" replaceWith List("bye", "bye")))(<b><div id="baz">Hello</div><span id="foo"/></b>) must ==/ (<b>{Text("bye")}{Text("bye")}{Text("hello")}</b>)
+ ("#baz" replaceWith List("bye", "bye")))(<b><div id="baz">Hello</div><span id="foo"/></b>) must_== (NodeSeq fromSeq <b>{Text("bye")}{Text("bye")}{Text("hello")}</b>)
}
View
5 core/util/src/test/scala/net/liftweb/util/BundleBuilderSpec.scala
@@ -21,13 +21,14 @@ import java.util.Locale
import xml.NodeSeq
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* Systems under specification for BundleBuilder.
*/
-object BundleBuilderSpec extends Specification("BundleBuilder Specification") {
+object BundleBuilderSpec extends Specification {
+ "BundleBuilder Specification".title
"BundleBuilder" should {
"Build a Bundle" in {
View
15 core/util/src/test/scala/net/liftweb/util/ClassHelpersSpec.scala
@@ -17,7 +17,7 @@
package net.liftweb
package util
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import ClassHelpers._
@@ -26,7 +26,8 @@ import ClassHelpers._
/**
* Systems under specification for ClassHelpers.
*/
-object ClassHelpersSpec extends Specification("ClassHelpers Specification") {
+object ClassHelpersSpec extends Specification {
+ "ClassHelpers Specification".title
"The findType function" should {
"return a Full can with the found class when given the type, the name, and a list of packages to conform to" in {
@@ -125,16 +126,16 @@ object ClassHelpersSpec extends Specification("ClassHelpers Specification") {
"The invokeMethod function" should {
"return a Failure if the class is null" in {
- invokeMethod(null, "", "length") must beLike { case Failure(_, _, _) => true }
+ invokeMethod(null, "", "length") must beLike { case Failure(_, _, _) => 1 must_== 1 }
}
"return a Failure if the instance is null" in {
- invokeMethod(classOf[String], null, "length") must beLike { case Failure(_, _, _) => true }
+ invokeMethod(classOf[String], null, "length") must beLike { case Failure(_, _, _) => 1 must_== 1 }
}
"return a Failure if the method name is null" in {
- invokeMethod(classOf[String], "", null) must beLike { case Failure(_, _, _) => true }
+ invokeMethod(classOf[String], "", null) must beLike { case Failure(_, _, _) => 1 must_== 1 }
}
"return a Failure if the method doesnt exist on the class" in {
- invokeMethod(classOf[String], "", "isNotEmpty") must beLike { case Failure(_, _, _) => true }
+ invokeMethod(classOf[String], "", "isNotEmpty") must beLike { case Failure(_, _, _) => 1 must_== 1 }
}
"return a Full can with the result if the method exist on the class" in {
invokeMethod(classOf[String], "", "length") must_== Full(0)
@@ -164,7 +165,7 @@ object ClassHelpersSpec extends Specification("ClassHelpers Specification") {
instantiate(classOf[String]) must_== Full("")
}
"return a failure if a class can not be instantiated with a new instance" in {
- instantiate(classOf[java.util.Calendar]) must beLike { case Failure(_, _, _) => true }
+ instantiate(classOf[java.util.Calendar]) must beLike { case Failure(_, _, _) => 1 must_== 1 }
}
}
View
45 core/util/src/test/scala/net/liftweb/util/CombParserHelpersSpec.scala
@@ -19,13 +19,15 @@ package util
import scala.util.parsing.combinator.Parsers
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.mutable.Specification
+import org.specs2.ScalaCheck
import org.scalacheck.{Arbitrary, Gen, Prop}
import Gen._
import Prop._
-object CombParserHelpersSpec extends Specification("CombParserHelpers Specification") with ScalaCheck {
+object CombParserHelpersSpec extends Specification with ScalaCheck {
+ "CombParserHelpers Specification".title
object ParserHelpers extends CombParserHelpers with Parsers
import ParserHelpers._
@@ -49,17 +51,16 @@ object CombParserHelpersSpec extends Specification("CombParserHelpers Specificat
}
"provide a whitespace parser: white. Alias: wsc" in {
import WhiteStringGen._
- val whiteParse = (s: String) => wsc(s) must beLike {case Success(_, _) => true}
- forAll(whiteParse) must pass
+ val whiteParse = (s: String) => wsc(s).isInstanceOf[Success[_]]
+ check(forAll(whiteParse))
}
"provide a whiteSpace parser always succeeding and discarding its result" in {
import StringWithWhiteGen._
val whiteSpaceParse =
(s: String) => whiteSpace(s) must beLike {
- case Success(x, y) => x.toString == "()"
- case _ => false
+ case Success(x, y) => x.toString must_== "()"
}
- forAll(whiteSpaceParse) must pass
+ check(forAll(whiteSpaceParse))
}
"provide an acceptCI parser to parse whatever string matching another string ignoring case" in {
import AbcdStringGen._
@@ -68,38 +69,38 @@ object CombParserHelpersSpec extends Specification("CombParserHelpers Specificat
case Success(x, y) => s2.toUpperCase must startWith(s.toUpperCase)
case _ => true
}
- forAll(ignoreCaseStringParse) must pass
+ check(forAll(ignoreCaseStringParse))
}
"provide a digit parser - returning a String" in {
val isDigit: String => Boolean =
(s: String) => digit(s) match {
- case Success(x, y) => s mustMatch ("\\p{Nd}")
+ case Success(x, y) => s must beMatching ("\\p{Nd}.*")
case _ => true
}
- forAll(isDigit) must pass
+ check(forAll(isDigit))
}
"provide an aNumber parser - returning an Int if succeeding" in {
val number: String => Boolean =
(s: String) => {
aNumber(s) match {
- case Success(x, y) => s mustMatch ("\\p{Nd}+")
+ case Success(x, y) => s must beMatching ("\\p{Nd}+.*")
case _ => true
}
}
- forAll(number) must pass
+ check(forAll(number))
}
"provide a slash parser" in {
slash("/").get must_== '/'
- slash("x") must beLike {case Failure(_, _) => true}
+ slash("x") must beLike {case Failure(_, _) => 1 must_== 1}
}
"provide a colon parser" in {
colon(":").get must_== ':'
- colon("x") must beLike {case Failure(_, _) => true}
+ colon("x") must beLike {case Failure(_, _) => 1 must_== 1}
}
"provide a EOL parser which parses the any and discards any end of line character" in {
- List("\n", "\r") foreach {
+ List("\n", "\r") map {
s =>
val result = EOL(s)
result.get.toString must_== "()"
@@ -117,17 +118,25 @@ object CombParserHelpersSpec extends Specification("CombParserHelpers Specificat
"provide a permute parser succeeding if any permutation of given parsers succeeds" in {
def permuteParsers(s: String) = shouldSucceed(permute(parserA, parserB, parserC, parserD)(s))
val permutationOk = (s: String) => permuteParsers(s)
- AbcdStringGen.abcdString must pass(permutationOk)
+ check(forAll(AbcdStringGen.abcdString)(permutationOk))
}
"provide a permuteAll parser succeeding if any permutation of the list given parsers, or a sublist of the given parsers succeeds" in {
def permuteAllParsers(s: String) = shouldSucceed(permuteAll(parserA, parserB, parserC, parserD)(s))
implicit def pick3Letters = AbcdStringGen.pickN(3, List("a", "b", "c"))
- forAll((s: String) => (!(new scala.collection.immutable.StringOps(s)).isEmpty) ==> permuteAllParsers(s)) must pass
+ check {
+ forAll { (s: String) =>
+ (!(new scala.collection.immutable.StringOps(s)).isEmpty) ==> permuteAllParsers(s)
+ }
+ }
}
"provide a repNN parser succeeding if an input can be parsed n times with a parser" in {
def repNNParser(s: String) = shouldSucceed(repNN(3, parserA)(s))
implicit def pick3Letters = AbcdStringGen.pickN(3, List("a", "a", "a"))
- forAll((s: String) => (!(new scala.collection.immutable.StringOps(s)).isEmpty) ==> repNNParser(s)) must pass
+ check {
+ forAll { (s: String) =>
+ (!(new scala.collection.immutable.StringOps(s)).isEmpty) ==> repNNParser(s)
+ }
+ }
}
}
}
View
15 core/util/src/test/scala/net/liftweb/util/ControlHelpersSpec.scala
@@ -17,7 +17,7 @@
package net.liftweb
package util
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import ControlHelpers._
@@ -26,7 +26,8 @@ import ControlHelpers._
/**
* Systems under specification for ControlHelpers.
*/
-object ControlHelpersSpec extends Specification("ControlHelpers Specification") {
+object ControlHelpersSpec extends Specification {
+ "ControlHelpers Specification".title
"the tryo function" should {
"return a Full can if the tested block doesn't throw an exception" in {
@@ -47,18 +48,24 @@ object ControlHelpersSpec extends Specification("ControlHelpers Specification")
"trigger a callback function with the exception if the tested block throws an exception" in {
val callback = (e: Throwable) => { e must_== exception; () }
tryo(callback) { failureBlock }
+ success