Permalink
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...
2 parents 4f4b10a + 7ab295c commit 9ca2c362e13a08859ff15792a320ebf4694a62ff @etorreborre etorreborre committed Mar 20, 2011
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
@@ -17,16 +17,18 @@
package net.liftweb
package actor
-import org.specs.Specification
+import org.specs2.mutable._
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
}
}
@@ -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,37 +156,37 @@ 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
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 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)
}
"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,19 +210,17 @@ 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
Failure("error", Full(new LiftException("broken")), Empty).exception.get must_== new LiftException("broken")
}
"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))
-
-}
-
Oops, something went wrong.

0 comments on commit 9ca2c36

Please sign in to comment.