Permalink
Browse files

lift-util

  • Loading branch information...
1 parent 6d7ef24 commit 5ab5f45cd0077f9264880b0c6c530366ecf7a14e @nafg nafg committed Jul 30, 2012
Showing with 249 additions and 197 deletions.
  1. +63 −62 core/util/src/test/scala/net/liftweb/util/BasicTypesHelpersSpec.scala
  2. +14 −6 core/util/src/test/scala/net/liftweb/util/BindHelpersSpec.scala
  3. +3 −2 core/util/src/test/scala/net/liftweb/util/BundleBuilderSpec.scala
  4. +8 −7 core/util/src/test/scala/net/liftweb/util/ClassHelpersSpec.scala
  5. +27 −18 core/util/src/test/scala/net/liftweb/util/CombParserHelpersSpec.scala
  6. +11 −4 core/util/src/test/scala/net/liftweb/util/ControlHelpersSpec.scala
  7. +3 −2 core/util/src/test/scala/net/liftweb/util/CssSelectorSpec.scala
  8. +8 −7 core/util/src/test/scala/net/liftweb/util/CurrencyZoneSpec.scala
  9. +4 −3 core/util/src/test/scala/net/liftweb/util/EnumWithDescriptionSpec.scala
  10. +1 −1 core/util/src/test/scala/net/liftweb/util/HelpersSpec.scala
  11. +8 −7 core/util/src/test/scala/net/liftweb/util/Html5ParserSpec.scala
  12. +3 −2 core/util/src/test/scala/net/liftweb/util/HttpHelpersSpec.scala
  13. +3 −2 core/util/src/test/scala/net/liftweb/util/JsonCommandSpec.scala
  14. +13 −12 core/util/src/test/scala/net/liftweb/util/JsonParserSpec.scala
  15. +3 −2 core/util/src/test/scala/net/liftweb/util/ListHelpersSpec.scala
  16. +9 −5 core/util/src/test/scala/net/liftweb/util/MailerSpec.scala
  17. +3 −2 core/util/src/test/scala/net/liftweb/util/PCDataXmlParserSpec.scala
  18. +9 −9 core/util/src/test/scala/net/liftweb/util/ScheduleSpec.scala
  19. +3 −2 core/util/src/test/scala/net/liftweb/util/SecurityHelpersSpec.scala
  20. +12 −9 core/util/src/test/scala/net/liftweb/util/StringHelpersSpec.scala
  21. +14 −9 core/util/src/test/scala/net/liftweb/util/TimeHelpersSpec.scala
  22. +20 −19 core/util/src/test/scala/net/liftweb/util/ToHeadSpec.scala
  23. +4 −3 core/util/src/test/scala/net/liftweb/util/VCardParserSpec.scala
  24. +3 −2 core/util/src/test/scala/net/liftweb/util/XmlParserSpec.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
}
}
@@ -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>)
}
@@ -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 {
@@ -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 }
@fmpwizard

fmpwizard Aug 20, 2012

Owner

I think it's fine but, could we not use success instead of 1 must_== 1 ?

@nafg

nafg Aug 23, 2012

Contributor

IIRC no, because it needed a MatchResult, while success is a Result.
What might be better is:

invokeMethod(null, "", "length").getClass must_== classOf[Failure[_]]

(or if specs2 has a built in way to say that).
At the moment I'm pretty swamped though so I'd rather not bother.

}
"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 }
}
}
Oops, something went wrong.

1 comment on commit 5ab5f45

Owner

fmpwizard commented on 5ab5f45 Aug 20, 2012

done with this commit

Please sign in to comment.