Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'eto-wip-specs2-from-forked-repo' into eto_issue_941

Conflicts:
	persistence/ldap/src/test/scala/net/liftweb/ldap/LdapSpec.scala
	persistence/mapper/src/test/scala/net/liftweb/mapper/MappedLongForeignKeySpec.scala
	persistence/mapper/src/test/scala/net/liftweb/mapper/MapperSpec.scala
	persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoFieldSpec.scala
	persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoRecordSpec.scala
  • Loading branch information...
commit 9ca2c362e13a08859ff15792a320ebf4694a62ff 2 parents 4f4b10a + 7ab295c
@etorreborre etorreborre authored
Showing with 2,583 additions and 2,400 deletions.
  1. +12 −8 core/actor/src/test/scala/net/liftweb/actor/ActorSpec.scala
  2. +19 −127 core/common/src/test/scala/net/liftweb/common/BoxSpec.scala
  3. +6 −32 core/common/src/test/scala/net/liftweb/common/ConversionsSpec.scala
  4. +11 −24 core/common/src/test/scala/net/liftweb/common/HListSpec.scala
  5. +17 −21 core/common/src/test/scala/net/liftweb/common/LoggingSpec.scala
  6. +12 −18 core/common/src/test/scala/net/liftweb/common/LruMapSpec.scala
  7. +7 −6 core/json-ext/src/test/scala/net/liftweb/json/ext/JodaTimeSerializerSpec.scala
  8. +11 −10 core/json-ext/src/test/scala/net/liftweb/json/ext/JsonBoxSerializerSpec.scala
  9. +9 −9 core/json/src/test/scala/net/liftweb/json/DiffExamples.scala
  10. +30 −30 core/json/src/test/scala/net/liftweb/json/Examples.scala
  11. +7 −5 core/json/src/test/scala/net/liftweb/json/ExtractionBugs.scala
  12. +47 −45 core/json/src/test/scala/net/liftweb/json/ExtractionExamplesSpec.scala
  13. +35 −51 core/json/src/test/scala/net/liftweb/json/JsonAstSpec.scala
  14. +10 −8 core/json/src/test/scala/net/liftweb/json/JsonFormatsSpec.scala
  15. +21 −14 core/json/src/test/scala/net/liftweb/json/JsonParserSpec.scala
  16. +7 −5 core/json/src/test/scala/net/liftweb/json/JsonPrintingSpec.scala
  17. +10 −8 core/json/src/test/scala/net/liftweb/json/JsonQueryExamples.scala
  18. +11 −9 core/json/src/test/scala/net/liftweb/json/JsonXmlSpec.scala
  19. +7 −6 core/json/src/test/scala/net/liftweb/json/LottoExample.scala
  20. +6 −4 core/json/src/test/scala/net/liftweb/json/MergeExamples.scala
  21. +4 −4 core/json/src/test/scala/net/liftweb/json/ParserBugs.scala
  22. +5 −3 core/json/src/test/scala/net/liftweb/json/PullParserExamples.scala
  23. +16 −16 core/json/src/test/scala/net/liftweb/json/SerializationBugs.scala
  24. +37 −37 core/json/src/test/scala/net/liftweb/json/SerializationExamples.scala
  25. +6 −6 core/json/src/test/scala/net/liftweb/json/XmlBugs.scala
  26. +14 −12 core/json/src/test/scala/net/liftweb/json/XmlExamples.scala
  27. +55 −59 core/util/src/test/scala/net/liftweb/util/BasicTypesHelpersSpec.scala
  28. +5 −501 core/util/src/test/scala/net/liftweb/util/BindHelpersSpec.scala
  29. +4 −3 core/util/src/test/scala/net/liftweb/util/BundleBuilderSpec.scala
  30. +17 −16 core/util/src/test/scala/net/liftweb/util/ClassHelpersSpec.scala
  31. +46 −70 core/util/src/test/scala/net/liftweb/util/CombParserHelpersSpec.scala
  32. +22 −16 core/util/src/test/scala/net/liftweb/util/ControlHelpersSpec.scala
  33. +519 −0 core/util/src/test/scala/net/liftweb/util/CssBindHelpersSpec.scala
  34. +3 −2 core/util/src/test/scala/net/liftweb/util/CssSelectorSpec.scala
  35. +16 −15 core/util/src/test/scala/net/liftweb/util/CurrencyZoneSpec.scala
  36. +9 −8 core/util/src/test/scala/net/liftweb/util/EnumWithDescriptionSpec.scala
  37. +0 −26 core/util/src/test/scala/net/liftweb/util/HelpersSpec.scala
  38. +8 −13 core/util/src/test/scala/net/liftweb/util/Html5ParserSpec.scala
  39. +3 −3 core/util/src/test/scala/net/liftweb/util/HttpHelpersSpec.scala
  40. +8 −8 core/util/src/test/scala/net/liftweb/util/JsonCommandSpec.scala
  41. +15 −15 core/util/src/test/scala/net/liftweb/util/JsonParserSpec.scala
  42. +3 −2 core/util/src/test/scala/net/liftweb/util/ListHelpersSpec.scala
  43. +47 −76 core/util/src/test/scala/net/liftweb/util/MailerSpec.scala
  44. +3 −2 core/util/src/test/scala/net/liftweb/util/PCDataXmlParserSpec.scala
  45. +13 −13 core/util/src/test/scala/net/liftweb/util/ScheduleSpec.scala
  46. +3 −2 core/util/src/test/scala/net/liftweb/util/SecurityHelpersSpec.scala
  47. +26 −22 core/util/src/test/scala/net/liftweb/util/StringHelpersSpec.scala
  48. +32 −26 core/util/src/test/scala/net/liftweb/util/TimeHelpersSpec.scala
  49. +21 −22 core/util/src/test/scala/net/liftweb/util/ToHeadSpec.scala
  50. +4 −3 core/util/src/test/scala/net/liftweb/util/VCardParserSpec.scala
  51. +3 −2 core/util/src/test/scala/net/liftweb/util/XmlParserSpec.scala
  52. +7 −10 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchDatabaseSpec.scala
  53. +11 −10 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchDocumentSpec.scala
  54. +6 −4 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchQuerySpec.scala
  55. +30 −28 persistence/couchdb/src/test/scala/net/liftweb/couchdb/CouchRecordSpec.scala
  56. +16 −13 persistence/couchdb/src/test/scala/net/liftweb/couchdb/JsonRecordSpec.scala
  57. +8 −7 persistence/ldap/src/test/scala/net/liftweb/ldap/LdapSpec.scala
  58. +7 −3 persistence/mapper/src/test/scala/net/liftweb/mapper/DbSpec.scala
  59. +5 −3 persistence/mapper/src/test/scala/net/liftweb/mapper/ItemsListSpec.scala
  60. +5 −3 persistence/mapper/src/test/scala/net/liftweb/mapper/ManyToManySpecs.scala
  61. +6 −4 persistence/mapper/src/test/scala/net/liftweb/mapper/MappedDateSpec.scala
  62. +15 −13 persistence/mapper/src/test/scala/net/liftweb/mapper/MappedLongForeignKeySpec.scala
  63. +421 −71 persistence/mapper/src/test/scala/net/liftweb/mapper/MapperSpec.scala
  64. +47 −47 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/CustomSerializersSpec.scala
  65. +23 −26 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoFieldSpec.scala
  66. +11 −13 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoRecordExamplesSpec.scala
  67. +55 −60 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoRecordSpec.scala
  68. +34 −42 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoTestKit.scala
  69. +22 −26 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/field/EnumFieldSpec.scala
  70. +22 −26 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/field/EnumNameFieldSpec.scala
  71. +11 −12 persistence/mongodb/src/test/scala/net/liftweb/mongodb/CustomSerializersSpec.scala
  72. +210 −172 persistence/mongodb/src/test/scala/net/liftweb/mongodb/MongoDirectSpec.scala
  73. +25 −37 persistence/mongodb/src/test/scala/net/liftweb/mongodb/MongoDocumentExamplesSpec.scala
  74. +5 −30 persistence/mongodb/src/test/scala/net/liftweb/mongodb/MongoDocumentSpec.scala
  75. +8 −14 persistence/mongodb/src/test/scala/net/liftweb/mongodb/MongoSpec.scala
  76. +27 −32 persistence/mongodb/src/test/scala/net/liftweb/mongodb/MongoTestKit.scala
  77. +81 −65 persistence/record/src/test/scala/net/liftweb/record/FieldSpec.scala
  78. +1 −3 persistence/record/src/test/scala/net/liftweb/record/Fixtures.scala
  79. +30 −24 persistence/record/src/test/scala/net/liftweb/record/RecordSpec.scala
  80. +24 −24 persistence/squeryl-record/src/test/scala/net/liftweb/squerylrecord/SquerylRecordSpec.scala
  81. +4 −2 project/build/LiftFrameworkProject.scala
  82. +3 −2 web/testkit/src/test/scala/net/liftweb/http/testing/MockHttpRequestSpec.scala
  83. +9 −12 web/webkit/src/main/scala/net/liftweb/mockweb/WebSpec.scala
  84. +6 −3 web/webkit/src/test/scala/net/liftweb/builtin/snippet/MsgSpec.scala
  85. +5 −3 web/webkit/src/test/scala/net/liftweb/builtin/snippet/MsgsSpec.scala
  86. +6 −4 web/webkit/src/test/scala/net/liftweb/http/BindingsSpec.scala
  87. +3 −2 web/webkit/src/test/scala/net/liftweb/http/FactoryMakerSpec.scala
  88. +6 −3 web/webkit/src/test/scala/net/liftweb/http/ReqSpec.scala
  89. +4 −3 web/webkit/src/test/scala/net/liftweb/http/ResourceServerSpec.scala
  90. +8 −2 web/webkit/src/test/scala/net/liftweb/http/SnippetSpec.scala
  91. +3 −2 web/webkit/src/test/scala/net/liftweb/http/js/JsExpSpec.scala
  92. +3 −2 web/webkit/src/test/scala/net/liftweb/http/js/extcore/ExtCoreArtifactsSpec.scala
  93. +6 −7 web/webkit/src/test/scala/net/liftweb/http/rest/XMLApiSpec.scala
  94. +3 −3 web/webkit/src/test/scala/net/liftweb/mockweb/MockWebSpec.scala
  95. +7 −13 web/webkit/src/test/scala/net/liftweb/mockweb/WebSpecSpec.scala
  96. +12 −11 web/webkit/src/test/scala/net/liftweb/sitemap/MenuDSLSpec.scala
  97. +26 −34 web/webkit/src/test/scala/net/liftweb/webapptest/MemoizeSpec.scala
  98. +4 −6 web/webkit/src/test/scala/net/liftweb/webapptest/OneShot.scala
  99. +25 −19 web/webkit/src/test/scala/net/liftweb/webapptest/ToHeadUsages.scala
  100. +5 −2 web/wizard/src/test/scala/net/liftweb/wizard/WizardSpec.scala
View
20 core/actor/src/test/scala/net/liftweb/actor/ActorSpec.scala
@@ -17,7 +17,7 @@
package net.liftweb
package actor
-import org.specs.Specification
+import org.specs2.mutable._
import common._
@@ -25,8 +25,10 @@ import common._
/**
* Systems under specification for Lift Actor.
*/
-object ActorSpec extends Specification("Actor Specification") {
+object ActorSpec extends Specification {
+ "Actor Specification".title
+
"A Scala Actor" should {
"support common features" in commonFeatures(new MyScalaActor)
}
@@ -35,37 +37,39 @@ object ActorSpec extends Specification("Actor Specification") {
"support common features" in commonFeatures(new MyJavaActor)
}
- private def commonFeatures(actor: LiftActor) = {
+ private def commonFeatures(actor: =>LiftActor) = {
"allow setting and getting of a value" in {
val a = actor
a ! Set(33)
a !? Get()
- (a.!?(50, Get())) must be_==(Full(Answer(33))).eventually
+ (a.!?(50, Get())) must be_===(Full(Answer(33))).eventually
}
"allow setting and getting of a value with subclass of Get()" in {
val a = actor
a ! Set(33)
a ! new FunnyGet()
- (a.!?(50L, new FunnyGet())) must be_==(Full(Answer(33))).eventually
+ (a.!?(50L, new FunnyGet())) must be_===(Full(Answer(33))).eventually
}
"allow adding of a value" in {
val a = actor
a ! Set(33)
- (a !< Add(44)).get(50) must be_==(Full(Answer(77))).eventually
+ val r = (a !< Add(44)).get(50)
+ r must be_===(Full(Answer(77))).eventually
}
"allow subtracting of a value" in {
val a = actor
a ! Set(33)
- (a !< Sub(11)).get(50) must be_==(Full(Answer(22))).eventually
+ val r = (a !< Sub(11)).get(50)
+ r must be_===(Full(Answer(22))).eventually
}
"properly timeout" in {
val a = actor
- (a !< Set(33)).get(50) must be_==(Empty).eventually
+ (a !< Set(33)).get(50) must be_===(Empty).eventually
}
}
View
146 core/common/src/test/scala/net/liftweb/common/BoxSpec.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2007-2011 WorldWide Conferencing, LLC
+ * Copyright 2007-2010 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,28 +17,19 @@
package net.liftweb
package common
-import org.specs.{ScalaCheck, Specification}
-import org.scalacheck.{Arbitrary, Gen, Prop}
-import Gen._
-import Prop.forAll
-
-import Box._
-
-
-/**
- * System under specification for Box.
- */
-object BoxSpec extends Specification("Box Specification") with ScalaCheck with BoxGenerator {
+import org.specs2.mutable._
+import _root_.net.liftweb.common.Box._
+class BoxSpec extends Specification {
"A Box" can {
"be created from a Option. It is Empty if the option is None" in {
- Box(None) mustBe Empty
+ Box(None) must be(Empty)
}
- "be created from a Option. It is Full(x) if the option is Some(x)" in {
+ "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 be(Empty)
}
"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)
@@ -63,7 +54,6 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
Box.legacyNullTest(null) must_== Empty
}
}
-
"A Box" should {
"provide a 'choice' method to either apply a function to the Box value or return another default can" in {
def gotIt = (x: Int) => Full("got it: " + x.toString)
@@ -72,7 +62,6 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
Empty.choice(gotIt)(Full("nothing")) must_== Full("nothing")
}
}
-
"A Full Box" should {
"not beEmpty" in {
Full(1).isEmpty must beFalse
@@ -81,10 +70,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)
@@ -99,7 +88,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 be(Empty)
}
"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)
@@ -116,7 +105,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 be(Empty)
}
"define an 'elements' method returning an iterator containing its value" in {
Full(1).elements.next must_== 1
@@ -155,49 +144,7 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
"define a 'asA' method returning Empty if the value is not the instance of a given type" in {
Full("s").asA[Double] must_== Empty
}
-
- "define a 'asA' method must work with Boolean" in {
- Full(true).asA[Boolean] must_== Full(true)
- Full(3).asA[Boolean] must_== Empty
- }
-
- "define a 'asA' method must work with Character" in {
- Full('a').asA[Char] must_== Full('a')
- Full('a').asA[Boolean] must_== Empty
- }
-
- "define a 'asA' method must work with Byte" in {
- Full(3.toByte).asA[Byte] must_== Full(3.toByte)
- Full(3.toByte).asA[Boolean] must_== Empty
- }
-
- "define a 'asA' method must work with Double" in {
- Full(44d).asA[Double] must_== Full(44D)
- Full(44d).asA[Boolean] must_== Empty
- }
-
- "define a 'asA' method must work with Float" in {
- Full(32f).asA[Float] must_== Full(32f)
- Full(33f).asA[Boolean] must_== Empty
- }
-
- "define a 'asA' method must work with Integer" in {
- Full(3).asA[Int] must_== Full(3)
- Full(3).asA[Boolean] must_== Empty
- }
-
- "define a 'asA' method must work with Long" in {
- Full(32L).asA[Long] must_== Full(32L)
- Full(32L).asA[Boolean] must_== Empty
- }
-
- "define a 'asA' method must work with Short" in {
- Full(8.toShort).asA[Short] must_== Full(8.toShort)
- Full(8.toShort).asA[Boolean] must_== Empty
- }
-
}
-
"An Empty Box" should {
"beEmpty" in {
Empty.isEmpty must beTrue
@@ -209,14 +156,14 @@ 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 be(Empty)
}
"define an 'exists' method returning false" in {
val empty: Box[Int] = Empty
@@ -224,7 +171,7 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
}
"define a 'filter' method, returning Empty" in {
val empty: Box[Int] = Empty
- empty filter {_ > 0} mustBe Empty
+ empty filter {_ > 0} must be(Empty)
}
"define a 'filterMsg' method, returning a Failure" in {
Empty.filterMsg("not equal to 0")(_ == 0) must_== Failure("not equal to 0", Empty, Empty)
@@ -232,14 +179,14 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
"define a 'foreach' doing nothing" in {
var total = 0
val empty: Box[Int] = Empty
- empty foreach {total += _}
+ empty foreach { total += _ }
total must_== 0
}
"define a 'map' method returning Empty" in {
- Empty map {_.toString} mustBe Empty
+ Empty map { _.toString } must be(Empty)
}
"define a 'flatMap' method returning Empty" in {
- Empty flatMap {x: Int => Full("full")} mustBe Empty
+ Empty flatMap { x: Int => Full("full") } must be(Empty)
}
"define an 'elements' method returning an empty iterator" in {
Empty.elements.hasNext must beFalse
@@ -263,7 +210,6 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
Empty.asA[Double] must_== Empty
}
}
-
"A Failure is an Empty Box which" can {
"return its cause as an exception" in {
case class LiftException(m: String) extends Exception
@@ -271,11 +217,10 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
}
"return a chained list of causes" in {
Failure("error",
- Full(new Exception("broken")),
- Full(Failure("nested cause", Empty, Empty))).chain must_== Full(Failure("nested cause", Empty, Empty))
+ Full(new Exception("broken")),
+ Full(Failure("nested cause", Empty, Empty))).chain must_== Full(Failure("nested cause", Empty, Empty))
}
}
-
"A Failure is an Empty Box which" should {
"return itself if mapped or flatmapped" in {
Failure("error", Empty, Empty) map {_.toString} must_== Failure("error", Empty, Empty)
@@ -288,57 +233,4 @@ object BoxSpec extends Specification("Box Specification") with ScalaCheck with B
Failure("error", Empty, Empty) ?~! "error2" must_== Failure("error2", Empty, Full(Failure("error", Empty, Empty)))
}
}
-
- "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
- }
- forAll(equality) must pass
- }
-
- "return false with comparing one Full and another object" in {
- Full(1) must_!= "hello"
- }
-
- "return false with comparing one Empty and another object" in {
- Empty must_!= "hello"
- }
-
- "return false with comparing one Failure and another object" in {
- Failure("", Empty, Empty) must_!= "hello"
- }
- }
-
}
-
-
-trait BoxGenerator {
-
- implicit def genThrowable: Arbitrary[Throwable] = Arbitrary[Throwable] {
- case object UserException extends Throwable
- value(UserException)
- }
-
- implicit def genBox[T](implicit a: Arbitrary[T]): Arbitrary[Box[T]] = Arbitrary[Box[T]] {
- frequency(
- (3, value(Empty)),
- (3, a.arbitrary.map(Full[T])),
- (1, genFailureBox)
- )
- }
-
- def genFailureBox: Gen[Failure] = for {
- msgLen <- choose(0, 4)
- msg <- listOfN(msgLen, alphaChar)
- exception <- value(Full(new Exception("")))
- chainLen <- choose(1, 5)
- chain <- frequency((1, listOfN(chainLen, genFailureBox)), (3, value(Nil)))
- } yield Failure(msg.mkString, exception, Box(chain.headOption))
-
-}
-
View
38 core/common/src/test/scala/net/liftweb/common/ConversionsSpec.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 WorldWide Conferencing, LLC
+ * Copyright 2010 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,18 +17,12 @@
package net.liftweb
package common
-import xml._
-
-import org.specs.Specification
-
-
-/**
- * System under specification for Conversions.
- */
-object ConversionsSpec extends Specification("Conversions Specification") {
+import org.specs2.mutable._
+import _root_.net.liftweb.common.Box._
+import _root_.scala.xml._
+class ConversionsSpec extends Specification {
"A StringOrNodeSeq" should {
-
"convert from a String" in {
val sns: StringOrNodeSeq = "Hello"
sns.nodeSeq must_== Text("Hello")
@@ -36,7 +30,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 {
@@ -46,64 +40,44 @@ object ConversionsSpec extends Specification("Conversions Specification") {
}
"A StringFunc" should {
-
"be created by a String constant" in {
val sf: StringFunc = "Foo"
-
sf.func() must_== "Foo"
}
-
"be created by a String Function" in {
val sf: StringFunc = () => "Bar"
-
sf.func() must_== "Bar"
}
-
"be created by a constant that can be converted to a String" in {
implicit def intToString(in: Int): String = in.toString
val sf: StringFunc = 55
-
sf.func() must_== "55"
}
-
"be created by a function that can be converted to a String" in {
implicit def intToString(in: Int): String = in.toString
val sf: StringFunc = () => 55
-
sf.func() must_== "55"
}
-
}
"A NodeSeqFunc" should {
-
"be created by a NodeSeq constant" in {
val sf: NodeSeqFunc = <b>Foo</b>
-
sf.func() must ==/ (<b>Foo</b>)
}
-
"be created by a NodeSeq Function" in {
val sf: NodeSeqFunc = () => <i>Bar</i>
-
sf.func() must ==/ (<i>Bar</i>)
}
-
"be created by a constant that can be converted to a NodeSeq" in {
implicit def intToNS(in: Int): NodeSeq = <a>{in}</a>
val sf: NodeSeqFunc = 55
-
sf.func() must ==/ (<a>55</a>)
}
-
"be created by a function that can be converted to a NodeSeq" in {
implicit def intToNodeSeq(in: Int): NodeSeq = <a>{in}</a>
val sf: NodeSeqFunc = () => 55
-
sf.func() must ==/ (<a>55</a>)
}
-
}
-
}
-
View
35 core/common/src/test/scala/net/liftweb/common/HListSpec.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 WorldWide Conferencing, LLC
+ * Copyright 2010 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,21 +17,15 @@
package net.liftweb
package common
-import org.specs.Specification
-
-
-/**
- * System under specification for Heterogeneous List.
- */
-object HListSpec extends Specification("HList Specification") {
+import org.specs2.mutable._
+import _root_.net.liftweb.common.Box._
+class HListSpec extends Specification {
"An HList" should {
-
- "get the types right" in {
+ "get types right" in {
import HLists._
val x = 1 :+: "Foo" :+: HNil
-
val head: Int = x.head
val head2: String = x.tail.head
@@ -41,20 +35,17 @@ object HListSpec extends Specification("HList Specification") {
}
"A combinable box" should {
-
- "have a box built with a failure result in a failure" in {
+ "build a box with a failure must be a failure" in {
import CombinableBox._
val x = Full("a") :&: Full(1) :&: Empty
// result in a failure
x match {
- case Left(_) => true must_== true
- case _ => fail("Full elements available")
+ case Left(_) => success
}
}
-
- "be able to build a box with all the Full elements matching" in {
+ "build a box with all Full must match" in {
import CombinableBox._
import HLists._
@@ -69,13 +60,11 @@ 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")
}
}
-
- "be usable in for comprehension" in {
+ "Use in for comprehension" in {
import CombinableBox._
import HLists._
@@ -87,6 +76,4 @@ object HListSpec extends Specification("HList Specification") {
res must_== Full(6)
}
}
-
-}
-
+}
View
38 core/common/src/test/scala/net/liftweb/common/LoggingSpec.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 WorldWide Conferencing, LLC
+ * Copyright 2010 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,15 +17,23 @@
package net.liftweb
package common
-import org.specs.Specification
+import org.specs2.mutable._
+import _root_.net.liftweb.common.Box._
+class MyTopClass extends Logger {
+ val x=1
+ debug("Top level class logging")
+}
+
+object MyTopObj extends Logger {
+ val x=1
+ debug("Top level object logging")
+}
/**
- * System under specification for Logging.
- *
- * Tests rely on logback being in the classpath, so no configuration should be necessary.
+ * Test relies on logback being on the classpath, so no configuration necessary
*/
-object LoggingSpec extends Specification("Logging Specification") {
+class LoggingUnitSpec extends Specification {
"Logging" can {
"be mixed directly into object" in {
object MyObj extends Logger {
@@ -52,7 +60,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 {
@@ -88,7 +96,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 +106,7 @@ object LoggingSpec extends Specification("Logging Specification") {
val x = 1
}
MyObj.x
+ success
}
"be used in different levels and yield different loggers" in {
@@ -119,16 +128,3 @@ object LoggingSpec extends Specification("Logging Specification") {
}
}
}
-
-
-class MyTopClass extends Logger {
- val x=1
- debug("Top level class logging")
-}
-
-
-object MyTopObj extends Logger {
- val x=1
- debug("Top level object logging")
-}
-
View
30 core/common/src/test/scala/net/liftweb/common/LruMapSpec.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 WorldWide Conferencing, LLC
+ * Copyright 2010 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,31 +17,27 @@
package net.liftweb
package common
-import org.specs.Specification
+import org.specs2.mutable._
+import _root_.net.liftweb.common.Box._
-
-/**
- * Systems under specification for LRU Map.
- */
-object LruMapSpec extends Specification("LRU Map Specification") {
-
- "An LRU Map" should {
-
- "never grow beyond the given size" in {
+class LruMapSpec extends Specification {
+ "LRU" should {
+ "never grow beyond a certain size" in {
val lru = new LRUMap[Int, Int](10)
for (i <- 1 to 20) lru(i) = i
lru.size must_== 10
}
- "have the last N elements (where N is the initial MaxSize)" in {
+ "have the last 10 elements" in {
val lru = new LRUMap[Int, Int](10)
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 {
var expCnt = 0
val lru = new LRUMap[Int, Int](10, Empty, (k, v) => {expCnt += 1; k must_== v; k must be > 0; v must be < 11})
@@ -49,10 +45,10 @@ 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 {
+ "not expire recently accessed" in {
var expCnt = 0
val lru = new LRUMap[Int, Int](10, Empty, (k, v) => {expCnt += 1; k must_== v; k must be > 0})
for (i <- 1 to 20) {
@@ -66,6 +62,4 @@ object LruMapSpec extends Specification("LRU Map Specification") {
}
}
-
-}
-
+}
View
13 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._
import common._
import json.Serialization.{read, write => swrite}
@@ -29,8 +29,9 @@ 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
"Serialize joda time types" in {
@@ -38,7 +39,7 @@ object JodaTimeSerializerSpec extends Specification("JodaTimeSerializer Specific
new DateTime, new DateMidnight, new Interval(1000, 50000),
new LocalDate(2011, 1, 16), new LocalTime(16, 52, 10))
val ser = swrite(x)
- read[JodaTypes](ser) mustEqual x
+ read[JodaTypes](ser) must_== x
}
"DateTime and DateMidnight use configured date format" in {
@@ -48,13 +49,13 @@ object JodaTimeSerializerSpec extends Specification("JodaTimeSerializer Specific
val x = Dates(new DateTime(2011, 1, 16, 10, 32, 0, 0, DateTimeZone.UTC), new DateMidnight(2011, 1, 16, DateTimeZone.UTC))
val ser = swrite(x)
- ser mustEqual """{"dt":"2011-01-16 10:32:00Z","dm":"2011-01-16 00:00:00Z"}"""
+ ser must_== """{"dt":"2011-01-16 10:32:00Z","dm":"2011-01-16 00:00:00Z"}"""
}
"null is serialized as JSON null" in {
val x = JodaTypes(null, null, null, null, null, null, null)
val ser = swrite(x)
- read[JodaTypes](ser) mustEqual x
+ read[JodaTypes](ser) must_== x
}
}
View
21 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._
import common._
import json.Serialization.{read, write => swrite}
@@ -27,27 +27,28 @@ 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
"Extract empty age" in {
- parse("""{"name":"joe"}""").extract[Person] mustEqual Person("joe", Empty, Empty)
+ parse("""{"name":"joe"}""").extract[Person] must_== Person("joe", Empty, Empty)
}
"Extract boxed age" in {
- parse("""{"name":"joe", "age":12}""").extract[Person] mustEqual Person("joe", Full(12), Empty)
+ parse("""{"name":"joe", "age":12}""").extract[Person] must_== Person("joe", Full(12), Empty)
}
"Extract boxed mother" in {
val json = """{"name":"joe", "age":12, "mother": {"name":"ann", "age":53}}"""
val p = parse(json).extract[Person]
- p mustEqual Person("joe", Full(12), Full(Person("ann", Full(53), Empty)))
- (for { a1 <- p.age; m <-p.mother; a2 <- m.age } yield a1+a2) mustEqual Full(65)
+ p must_== Person("joe", Full(12), Full(Person("ann", Full(53), Empty)))
+ (for { a1 <- p.age; m <-p.mother; a2 <- m.age } yield a1+a2) must_== Full(65)
}
"Render with age" in {
- swrite(Person("joe", Full(12), Empty)) mustEqual """{"name":"joe","age":12,"mother":null}"""
+ swrite(Person("joe", Full(12), Empty)) must_== """{"name":"joe","age":12,"mother":null}"""
}
"Serialize failure" in {
@@ -55,14 +56,14 @@ object JsonBoxSerializerSpec extends Specification("JsonBoxSerializer Specificat
val exn2 = SomeException("e2")
val p = Person("joe", Full(12), Failure("f", Full(exn1), Failure("f2", Full(exn2), Empty)))
val ser = swrite(p)
- read[Person](ser) mustEqual p
+ read[Person](ser) must_== p
}
"Serialize param failure" in {
val exn = SomeException("e1")
val p = Person("joe", Full(12), ParamFailure("f", Full(exn), Empty, "param value"))
val ser = swrite(p)
- read[Person](ser) mustEqual p
+ read[Person](ser) must_== p
}
}
View
18 core/json/src/test/scala/net/liftweb/json/DiffExamples.scala
@@ -17,20 +17,20 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable._
/**
* System under specification for Diff Examples.
*/
-object DiffExamples extends Specification("Diff Examples") {
+object DiffExamples extends Specification {
import MergeExamples.{scala1, scala2, lotto1, lotto2, mergedLottoResult}
"Diff example" in {
val Diff(changed, added, deleted) = scala1 diff scala2
- changed mustEqual expectedChanges
- added mustEqual expectedAdditions
- deleted mustEqual expectedDeletions
+ changed must_== expectedChanges
+ added must_== expectedAdditions
+ deleted must_== expectedDeletions
}
val expectedChanges = parse("""
@@ -57,9 +57,9 @@ object DiffExamples extends Specification("Diff Examples") {
"Lotto example" in {
val Diff(changed, added, deleted) = mergedLottoResult diff lotto1
- changed mustEqual JNothing
- added mustEqual JNothing
- deleted mustEqual lotto2
+ changed must_== JNothing
+ added must_== JNothing
+ deleted must_== lotto2
}
"Example from http://tlrobinson.net/projects/js/jsondiff/" in {
@@ -69,7 +69,7 @@ object DiffExamples extends Specification("Diff Examples") {
val expectedAdditions = read("/diff-example-expected-additions.json")
val expectedDeletions = read("/diff-example-expected-deletions.json")
- json1 diff json2 mustEqual Diff(expectedChanges, expectedAdditions, expectedDeletions)
+ json1 diff json2 must_== Diff(expectedChanges, expectedAdditions, expectedDeletions)
}
private def read(resource: String) =
View
60 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._
object Examples extends Specification {
@@ -27,28 +27,28 @@ object Examples extends Specification {
"Lotto example" in {
val json = parse(lotto)
val renderedLotto = compact(render(json))
- json mustEqual parse(renderedLotto)
+ json must_== parse(renderedLotto)
}
"Person example" in {
val json = parse(person)
val renderedPerson = Printer.pretty(render(json))
- json mustEqual parse(renderedPerson)
- render(json) mustEqual render(personDSL)
- compact(render(json \\ "name")) mustEqual """{"name":"Joe","name":"Marilyn"}"""
- compact(render(json \ "person" \ "name")) mustEqual "\"Joe\""
+ json must_== parse(renderedPerson)
+ render(json) must_== render(personDSL)
+ compact(render(json \\ "name")) must_== """{"name":"Joe","name":"Marilyn"}"""
+ compact(render(json \ "person" \ "name")) must_== "\"Joe\""
}
"Transformation example" in {
val uppercased = parse(person).transform { case JField(n, v) => JField(n.toUpperCase, v) }
val rendered = compact(render(uppercased))
- rendered mustEqual
+ rendered must_==
"""{"PERSON":{"NAME":"Joe","AGE":35,"SPOUSE":{"PERSON":{"NAME":"Marilyn","AGE":33}}}}"""
}
"Remove example" in {
val json = parse(person) remove { _ == JField("name", "Marilyn") }
- compact(render(json \\ "name")) mustEqual """{"name":"Joe"}"""
+ compact(render(json \\ "name")) must_== """{"name":"Joe"}"""
}
"Queries on person example" in {
@@ -57,66 +57,66 @@ object Examples extends Specification {
case JField("name", _) => true
case _ => false
}
- filtered mustEqual List(JField("name", JString("Joe")), JField("name", JString("Marilyn")))
+ filtered must_== List(JField("name", JString("Joe")), JField("name", JString("Marilyn")))
val found = json find {
case JField("name", _) => true
case _ => false
}
- found mustEqual Some(JField("name", JString("Joe")))
+ found must_== Some(JField("name", JString("Joe")))
}
"Object array example" in {
val json = parse(objArray)
- compact(render(json \ "children" \ "name")) mustEqual """["name":"Mary","name":"Mazy"]"""
- compact(render((json \ "children")(0) \ "name")) mustEqual "\"Mary\""
- compact(render((json \ "children")(1) \ "name")) mustEqual "\"Mazy\""
- (for { JField("name", JString(y)) <- json } yield y) mustEqual List("joe", "Mary", "Mazy")
+ compact(render(json \ "children" \ "name")) must_== """["name":"Mary","name":"Mazy"]"""
+ compact(render((json \ "children")(0) \ "name")) must_== "\"Mary\""
+ compact(render((json \ "children")(1) \ "name")) must_== "\"Mazy\""
+ (for { JField("name", JString(y)) <- json } yield y) must_== List("joe", "Mary", "Mazy")
}
"Unbox values using XPath-like type expression" in {
- parse(objArray) \ "children" \\ classOf[JInt] mustEqual List(5, 3)
- parse(lotto) \ "lotto" \ "winning-numbers" \ classOf[JInt] mustEqual List(2, 45, 34, 23, 7, 5, 3)
- parse(lotto) \\ "winning-numbers" \ classOf[JInt] mustEqual List(2, 45, 34, 23, 7, 5, 3)
+ parse(objArray) \ "children" \\ classOf[JInt] must_== List(5, 3)
+ parse(lotto) \ "lotto" \ "winning-numbers" \ classOf[JInt] must_== List(2, 45, 34, 23, 7, 5, 3)
+ parse(lotto) \\ "winning-numbers" \ classOf[JInt] must_== List(2, 45, 34, 23, 7, 5, 3)
}
"Quoted example" in {
val json = parse(quoted)
- List("foo \" \n \t \r bar") mustEqual json.values
+ (List("foo \" \n \t \r bar"): Any) must_== (json.values:Any)
}
"Null example" in {
- compact(render(parse(""" {"name": null} """))) mustEqual """{"name":null}"""
+ compact(render(parse(""" {"name": null} """))) must_== """{"name":null}"""
}
"Null rendering example" in {
- compact(render(nulls)) mustEqual """{"f1":null,"f2":[null,"s"]}"""
+ compact(render(nulls)) must_== """{"f1":null,"f2":[null,"s"]}"""
}
"Symbol example" in {
- compact(render(symbols)) mustEqual """{"f1":"foo","f2":"bar"}"""
+ compact(render(symbols)) must_== """{"f1":"foo","f2":"bar"}"""
}
"Unicode example" in {
- parse("[\" \\u00e4\\u00e4li\\u00f6t\"]") mustEqual JArray(List(JString(" \u00e4\u00e4li\u00f6t")))
+ parse("[\" \\u00e4\\u00e4li\\u00f6t\"]") must_== JArray(List(JString(" \u00e4\u00e4li\u00f6t")))
}
"Exponent example" in {
- parse("""{"num": 2e5 }""") mustEqual JObject(List(JField("num", JDouble(200000.0))))
- parse("""{"num": -2E5 }""") mustEqual JObject(List(JField("num", JDouble(-200000.0))))
- parse("""{"num": 2.5e5 }""") mustEqual JObject(List(JField("num", JDouble(250000.0))))
- parse("""{"num": 2.5e-5 }""") mustEqual JObject(List(JField("num", JDouble(2.5e-5))))
+ parse("""{"num": 2e5 }""") must_== JObject(List(JField("num", JDouble(200000.0))))
+ parse("""{"num": -2E5 }""") must_== JObject(List(JField("num", JDouble(-200000.0))))
+ parse("""{"num": 2.5e5 }""") must_== JObject(List(JField("num", JDouble(250000.0))))
+ parse("""{"num": 2.5e-5 }""") must_== JObject(List(JField("num", JDouble(2.5e-5))))
}
"JSON building example" in {
val json = concat(JField("name", JString("joe")), JField("age", JInt(34))) ++ concat(JField("name", JString("mazy")), JField("age", JInt(31)))
- compact(render(json)) mustEqual """[{"name":"joe","age":34},{"name":"mazy","age":31}]"""
+ compact(render(json)) must_== """[{"name":"joe","age":34},{"name":"mazy","age":31}]"""
}
"JSON building with implicit primitive conversions example" in {
import Implicits._
val json = concat(JField("name", "joe"), JField("age", 34)) ++ concat(JField("name", "mazy"), JField("age", 31))
- compact(render(json)) mustEqual """[{"name":"joe","age":34},{"name":"mazy","age":31}]"""
+ compact(render(json)) must_== """[{"name":"joe","age":34},{"name":"mazy","age":31}]"""
}
"Example which collects all integers and forms a new JSON" in {
@@ -125,14 +125,14 @@ object Examples extends Specification {
case x: JInt => a ++ x
case _ => a
}}
- compact(render(ints)) mustEqual """[35,33]"""
+ compact(render(ints)) must_== """[35,33]"""
}
"Generate JSON with DSL example" in {
val json: JValue =
("id" -> 5) ~
("tags" -> Map("a" -> 5, "b" -> 7))
- compact(render(json)) mustEqual """{"id":5,"tags":{"a":5,"b":7}}"""
+ compact(render(json)) must_== """{"id":5,"tags":{"a":5,"b":7}}"""
}
val lotto = """
View
12 core/json/src/test/scala/net/liftweb/json/ExtractionBugs.scala
@@ -17,28 +17,30 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for Extraction bugs.
*/
-object ExtractionBugs extends Specification("Extraction bugs Specification") {
+object ExtractionBugs extends Specification {
+ "Extraction bugs Specification".title
+
implicit val formats = DefaultFormats
"ClassCastException (BigInt) regression 2 must pass" in {
val opt = OptionOfInt(Some(39))
- Extraction.decompose(opt).extract[OptionOfInt].opt.get mustEqual 39
+ Extraction.decompose(opt).extract[OptionOfInt].opt.get must_== 39
}
"Extraction should not fail when Maps values are Lists" in {
val m = PMap(Map("a" -> List("b"), "c" -> List("d")))
- Extraction.decompose(m).extract[PMap] mustEqual m
+ Extraction.decompose(m).extract[PMap] must_== m
}
"Extraction should always choose constructor with the most arguments if more than one constructor exists" in {
val args = Meta.Reflection.primaryConstructorArgs(classOf[ManyConstructors])
- args.size mustEqual 4
+ args.size must_== 4
}
case class OptionOfInt(opt: Option[Int])
View
92 core/json/src/test/scala/net/liftweb/json/ExtractionExamplesSpec.scala
@@ -18,88 +18,90 @@ package net.liftweb
package json
import java.util.Date
-import org.specs.Specification
+import org.specs2.mutable._
/**
* Systems under specification for Extraction Examples.
*/
-object ExtractionExamples extends Specification("Extraction Examples Specification") {
+object ExtractionExamplesSpec extends Specification {
+ "Extraction Examples Specification".title
+
implicit val formats = DefaultFormats
"Extraction example" in {
val json = parse(testJson)
- json.extract[Person] mustEqual Person("joe", Address("Bulevard", "Helsinki"), List(Child("Mary", 5, Some(date("2004-09-04T18:06:22Z"))), Child("Mazy", 3, None)))
+ json.extract[Person] must_== Person("joe", Address("Bulevard", "Helsinki"), List(Child("Mary", 5, Some(date("2004-09-04T18:06:22Z"))), Child("Mazy", 3, None)))
}
"Extraction with path expression example" in {
val json = parse(testJson)
- (json \ "address").extract[Address] mustEqual Address("Bulevard", "Helsinki")
+ (json \ "address").extract[Address] must_== Address("Bulevard", "Helsinki")
}
"Partial extraction example" in {
val json = parse(testJson)
- json.extract[SimplePerson] mustEqual SimplePerson("joe", Address("Bulevard", "Helsinki"))
+ json.extract[SimplePerson] must_== SimplePerson("joe", Address("Bulevard", "Helsinki"))
}
"Map with primitive values extraction example" in {
val json = parse(testJson)
- json.extract[PersonWithMap] mustEqual
+ json.extract[PersonWithMap] must_==
PersonWithMap("joe", Map("street" -> "Bulevard", "city" -> "Helsinki"))
}
"Map with object values extraction example" in {
val json = parse(twoAddresses)
- json.extract[PersonWithAddresses] mustEqual
+ json.extract[PersonWithAddresses] must_==
PersonWithAddresses("joe", Map("address1" -> Address("Bulevard", "Helsinki"),
"address2" -> Address("Soho", "London")))
}
"Simple value extraction example" in {
val json = parse(testJson)
- json.extract[Name] mustEqual Name("joe")
- (json \ "children")(0).extract[Name] mustEqual Name("Mary")
- (json \ "children")(1).extract[Name] mustEqual Name("Mazy")
+ json.extract[Name] must_== Name("joe")
+ (json \ "children")(0).extract[Name] must_== Name("Mary")
+ (json \ "children")(1).extract[Name] must_== Name("Mazy")
}
"Primitive value extraction example" in {
val json = parse(testJson)
- (json \ "name").extract[String] mustEqual "joe"
- (json \ "name").extractOpt[String] mustEqual Some("joe")
- (json \ "name").extractOpt[Int] mustEqual None
- ((json \ "children")(0) \ "birthdate").extract[Date] mustEqual date("2004-09-04T18:06:22Z")
-
- JInt(1).extract[Int] mustEqual 1
- JInt(1).extract[String] mustEqual "1"
- JField("foo", JInt(1)).extract[Int] mustEqual 1
+ (json \ "name").extract[String] must_== "joe"
+ (json \ "name").extractOpt[String] must_== Some("joe")
+ (json \ "name").extractOpt[Int] must_== None
+ ((json \ "children")(0) \ "birthdate").extract[Date] must_== date("2004-09-04T18:06:22Z")
+
+ JInt(1).extract[Int] must_== 1
+ JInt(1).extract[String] must_== "1"
+ JField("foo", JInt(1)).extract[Int] must_== 1
}
"Primitive extraction example" in {
val json = parse(primitives)
- json.extract[Primitives] mustEqual Primitives(124, 123L, 126.5, 127.5.floatValue, "128", 'symb, 125, 129.byteValue, true)
+ json.extract[Primitives] must_== Primitives(124, 123L, 126.5, 127.5.floatValue, "128", 'symb, 125, 129.byteValue, true)
}
"Null extraction example" in {
val json = parse("""{ "name": null, "age": 5, "birthdate": null }""")
- json.extract[Child] mustEqual Child(null, 5, None)
+ json.extract[Child] must_== Child(null, 5, None)
}
"Date extraction example" in {
val json = parse("""{"name":"e1","timestamp":"2009-09-04T18:06:22Z"}""")
- json.extract[Event] mustEqual Event("e1", date("2009-09-04T18:06:22Z"))
+ json.extract[Event] must_== Event("e1", date("2009-09-04T18:06:22Z"))
}
"Option extraction example" in {
val json = parse("""{ "name": null, "age": 5, "mother":{"name":"Marilyn"}}""")
- json.extract[OChild] mustEqual OChild(None, 5, Some(Parent("Marilyn")), None)
+ json.extract[OChild] must_== OChild(None, 5, Some(Parent("Marilyn")), None)
}
"Missing JSON array can be extracted as an empty List" in {
- parse(missingChildren).extract[Person] mustEqual Person("joe", Address("Bulevard", "Helsinki"), Nil)
+ parse(missingChildren).extract[Person] must_== Person("joe", Address("Bulevard", "Helsinki"), Nil)
}
"Multidimensional array extraction example" in {
- parse(multiDimensionalArrays).extract[MultiDim] mustEqual MultiDim(
+ parse(multiDimensionalArrays).extract[MultiDim] must_== MultiDim(
List(List(List(1, 2), List(3)), List(List(4), List(5, 6))),
List(List(Name("joe"), Name("mary")), List(Name("mazy"))))
}
@@ -108,64 +110,64 @@ object ExtractionExamples extends Specification("Extraction Examples Specificati
val f = Extraction.flatten(Extraction.decompose(SimplePerson("joe", Address("Bulevard", "Helsinki"))))
val e = Map(".name" -> "\"joe\"", ".address.street" -> "\"Bulevard\"", ".address.city" -> "\"Helsinki\"")
- f mustEqual e
+ f must_== e
}
"Unflatten example with top level string and int" in {
val m = Map(".name" -> "\"joe\"", ".age" -> "32")
- Extraction.unflatten(m) mustEqual JObject(List(JField("name",JString("joe")), JField("age",JInt(32))))
+ Extraction.unflatten(m) must_== JObject(List(JField("name",JString("joe")), JField("age",JInt(32))))
}
"Unflatten example with top level string and double" in {
val m = Map(".name" -> "\"joe\"", ".age" -> "32.2")
- Extraction.unflatten(m) mustEqual JObject(List(JField("name",JString("joe")), JField("age",JDouble(32.2))))
+ Extraction.unflatten(m) must_== JObject(List(JField("name",JString("joe")), JField("age",JDouble(32.2))))
}
"Unflatten example with two-level string properties" in {
val m = Map(".name" -> "\"joe\"", ".address.street" -> "\"Bulevard\"", ".address.city" -> "\"Helsinki\"")
- Extraction.unflatten(m) mustEqual JObject(List(JField("name", JString("joe")), JField("address", JObject(List(JField("street", JString("Bulevard")), JField("city", JString("Helsinki")))))))
+ Extraction.unflatten(m) must_== JObject(List(JField("name", JString("joe")), JField("address", JObject(List(JField("street", JString("Bulevard")), JField("city", JString("Helsinki")))))))
}
"Unflatten example with top level array" in {
val m = Map(".foo[2]" -> "2", ".foo[0]" -> "0", ".foo[1]" -> "1")
- Extraction.unflatten(m) mustEqual JObject(List(JField("foo", JArray(List(JInt(0), JInt(1), JInt(2))))))
+ Extraction.unflatten(m) must_== JObject(List(JField("foo", JArray(List(JInt(0), JInt(1), JInt(2))))))
}
"Flatten and unflatten are symmetric" in {
val parsed = parse(testJson)
- Extraction.unflatten(Extraction.flatten(parsed)) mustEqual parsed
+ Extraction.unflatten(Extraction.flatten(parsed)) must_== parsed
}
"Flatten preserves empty sets" in {
val s = SetWrapper(Set())
- Extraction.flatten(Extraction.decompose(s)).get(".set") mustEqual Some("[]")
+ Extraction.flatten(Extraction.decompose(s)).get(".set") must_== Some("[]")
}
"Flatten and unflatten are symmetric with empty sets" in {
val s = SetWrapper(Set())
- Extraction.unflatten(Extraction.flatten(Extraction.decompose(s))).extract[SetWrapper] mustEqual s
+ Extraction.unflatten(Extraction.flatten(Extraction.decompose(s))).extract[SetWrapper] must_== s
}
"List extraction example" in {
val json = parse(testJson) \ "children"
- json.extract[List[Name]] mustEqual List(Name("Mary"), Name("Mazy"))
+ json.extract[List[Name]] must_== List(Name("Mary"), Name("Mazy"))
}
"Map extraction example" in {
val json = parse(testJson) \ "address"
- json.extract[Map[String, String]] mustEqual Map("street" -> "Bulevard", "city" -> "Helsinki")
+ json.extract[Map[String, String]] must_== Map("street" -> "Bulevard", "city" -> "Helsinki")
}
"Extraction and decomposition are symmetric" in {
val person = parse(testJson).extract[Person]
- Extraction.decompose(person).extract[Person] mustEqual person
+ Extraction.decompose(person).extract[Person] must_== person
}
"Extraction failure message example" in {
@@ -174,33 +176,33 @@ object ExtractionExamples extends Specification("Extraction Examples Specificati
}
"Best matching constructor selection example" in {
- parse("""{"name":"john","age":32,"size":"M"}""").extract[MultipleConstructors] mustEqual
+ parse("""{"name":"john","age":32,"size":"M"}""").extract[MultipleConstructors] must_==
MultipleConstructors("john", 32, Some("M"))
- parse("""{"name":"john","age":32}""").extract[MultipleConstructors] mustEqual
+ parse("""{"name":"john","age":32}""").extract[MultipleConstructors] must_==
MultipleConstructors("john", 32, Some("S"))
- parse("""{"name":"john","foo":"xxx"}""").extract[MultipleConstructors] mustEqual
+ parse("""{"name":"john","foo":"xxx"}""").extract[MultipleConstructors] must_==
MultipleConstructors("john", 30, None)
- parse("""{"name":"john","age":32,"size":null}""").extract[MultipleConstructors] mustEqual
+ parse("""{"name":"john","age":32,"size":null}""").extract[MultipleConstructors] must_==
MultipleConstructors("john", 32, None)
- parse("""{"birthYear":1990,"name":"john","foo":2}""").extract[MultipleConstructors] mustEqual
+ parse("""{"birthYear":1990,"name":"john","foo":2}""").extract[MultipleConstructors] must_==
MultipleConstructors("john", 20, None)
- parse("""{"foo":2,"age":12,"size":"XS"}""").extract[MultipleConstructors] mustEqual
+ parse("""{"foo":2,"age":12,"size":"XS"}""").extract[MultipleConstructors] must_==
MultipleConstructors("unknown", 12, Some("XS"))
}
"Partial JSON extraction" in {
- parse(stringField).extract[ClassWithJSON] mustEqual ClassWithJSON("one", JString("msg"))
- parse(objField).extract[ClassWithJSON] mustEqual ClassWithJSON("one", JObject(List(JField("yes", JString("woo")))))
+ parse(stringField).extract[ClassWithJSON] must_== ClassWithJSON("one", JString("msg"))
+ parse(objField).extract[ClassWithJSON] must_== ClassWithJSON("one", JObject(List(JField("yes", JString("woo")))))
}
"Double can be coerced to Int or Long" in {
- JDouble(2.1).extract[Int] mustEqual 2
- JDouble(2.1).extract[Long] mustEqual 2L
+ JDouble(2.1).extract[Int] must_== 2
+ JDouble(2.1).extract[Long] must_== 2L
}
val testJson =
View
86 core/json/src/test/scala/net/liftweb/json/JsonAstSpec.scala
@@ -17,7 +17,8 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.mutable._
+import org.specs2.ScalaCheck
import org.scalacheck._
import org.scalacheck.Prop.{forAll, forAllNoShrink}
@@ -25,73 +26,57 @@ import org.scalacheck.Prop.{forAll, forAllNoShrink}
/**
* System under specification for JSON AST.
*/
-object JsonAstSpec extends Specification("JSON AST Specification") with JValueGen with ScalaCheck {
- "Functor identity" in {
- val identityProp = (json: JValue) => json == (json map identity)
- forAll(identityProp) must pass
+object JsonAstSpec extends Specification with JValueGen with ScalaCheck {
+ "JSON AST Specification".title
+
+ "Functor identity" in { (json: JValue) =>
+ json === (json map identity)
}
- "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
+ "Functor composition" in check{ (json: JValue, fa: JValue => JValue, fb: JValue => JValue) =>
+ json.map(fb).map(fa) === json.map(fa compose fb)
}
- "Monoid identity" in {
- val identityProp = (json: JValue) => (json ++ JNothing == json) && (JNothing ++ json == json)
- forAll(identityProp) must pass
+ "Monoid identity" in { (json: JValue) =>
+ (json ++ JNothing === json) and (JNothing ++ json === json)
}
- "Monoid associativity" in {
- val assocProp = (x: JValue, y: JValue, z: JValue) => x ++ (y ++ z) == (x ++ y) ++ z
- forAll(assocProp) must pass
+ "Monoid associativity" in check { (x: JValue, y: JValue, z: JValue) =>
+ x ++ (y ++ z) === (x ++ y) ++ z
}
- "Merge identity" in {
- val identityProp = (json: JValue) => (json merge JNothing) == json && (JNothing merge json) == json
- forAll(identityProp) must pass
+ "Merge identity" in { (json: JValue) =>
+ (json merge JNothing) === json and (JNothing merge json) === json
}
- "Merge idempotency" in {
- val idempotencyProp = (x: JValue) => (x merge x) == x
- forAll(idempotencyProp) must pass
+ "Merge idempotency" in { (x: JValue) =>
+ (x merge x) === x
}
- "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
+ "Diff identity" in check { (json: JValue) =>
+ ((json diff JNothing) === Diff(JNothing, JNothing, json)) and
+ ((JNothing diff json) === Diff(JNothing, json, JNothing))
}
- "Diff with self is empty" in {
- val emptyProp = (x: JValue) => (x diff x) == Diff(JNothing, JNothing, JNothing)
- forAll(emptyProp) must pass
+ "Diff with self is empty" in check { (x: JValue) =>
+ (x diff x) === Diff(JNothing, JNothing, JNothing)
}
- "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
+ "Diff is subset of originals" in check { (x: JObject, y: JObject) =>
+ val Diff(c, a, d) = x diff y
+ y === (y merge (c merge a))
}
- "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
+ "Diff result is same when fields are reordered" in check { (x: JObject) =>
+ (x diff reorderFields(x)) === Diff(JNothing, JNothing, JNothing)
}
- "Remove all" in {
- val removeAllProp = (x: JValue) => (x remove { _ => true }) == JNothing
- forAll(removeAllProp) must pass
+ "Remove all" in { (x: JValue) =>
+ (x remove { _ => true }) === JNothing
}
- "Remove nothing" in {
- val removeNothingProp = (x: JValue) => (x remove { _ => false }) == x
- forAll(removeNothingProp) must pass
+ "Remove nothing" in { (x: JValue) =>
+ (x remove { _ => false }) === x
}
"Remove removes only matching elements (in case of a field, its value is set to JNothing)" in {
@@ -103,11 +88,11 @@ object JsonAstSpec extends Specification("JSON AST Specification") with JValueGe
case _ => true
}
c == JNothing && a == JNothing && elemsLeft.forall(_.getClass != x)
- }} must pass
+ }}
}
- "Replace one" in {
- val anyReplacement = (x: JValue, replacement: JObject) => {
+ "Replace one" in checkProp {
+ val anyReplacement = (x: JValue, replacement: JObject) => {
def findOnePath(jv: JValue, l: List[String]): List[String] = jv match {
case JField(name, value) => findOnePath(value, name :: l)
case JObject(fl) => fl match {
@@ -142,8 +127,7 @@ 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
+ fieldReplacement.forAll && anyReplacement.forAll
}
private def reorderFields(json: JValue) = json map {
View
18 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._
/**
* 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])
@@ -30,15 +32,15 @@ object JsonFormatsSpec extends Specification("JsonFormats Specification") with T
val hintsForAnimal = FullTypeHintExamples.formats.typeHints.hintFor(classOf[Animal])
"hintsFor across composite formats" in {
- formats.typeHints.hintFor(classOf[Fish]) mustEqual (hintsForFish)
- formats.typeHints.hintFor(classOf[Dog]) mustEqual (hintsForDog)
- formats.typeHints.hintFor(classOf[Animal]) mustEqual (hintsForAnimal)
+ formats.typeHints.hintFor(classOf[Fish]) must_== (hintsForFish)
+ formats.typeHints.hintFor(classOf[Dog]) must_== (hintsForDog)
+ formats.typeHints.hintFor(classOf[Animal]) must_== (hintsForAnimal)
}
"classFor across composite formats" in {
- formats.typeHints.classFor(hintsForFish) mustEqual (ShortTypeHintExamples.formats.typeHints.classFor(hintsForFish))
- formats.typeHints.classFor(hintsForDog) mustEqual (ShortTypeHintExamples.formats.typeHints.classFor(hintsForDog))
- formats.typeHints.classFor(hintsForAnimal) mustEqual (FullTypeHintExamples.formats.typeHints.classFor(hintsForAnimal))
+ formats.typeHints.classFor(hintsForFish) must_== (ShortTypeHintExamples.formats.typeHints.classFor(hintsForFish))
+ formats.typeHints.classFor(hintsForDog) must_== (ShortTypeHintExamples.formats.typeHints.classFor(hintsForDog))
+ formats.typeHints.classFor(hintsForAnimal) must_== (FullTypeHintExamples.formats.typeHints.classFor(hintsForAnimal))
}
"parameter name reading strategy can be changed" in {
View
35 core/json/src/test/scala/net/liftweb/json/JsonParserSpec.scala
@@ -17,7 +17,8 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.ScalaCheck
+import org.specs2.mutable._
import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Prop._
@@ -25,26 +26,32 @@ import org.scalacheck.Prop._
/**
* System under specification for JSON Parser.
*/
-object JsonParserSpec extends Specification("JSON Parser Specification") with JValueGen with ScalaCheck {
- "Any valid json can be parsed" in {
- val parsing = (json: JValue) => { parse(Printer.pretty(render(json))); true }
- forAll(parsing) must pass
+object JsonParserSpec extends Specification with JValueGen with ScalaCheck {
+ "JSON Parser Specification".title
+
+ "Any valid json can be parsed" in check { (json: JValue) =>
+ parse(Printer.pretty(render(json))) must not(throwA[java.lang.Exception])
}
- "Buffer size does not change parsing result" in {
+ "Buffer size does not change parsing result" in checkProp {
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
+ forAll(genObject, bufSize, bufSize)(parsing)
}
"Parsing is thread safe" in {
import java.util.concurrent._
val json = Examples.person
- val executor = Executors.newFixedThreadPool(100)
- val results = (0 to 100).map(_ =>
- executor.submit(new Callable[JValue] { def call = parse(json) })).toList.map(_.get)
- results.zip(results.tail).forall(pair => pair._1 == pair._2) mustEqual true
+ val executor = Executors.newFixedThreadPool(10)
+ try {
+ val results = (0 to 10).map(_ =>
+ executor.submit(new Callable[JValue] { def call = parse(json) })).toList.map(_.get)
+ results.zip(results.tail).forall(pair => pair._1 == pair._2) must_== true
+ } finally {
+ executor.shutdown()
+ }
+
}
"All valid string escape characters can be parsed" in {
@@ -52,8 +59,8 @@ object JsonParserSpec extends Specification("JSON Parser Specification") with JV
}
"Unclosed string literal fails parsing" in {
- parseOpt("{\"foo\":\"sd") mustEqual None
- parseOpt("{\"foo\":\"sd}") mustEqual None
+ parseOpt("{\"foo\":\"sd") must_== None
+ parseOpt("{\"foo\":\"sd}") must_== None
}
"The EOF has reached when the Reader returns EOF" in {
@@ -69,7 +76,7 @@ object JsonParserSpec extends Specification("JSON Parser Specification") with JV
}
val json = JsonParser.parse(new StingyReader(""" ["hello"] """))
- json mustEqual JArray(JString("hello") :: Nil)
+ json must_== JArray(JString("hello") :: Nil)
}
implicit def arbJValue: Arbitrary[JValue] = Arbitrary(genObject)
View
12 core/json/src/test/scala/net/liftweb/json/JsonPrintingSpec.scala
@@ -17,7 +17,8 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.ScalaCheck
+import org.specs2.mutable._
import org.scalacheck.Arbitrary
import org.scalacheck.Prop.forAll
@@ -25,12 +26,13 @@ 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
+ "rendering does not change semantics" in check { (json: Document) =>
+ parse(Printer.pretty(json)) === parse(Printer.compact(json))
}
private def parse(json: String) = scala.util.parsing.json.JSON.parse(json)
View
18 core/json/src/test/scala/net/liftweb/json/JsonQueryExamples.scala
@@ -17,21 +17,23 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable._
/**
* 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")
+ ips must_== List("192.168.1.125", "192.168.1.126", "192.168.1.127", "192.168.2.125", "192.168.2.126")
}
"List of IPs converted to XML" in {
val ips = <ips>{ for { JString(ip) <- json \\ "ip" } yield <ip>{ ip }</ip> }</ips>
- ips mustEqual <ips><ip>192.168.1.125</ip><ip>192.168.1.126</ip><ip>192.168.1.127</ip><ip>192.168.2.125</ip><ip>192.168.2.126</ip></ips>
+ ips must_== <ips><ip>192.168.1.125</ip><ip>192.168.1.126</ip><ip>192.168.1.127</ip><ip>192.168.2.125</ip><ip>192.168.2.126</ip></ips>
}
"List of IPs in cluster2" in {
@@ -39,11 +41,11 @@ object JsonQueryExamples extends Specification("JSON Query Examples") {
cluster @ JObject(x) <- json \ "data_center"
if (x contains JField("name", JString("cluster2")))
JString(ip) <- cluster \\ "ip" } yield ip
- ips mustEqual List("192.168.2.125", "192.168.2.126")
+ ips must_== List("192.168.2.125", "192.168.2.126")
}
"Total cpus in data center" in {
- (for { JInt(x) <- json \\ "cpus" } yield x) reduceLeft (_ + _) mustEqual 40
+ (for { JInt(x) <- json \\ "cpus" } yield x) reduceLeft (_ + _) must_== 40
}
"Servers sorted by uptime" in {
@@ -56,7 +58,7 @@ object JsonQueryExamples extends Specification("JSON Query Examples") {
JField("uptime", JInt(uptime)) <- server
} yield Server(ip, uptime.longValue)
- servers sortWith (_.uptime > _.uptime) mustEqual List(Server("192.168.1.127", 901214), Server("192.168.2.125", 453423), Server("192.168.2.126", 214312), Server("192.168.1.126", 189822), Server("192.168.1.125", 150123))
+ servers sortWith (_.uptime > _.uptime) must_== List(Server("192.168.1.127", 901214), Server("192.168.2.125", 453423), Server("192.168.2.126", 214312), Server("192.168.1.126", 189822), Server("192.168.1.125", 150123))
}
"Clusters administered by liza" in {
@@ -67,7 +69,7 @@ object JsonQueryExamples extends Specification("JSON Query Examples") {
JField("name", JString(name)) <- cluster
} yield name
- clusters mustEqual List("cluster2")
+ clusters must_== List("cluster2")
}
val json = parse("""
View
20 core/json/src/test/scala/net/liftweb/json/JsonXmlSpec.scala
@@ -17,7 +17,8 @@
package net.liftweb
package json
-import org.specs.{ScalaCheck, Specification}
+import org.specs2.ScalaCheck
+import org.specs2.mutable._
import org.scalacheck.Arbitrary
import org.scalacheck.Prop.forAll
@@ -25,20 +26,21 @@ 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
+ "Valid XML can be converted to JSON and back (symmetric op)" in check { (xml: Node) =>
+ toXml(toJson(xml)).head === xml
}
- "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
+ "JSON can be converted to XML, and back to valid JSON (non symmetric op)" in checkResult { (json: JValue) =>
+ parse(compact(render(toJson(toXml(json)))))
+ success
}
implicit def arbXml: Arbitrary[Node] = Arbitrary(genXml)
implicit def arbJValue: Arbitrary[JValue] = Arbitrary(genObject)
-}
+}
View
13 core/json/src/test/scala/net/liftweb/json/LottoExample.scala
@@ -17,13 +17,14 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable._
/**
* 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
@@ -45,11 +46,11 @@ object LottoExample extends Specification("Lotto Examples") {
(("winner-id" -> w.`winner-id`) ~
("numbers" -> w.numbers))}))
- compact(render(json)) mustEqual """{"lotto":{"id":5,"winning-numbers":[2,45,34,23,7,5,3],"winners":[{"winner-id":23,"numbers":[2,45,34,23,3,5]},{"winner-id":54,"numbers":[52,3,12,11,18,22]}]}}"""
+ compact(render(json)) must_== """{"lotto":{"id":5,"winning-numbers":[2,45,34,23,7,5,3],"winners":[{"winner-id":23,"numbers":[2,45,34,23,3,5]},{"winner-id":54,"numbers":[52,3,12,11,18,22]}]}}"""
- (json \ "lotto" \ "winners")(0).extract[Winner] mustEqual Winner(23, List(2, 45, 34, 23, 3, 5))
+ (json \ "lotto" \ "winners")(0).extract[Winner] must_== Winner(23, List(2, 45, 34, 23, 3, 5))
- (json \ "lotto").extract[Lotto] mustEqual lotto
+ (json \ "lotto").extract[Lotto] must_== lotto
- json.values mustEqual Map("lotto" -> Map("id" -> 5, "winning-numbers" -> List(2, 45, 34, 23, 7, 5, 3), "draw-date" -> None, "winners" -> List(Map("winner-id" -> 23, "numbers" -> List(2, 45, 34, 23, 3, 5)), Map("winner-id" -> 54, "numbers" -> List(52, 3, 12, 11, 18, 22)))))
+ json.values must_== Map("lotto" -> Map("id" -> 5, "winning-numbers" -> List(2, 45, 34, 23, 7, 5, 3), "draw-date" -> None, "winners" -> List(Map("winner-id" -> 23, "numbers" -> List(2, 45, 34, 23, 3, 5)), Map("winner-id" -> 54, "numbers" -> List(52, 3, 12, 11, 18, 22)))))
}
View
10 core/json/src/test/scala/net/liftweb/json/MergeExamples.scala
@@ -17,13 +17,15 @@
package net.liftweb
package json
-import org.specs.Specification
+import org.specs2.mutable._
-object MergeExamples extends Specification("Merge Examples") {
+object MergeExamples extends Specification {
+ "Merge Examples".title
+
"Merge example" in {
- (scala1 merge scala2) mustEqual expectedMergeResult
+ (scala1 merge scala2) must_== expectedMergeResult
}
val scala1 = parse("""
@@ -62,7 +64,7 @@ object MergeExamples extends Specification("Merge Examples") {
}""")
"Lotto example" in {
- (lotto1 merge lotto2) mustEqual mergedLottoResult
+ (lotto1 merge lotto2) must_== mergedLottoResult
}
val lotto1 = parse("""
View
8 core/json/src/test/scala/net/liftweb/json/ParserBugs.scala
@@ -19,16 +19,16 @@ package json
import util.control.Exception._
-import org.specs.Specification
+import org.specs2.mutable._
object ParserBugs extends Specification {
"Unicode ffff is a valid char in string literal" in {
- parseOpt(""" {"x":"\uffff"} """).isDefined mustEqual true
+ parseOpt(""" {"x":"\uffff"} """).isDefined must_== true
}