Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

lift-webkit

  • Loading branch information...
commit 762f7463cd7708fe69d033190aa619ee014c34b6 1 parent 5ab5f45
@nafg nafg authored
Showing with 136 additions and 135 deletions.
  1. +3 −2 web/testkit/src/test/scala/net/liftweb/http/testing/MockHttpRequestSpec.scala
  2. +1 −1  web/webkit/src/main/scala/net/liftweb/mockweb/MockWeb.scala
  3. +13 −25 web/webkit/src/main/scala/net/liftweb/mockweb/WebSpec.scala
  4. +4 −2 web/webkit/src/test/scala/net/liftweb/builtin/snippet/MsgSpec.scala
  5. +4 −2 web/webkit/src/test/scala/net/liftweb/builtin/snippet/MsgsSpec.scala
  6. +4 −3 web/webkit/src/test/scala/net/liftweb/http/BindingsSpec.scala
  7. +3 −2 web/webkit/src/test/scala/net/liftweb/http/FactoryMakerSpec.scala
  8. +7 −3 web/webkit/src/test/scala/net/liftweb/http/NamedCometPerTabSpec.scala
  9. +5 −7 web/webkit/src/test/scala/net/liftweb/http/ReqSpec.scala
  10. +4 −2 web/webkit/src/test/scala/net/liftweb/http/ResourceServerSpec.scala
  11. +5 −4 web/webkit/src/test/scala/net/liftweb/http/SHtmlSpec.scala
  12. +6 −2 web/webkit/src/test/scala/net/liftweb/http/SnippetSpec.scala
  13. +4 −2 web/webkit/src/test/scala/net/liftweb/http/js/JsExpSpec.scala
  14. +3 −2 web/webkit/src/test/scala/net/liftweb/http/js/extcore/ExtCoreArtifactsSpec.scala
  15. +9 −7 web/webkit/src/test/scala/net/liftweb/http/rest/XMLApiSpec.scala
  16. +6 −4 web/webkit/src/test/scala/net/liftweb/mockweb/MockWebSpec.scala
  17. +13 −16 web/webkit/src/test/scala/net/liftweb/mockweb/WebSpecSpec.scala
  18. +3 −2 web/webkit/src/test/scala/net/liftweb/sitemap/LocSpec.scala
  19. +3 −2 web/webkit/src/test/scala/net/liftweb/sitemap/MenuDSLSpec.scala
  20. +1 −1  web/webkit/src/test/scala/net/liftweb/webapptest/JettyTestServer.scala
  21. +5 −3 web/webkit/src/test/scala/net/liftweb/webapptest/MemoizeSpec.scala
  22. +4 −9 web/webkit/src/test/scala/net/liftweb/webapptest/OneShot.scala
  23. +23 −30 web/webkit/src/test/scala/net/liftweb/webapptest/ToHeadUsages.scala
  24. +3 −2 web/wizard/src/test/scala/net/liftweb/wizard/WizardSpec.scala
View
5 web/testkit/src/test/scala/net/liftweb/http/testing/MockHttpRequestSpec.scala
@@ -16,7 +16,7 @@
package net.liftweb
package mocks
-import org.specs.Specification
+import org.specs2.mutable.Specification
import json.JsonDSL._
@@ -24,7 +24,8 @@ import json.JsonDSL._
/**
* System under specification for MockHttpRequest.
*/
-object MockHttpRequestSpec extends Specification("MockHttpRequest Specification") {
+object MockHttpRequestSpec extends Specification {
+ "MockHttpRequest Specification".title
val IF_MODIFIED_HEADER = "If-Modified-Since"
val TEST_URL = "https://foo.com/test/this/page?a=b&b=a&a=c"
View
2  web/webkit/src/main/scala/net/liftweb/mockweb/MockWeb.scala
@@ -29,7 +29,7 @@ import net.liftweb.mocks.MockHttpServletRequest
import scala.xml.{MetaData,Null}
-import org.specs._
+import org.specs2.mutable._
/**
* The MockWeb object contains various methods to simplify
View
38 web/webkit/src/main/scala/net/liftweb/mockweb/WebSpec.scala
@@ -20,13 +20,13 @@ import javax.servlet.http.HttpServletRequest
import scala.xml.NodeSeq
-import org.specs._
+import org.specs2.mutable._
+import org.specs2.execute.Result
import common.{Box,Empty,Full}
import http._
-import json.JsonAST._
+import net.liftweb.json.JsonAST._
import mocks.MockHttpServletRequest
-import specification.Example
/**
@@ -191,11 +191,8 @@ abstract class WebSpec(boot : () => Any = () => {}) extends Specification {
def this (description : String, url : String, session : Box[LiftSession], contextPath : String) =
this(description, new MockHttpServletRequest(url, contextPath), session)
- def in [T](expectations : => T)(implicit m : scala.reflect.ClassManifest[T]) = {
- val example = exampleContainer.createExample(description)
- if (sequential) example.setSequential()
-
- example.in {
+ def in(expectations : => Result) =
+ exampleFactory newExample(description, {
LiftRulesMocker.devTestLiftRulesInstance.doWith(liftRules) {
MockWeb.useLiftRules.doWith(true) {
MockWeb.testS(req, session) {
@@ -203,8 +200,7 @@ abstract class WebSpec(boot : () => Any = () => {}) extends Specification {
}
}
}
- }(m)
- }
+ })
}
/**
@@ -216,18 +212,14 @@ abstract class WebSpec(boot : () => Any = () => {}) extends Specification {
def this (description : String, url : String, contextPath : String) =
this(description, new MockHttpServletRequest(url, contextPath))
- def in [T](expectations : Req => T)(implicit m : scala.reflect.ClassManifest[T]) = {
- val example = exampleContainer.createExample(description)
- if (sequential) example.setSequential()
-
- example.in {
+ def in(expectations : Req => Result) =
+ exampleFactory newExample(description, {
LiftRulesMocker.devTestLiftRulesInstance.doWith(liftRules) {
MockWeb.useLiftRules.doWith(true) {
MockWeb.testReq(req)(expectations)
}
}
- }(m)
- }
+ })
}
/**
@@ -240,23 +232,19 @@ abstract class WebSpec(boot : () => Any = () => {}) extends Specification {
def this (description : String, url : String, session : Box[LiftSession], contextPath : String) =
this(description, new MockHttpServletRequest(url, contextPath), session)
- def in [T](expectations : Box[NodeSeq] => T)(implicit m : scala.reflect.ClassManifest[T]) = {
- val example = exampleContainer.createExample(description)
- if (sequential) example.setSequential()
-
- example.in {
+ def in(expectations : Box[NodeSeq] => Result) =
+ exampleFactory.newExample(description, {
LiftRulesMocker.devTestLiftRulesInstance.doWith(liftRules) {
MockWeb.useLiftRules.doWith(true) {
MockWeb.testS(req, session) {
S.request match {
case Full(sReq) => expectations(S.runTemplate(sReq.path.partPath))
- case other => fail("Error: withTemplateFor call did not result in " +
+ case other => failure("Error: withTemplateFor call did not result in " +
"request initialization (S.request = " + other + ")")
}
}
}
}
- }(m)
- }
+ })
}
}
View
6 web/webkit/src/test/scala/net/liftweb/builtin/snippet/MsgSpec.scala
@@ -18,7 +18,7 @@ package net.liftweb
package builtin.snippet
import xml._
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import http._
@@ -27,7 +27,9 @@ import http._
/**
* System under specification for Msg.
*/
-object MsgSpec extends Specification("Msg Specification") {
+object MsgSpec extends Specification {
+ "Msg Specification".title
+
def withSession[T](f: => T) : T =
S.initIfUninitted(new LiftSession("test", "", Empty))(f)
View
6 web/webkit/src/test/scala/net/liftweb/builtin/snippet/MsgsSpec.scala
@@ -18,7 +18,7 @@ package net.liftweb
package builtin.snippet
import xml.XML
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import http._
@@ -27,7 +27,8 @@ import http._
/**
* System under specification for Msgs.
*/
-object MsgsSpec extends Specification("Msgs Specification") {
+object MsgsSpec extends Specification {
+ "Msgs Specification".title
def withSession[T](f: => T) : T =
S.initIfUninitted(new LiftSession("test", "", Empty))(f)
@@ -68,6 +69,7 @@ object MsgsSpec extends Specification("Msgs Specification") {
"Properly render AJAX content" in {
// TODO : Figure out how to test this
+ pending
}
}
}
View
7 web/webkit/src/test/scala/net/liftweb/http/BindingsSpec.scala
@@ -18,7 +18,7 @@ package net.liftweb
package http
import xml.{NodeSeq, Text}
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import util.Helpers._
@@ -28,7 +28,8 @@ import Bindings._
/**
* System under specification for Bindings.
*/
-object BindingsSpec extends Specification("Bindings Bindings") {
+object BindingsSpec extends Specification {
+ "Bindings Bindings".title
case class MyClass(str: String, i: Int, other: MyOtherClass)
case class MyOtherClass(foo: String)
@@ -73,7 +74,7 @@ object BindingsSpec extends Specification("Bindings Bindings") {
"Bindings.binder with an available implicit databinding" should {
"allow the application of that databinding to an appropriate object" in {
- MyClass("hi", 1, MyOtherClass("bar")).bind(template) must equalIgnoreSpace(expected)
+ MyClass("hi", 1, MyOtherClass("bar")).bind(template) must beEqualToIgnoringSpace(expected)
}
}
View
5 web/webkit/src/test/scala/net/liftweb/http/FactoryMakerSpec.scala
@@ -17,7 +17,7 @@
package net.liftweb
package http
-import _root_.org.specs.Specification
+import org.specs2.mutable.Specification
import common._
@@ -25,7 +25,8 @@ import common._
/**
* System under specification for FactoryMaker.
*/
-object FactoryMakerSpec extends Specification("FactoryMaker Specification") {
+object FactoryMakerSpec extends Specification {
+ "FactoryMaker Specification".title
object MyFactory extends Factory {
View
10 web/webkit/src/test/scala/net/liftweb/http/NamedCometPerTabSpec.scala
@@ -19,14 +19,15 @@ package http
import js.JsCmds
import xml._
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
/**
* System under specification for NamedComet* files.
*/
-object NamedCometPerTabSpec extends Specification("NamedCometPerTabSpec Specification") {
+object NamedCometPerTabSpec extends Specification {
+ "NamedCometPerTabSpec Specification".title
class CometA extends NamedCometActorTrait{
override def lowPriority = {
@@ -38,7 +39,7 @@ object NamedCometPerTabSpec extends Specification("NamedCometPerTabSpec Specific
}
"A NamedCometDispatcher" should {
- doBefore {
+ step {
val cometA= new CometA{override def name= Full("1")}
cometA.localSetup
@@ -50,16 +51,19 @@ object NamedCometPerTabSpec extends Specification("NamedCometPerTabSpec Specific
NamedCometListener.getDispatchersFor(Full("1")).foreach(
actor => actor.map(_.toString must startWith("net.liftweb.http.NamedCometDispatcher"))
)
+ success
}
"be created even if no comet is present when calling getOrAddDispatchersFor" in {
NamedCometListener.getOrAddDispatchersFor(Full("3")).foreach(
actor => actor.toString must startWith("net.liftweb.http.NamedCometDispatcher")
)
+ success
}
"not be created for a non existing key" in {
NamedCometListener.getDispatchersFor(Full("2")).foreach(
actor => actor must_== Empty
)
+ success
@fmpwizard Owner

does the success here mean that if

         actor => actor must_== Empty

is not Empty, the test case will pass anyway?

@fmpwizard Owner

I pulled this branch locally and verified that having the success is just to make specs2 happy, if there is a failure in the previous line, we get a failed test.

@nafg
nafg added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
}
View
12 web/webkit/src/test/scala/net/liftweb/http/ReqSpec.scala
@@ -17,7 +17,7 @@
package net.liftweb
package http
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
@@ -25,7 +25,8 @@ import common._
/**
* System under specification for Req.
*/
-object ReqSpec extends Specification("Req Specification") {
+object ReqSpec extends Specification {
+ "Req Specification".title
private val iPhoneUserAgents =
List("Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16",
@@ -40,17 +41,15 @@ object ReqSpec extends Specification("Req Specification") {
val uac = new UserAgentCalculator {
def userAgent = Full("Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-HK) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5")
}
-
uac.safariVersion.open_! must_== 5
}
"Do the right thing with iPhone" in {
- iPhoneUserAgents.foreach {
+ iPhoneUserAgents map {
agent => {
val uac = new UserAgentCalculator {
def userAgent = Full(agent)
}
-
uac.isIPhone must_== true
uac.isIPad must_== false
}
@@ -58,12 +57,11 @@ object ReqSpec extends Specification("Req Specification") {
}
"Do the right thing with iPad" in {
- iPadUserAgents.foreach {
+ iPadUserAgents map {
agent => {
val uac = new UserAgentCalculator {
def userAgent = Full(agent)
}
-
uac.isIPhone must_== false
uac.isIPad must_== true
}
View
6 web/webkit/src/test/scala/net/liftweb/http/ResourceServerSpec.scala
@@ -17,12 +17,14 @@
package net.liftweb
package http
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for ResourceServer.
*/
-object ResourceServerSpec extends Specification("ResourceServer Specification") {
+object ResourceServerSpec extends Specification {
+ "ResourceServer Specification".title
+
"ResourceServer.pathRewriter" should {
"default jquery.js to jquery-1.3.2" in {
ResourceServer.pathRewriter("jquery.js"::Nil) must_== List("jquery-1.3.2-min.js")
View
9 web/webkit/src/test/scala/net/liftweb/http/SHtmlSpec.scala
@@ -17,17 +17,18 @@
package net.liftweb
package http
-import org.specs.Specification
+import org.specs2.mutable.Specification
import util._
import Helpers._
import net.liftweb.mockweb.MockWeb._
-object SHtmlSpec extends Specification("NamedCometPerTabSpec Specification") {
+object SHtmlSpec extends Specification {
+ "NamedCometPerTabSpec Specification".title
val html1= <span><input id="number"></input></span>
val inputField1= testS("/")( ("#number" #> SHtml.number(0, println(_), 0, 100))(html1) )
- val inputField2= testS("/")( ("#number" #> SHtml.number(0, println(_), 0, 100, 0.1))(html1) )
- val inputField3= testS("/")( ("#number" #> SHtml.number(0, println(_), 0, 100, 1))(html1) )
+ val inputField2= testS("/")( ("#number" #> SHtml.number(0, println(_: Double), 0, 100, 0.1))(html1) )
+ val inputField3= testS("/")( ("#number" #> SHtml.number(0, println(_: Double), 0, 100, 1))(html1) )
"SHtml" should {
"create a number input field" in {
View
8 web/webkit/src/test/scala/net/liftweb/http/SnippetSpec.scala
@@ -18,7 +18,7 @@ package net.liftweb
package http
import xml._
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import util.Helpers._
@@ -27,7 +27,9 @@ import util.Helpers._
/**
* System under specification for SnippetSpec.
*/
-object SnippetSpec extends Specification("SnippetSpec Specification") {
+object SnippetSpec extends Specification {
+ "SnippetSpec Specification".title
+
def makeReq = new Req(Req.NilPath, "", GetRequest, Empty, null,
System.nanoTime, System.nanoTime, false,
() => ParamCalcInfo(Nil, Map.empty, Nil, Empty), Map())
@@ -366,6 +368,7 @@ object SnippetSpec extends Specification("SnippetSpec Specification") {
ret.open_! must ==/ (<yak/>)
*/
+ pending
}
"Check snippets via run" in {
@@ -381,6 +384,7 @@ object SnippetSpec extends Specification("SnippetSpec Specification") {
(ret.open_! \ "@name").text.length must be > 0
*/
+ pending
}
View
6 web/webkit/src/test/scala/net/liftweb/http/js/JsExpSpec.scala
@@ -18,7 +18,7 @@ package net.liftweb
package http
package js
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import json._
@@ -29,7 +29,9 @@ import util.Helpers._
/**
* System under specification for JsExp.
*/
-object JsExpSpec extends Specification("JsExp Specification") {
+object JsExpSpec extends Specification {
+ "JsExp Specification".title
+
"JsExp" should {
"Deal with lift-json" in {
val json = ("a" -> 4) ~ ("b" -> 44)
View
5 web/webkit/src/test/scala/net/liftweb/http/js/extcore/ExtCoreArtifactsSpec.scala
@@ -19,13 +19,14 @@ package http
package js
package extcore
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* System under specification for ExtCoreArtifacts.
*/
-object ExtCoreArtifactsSpec extends Specification("ExtCoreArtifacts Specification") {
+object ExtCoreArtifactsSpec extends Specification {
+ "ExtCoreArtifacts Specification".title
"ExtCoreArtifacts.toggle" should {
"return the correct javascript expression" in {
View
16 web/webkit/src/test/scala/net/liftweb/http/rest/XMLApiSpec.scala
@@ -20,8 +20,8 @@ package rest
import xml._
-import org.specs.Specification
-import org.specs.matcher.Matcher
+import org.specs2.mutable.Specification
+import org.specs2.matcher.Matcher
import common._
import util.ControlHelpers.tryo
@@ -29,7 +29,8 @@ import util.ControlHelpers.tryo
/**
* System under specification for XMLApi.
*/
-object XmlApiSpec extends Specification("XMLApi Specification") {
+object XmlApiSpec extends Specification {
+ "XMLApi Specification".title
object XMLApiExample extends XMLApiHelper {
// Define our root tag
@@ -83,17 +84,18 @@ object XmlApiSpec extends Specification("XMLApi Specification") {
// A helper to simplify the specs matching
case class matchXmlResponse(expected : Node) extends Matcher[LiftResponse] {
- def apply (response : => LiftResponse) = response match {
+ def apply[T <: LiftResponse](response : org.specs2.matcher.Expectable[T]) = response.value match {
case x : XmlResponse => {
/* For some reason, the UnprefixedAttributes that Lift uses to merge in
* new attributes makes comparison fail. Instead, we simply stringify and
* reparse the response contents and that seems to fix the issue. */
val converted = XML.loadString(x.xml.toString)
- (converted == expected,
+ result(converted == expected,
"%s matches %s".format(converted,expected),
- "%s does not match %s".format(converted, expected))
+ "%s does not match %s".format(converted, expected),
+ response)
}
- case other => (false,"matches","not an XmlResponse")
+ case other => result(false,"matches","not an XmlResponse", response)
}
}
View
10 web/webkit/src/test/scala/net/liftweb/mockweb/MockWebSpec.scala
@@ -18,7 +18,7 @@ package mockweb
import scala.xml.{Null,Text,UnprefixedAttribute}
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import util._
@@ -31,7 +31,9 @@ import mocks.MockHttpServletRequest
* System under specification for MockWeb. This does the double duty as both a spec
* against the MockWeb object as well as an example of how to use it.
*/
-object MockWebSpec extends Specification("MockWeb Specification") {
+object MockWebSpec extends Specification {
+ "MockWeb Specification".title
+
import MockWeb._
/** We can create our own LiftRules instance for the purpose of this spec. In the
@@ -73,8 +75,6 @@ object MockWebSpec extends Specification("MockWeb Specification") {
}
"MockWeb" should {
- shareVariables() // Avoid setting up LiftRules multiple times
-
"provide a Req corresponding to a string url" in {
testReq("http://foo.com/test/this?a=b&a=c", "/test") {
req =>
@@ -144,6 +144,7 @@ object MockWebSpec extends Specification("MockWeb Specification") {
}
}
}
+ success
}
"process S with stateful rewrites" in {
@@ -154,6 +155,7 @@ object MockWebSpec extends Specification("MockWeb Specification") {
}
}
}
+ success
}
"emulate a snippet invocation" in {
View
29 web/webkit/src/test/scala/net/liftweb/mockweb/WebSpecSpec.scala
@@ -69,9 +69,9 @@ object WebSpecSpecRest extends RestHelper {
* WebSpec trait as well as an example of how to use it.
*/
class WebSpecSpec extends WebSpec(WebSpecSpecBoot.boot _) {
- "WebSpec" should {
- setSequential() // This is important for using SessionVars, etc.
+ sequential // This is important for using SessionVars, etc.
+ "WebSpec" should {
val testUrl = "http://foo.com/test/stateless"
val testReq =
@@ -87,7 +87,7 @@ class WebSpecSpec extends WebSpec(WebSpecSpecBoot.boot _) {
"properly set up S with a String url" withSFor(testUrl) in {
S.request match {
case Full(req) => req.path.partPath must_== List("stateless", "works")
- case _ => fail("No request in S")
+ case _ => failure("No request in S")
}
}
@@ -123,7 +123,7 @@ class WebSpecSpec extends WebSpec(WebSpecSpecBoot.boot _) {
req.post_? must_== true
req.body match {
case Full(body) => (new String(body)) must_== "This is a test"
- case _ => fail("No body set")
+ case _ => failure("No body set")
}
}
@@ -133,18 +133,17 @@ class WebSpecSpec extends WebSpec(WebSpecSpecBoot.boot _) {
req.put_? must_== true
req.json match {
case Full(jval) => jval must_== JObject(List(JField("name", JString("Joe"))))
- case _ => fail("No body set")
+ case _ => failure("No body set")
}
}
"properly set an XML body" withSFor(testUrl) withPost(<test/>) in {
S.request match {
- case Full(req) => {
+ case Full(req) =>
req.xml_? must_== true
req.post_? must_== true
req.xml must_== Full(<test/>)
- }
- case _ => fail("No request found in S")
+ case _ => failure("No request found in S")
}
}
@@ -154,16 +153,14 @@ class WebSpecSpec extends WebSpec(WebSpecSpecBoot.boot _) {
"process a JSON RestHelper Request" withReqFor("http://foo.com/api/info.json") in { req =>
(WebSpecSpecRest(req)() match {
- case Full(JsonResponse(_, _, _, 200)) => true
- case other => fail("Invalid response : " + other); false
- }) must_== true
+ case Full(JsonResponse(_, _, _, 200)) => success
+ case other => failure("Invalid response : " + other)
+ })
}
- "properly process a template" withTemplateFor("http://foo.com/net/liftweb/mockweb/webspecspectemplate") in ({
+ "properly process a template" withTemplateFor("http://foo.com/net/liftweb/mockweb/webspecspectemplate") in {
case Full(template) => template.toString.contains("Hello, WebSpec!") must_== true
- case other => {
- fail("Error on template : " + other)
- }
- } : PartialFunction[Box[NodeSeq],Unit])
+ case other => failure("Error on template : " + other)
+ }
}
}
View
5 web/webkit/src/test/scala/net/liftweb/sitemap/LocSpec.scala
@@ -18,13 +18,14 @@ package net.liftweb
package sitemap
import common._
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* Systems under specification for Loc.
*/
-object LocSpec extends Specification("Loc Specification") {
+object LocSpec extends Specification {
+ "Loc Specification".title
case class Param(s: String)
View
5 web/webkit/src/test/scala/net/liftweb/sitemap/MenuDSLSpec.scala
@@ -17,13 +17,14 @@
package net.liftweb
package sitemap
-import org.specs.Specification
+import org.specs2.mutable.Specification
/**
* Systems under specification for Menu DSL.
*/
-object MenuDslSpec extends Specification("Menu DSL Specification") {
+object MenuDslSpec extends Specification {
+ "Menu DSL Specification".title
"The Menu DSL" should {
"allow basic menu definition via '/ path'" in {
View
2  web/webkit/src/test/scala/net/liftweb/webapptest/JettyTestServer.scala
@@ -61,7 +61,7 @@ final class JettyTestServer(baseUrlBox: Box[URL]) {
def running = server_.isRunning
- def browse(startPath: String, f:(WebTester) => Unit) {
+ def browse[A](startPath: String, f:(WebTester) => A): A = {
val wc = new WebTester()
try {
wc.setScriptingEnabled(false)
View
8 web/webkit/src/test/scala/net/liftweb/webapptest/MemoizeSpec.scala
@@ -17,7 +17,7 @@
package net.liftweb
package webapptest
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import util._
@@ -35,9 +35,11 @@ object SessionInfo {
/**
* System under specification for Memoize.
*/
-object MemoizeSpec extends Specification("Memoize Specification") {
- import SessionInfo._
+object MemoizeSpec extends Specification {
+ "Memoize Specification".title
+ sequential
+ import SessionInfo._
"Memoize" should {
"Session memo should default to empty" >> {
View
13 web/webkit/src/test/scala/net/liftweb/webapptest/OneShot.scala
@@ -17,7 +17,7 @@
package net.liftweb
package webapptest
-import org.specs.Specification
+import org.specs2.mutable.Specification
import util._
import http._
@@ -31,6 +31,7 @@ import snippet.Counter
object OneShot extends Specification with RequestKit {
+ sequential
private def reachableLocalAddress = {
val l = InetAddress.getLocalHost
@@ -49,12 +50,9 @@ object OneShot extends Specification with RequestKit {
def baseUrl = jetty.baseUrl.toString
- doBeforeSpec(jetty.start())
+ step(jetty.start())
"ContainerVars" should {
-
- setSequential()
-
"have correct int default" in {
val tmp = LiftRules.sessionCreator
try {
@@ -136,9 +134,6 @@ object OneShot extends Specification with RequestKit {
}
"OneShot" should {
-
- setSequential()
-
"fire once for oneshot" in {
Counter.x = 0
@@ -175,7 +170,7 @@ object OneShot extends Specification with RequestKit {
}
}
- doAfterSpec {
+ step {
tryo {
jetty.stop()
}
View
53 web/webkit/src/test/scala/net/liftweb/webapptest/ToHeadUsages.scala
@@ -19,7 +19,7 @@ package webapptest
import java.net.{URL, InetAddress}
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common.Full
import util._
@@ -29,7 +29,9 @@ import Helpers.tryo
/**
* System under specification for ToHeadUsages.
*/
-object ToHeadUsages extends Specification("ToHeadUsages Specification") {
+object ToHeadUsages extends Specification {
+ "ToHeadUsages Specification".title
+ sequential
private def reachableLocalAddress = {
val l = InetAddress.getLocalHost
@@ -46,53 +48,50 @@ object ToHeadUsages extends Specification("ToHeadUsages Specification") {
private lazy val jetty = new JettyTestServer(Full(baseUrl_))
- doBeforeSpec(jetty.start())
+ step(jetty.start())
"lift <head> merger" should {
- setSequential()
-
"merge <head> from html fragment" in {
jetty.browse(
"/htmlFragmentWithHead", html =>
- html.getElementByXPath("/html/head/script[@id='fromFrag']") must notBeNull.when(jetty.running)
- )
+ html.getElementByXPath("/html/head/script[@id='fromFrag']") must not(beNull when jetty.running))
}
"merge <head> from html fragment does not include head element in body" in {
jetty.browse(
"/htmlFragmentWithHead", html =>
- html.getElementsByXPath("/html/body/script[@id='fromFrag']").size must be_==(0).when(jetty.running)
+ html.getElementsByXPath("/html/body/script[@id='fromFrag']").size must (be_==(0) when jetty.running)
)
}
"merge <head> from snippet" in {
jetty.browse(
"/htmlSnippetWithHead", html =>
- html.getElementByXPath("/html/head/script[@src='snippet.js']") must notBeNull.when(jetty.running)
+ html.getElementByXPath("/html/head/script[@src='snippet.js']") must not(beNull when jetty.running)
)
}
"not merge for bodyless html" in {
jetty.browse(
- "/basicDiv",html => {
- html.getElementById("fruit") must notBeNull.when(jetty.running)
- html.getElementById("bat") must notBeNull.when(jetty.running)
+ "/basicDiv", html => {
+ html.getElementById("fruit") must not(beNull when jetty.running)
+ html.getElementById("bat") must not(beNull when jetty.running)
}
)
}
"not merge for headless bodyless html" in {
jetty.browse(
- "/h1",html => {
- html.getElementById("h1") must notBeNull.when(jetty.running)
+ "/h1", html => {
+ html.getElementById("h1") must not(beNull when jetty.running)
}
)
}
"not merge for headless body html" in {
jetty.browse(
- "/body_no_head",html => {
+ "/body_no_head", html => {
// Note: The XPath expression "html/body/head/div" fails here with
// HtmlUnit 2.5 since "head" is not recognized as a XHTML element
// due to its incorrect position (under body instead of directly under html)
@@ -103,8 +102,8 @@ object ToHeadUsages extends Specification("ToHeadUsages Specification") {
"not merge non-html" in {
jetty.browse(
- "/non_html",html => {
- html.getElementById("frog") must notBeNull.when(jetty.running)
+ "/non_html", html => {
+ html.getElementById("frog") must not(beNull when jetty.running)
}
)
}
@@ -112,9 +111,6 @@ object ToHeadUsages extends Specification("ToHeadUsages Specification") {
}
"pages " should {
-
- setSequential()
-
"Templates should recognize entities" in {
val ns = Templates(List("index")).open_!
val str = AltXML.toXML(ns(0), false, false, false)
@@ -144,29 +140,26 @@ object ToHeadUsages extends Specification("ToHeadUsages Specification") {
}
"deferred snippets" should {
-
- setSequential()
-
"render" in {
jetty.browse(
- "/deferred",html => {
- html.getElementById("second") must notBeNull.when(jetty.running)
+ "/deferred", html => {
+ html.getElementById("second") must not(beNull when jetty.running)
}
)
}
"not deferred not in actor" in {
jetty.browse(
- "/deferred",html => {
- html.getElementByXPath("/html/body/span[@id='whack1']/span[@id='actor_false']") must notBeNull.when(jetty.running)
+ "/deferred", html => {
+ html.getElementByXPath("/html/body/span[@id='whack1']/span[@id='actor_false']") must not(beNull when jetty.running)
}
)
}
"deferred in actor" in {
jetty.browse(
- "/deferred",html => {
- html.getElementByXPath("/html/body/span[@id='whack2']/span[@id='actor_true']") must notBeNull.when(jetty.running)
+ "/deferred", html => {
+ html.getElementByXPath("/html/body/span[@id='whack2']/span[@id='actor_true']") must not(beNull when jetty.running)
}
)
}
@@ -197,7 +190,7 @@ object ToHeadUsages extends Specification("ToHeadUsages Specification") {
}
}
- doAfterSpec {
+ step {
tryo {
jetty.stop()
}
View
5 web/wizard/src/test/scala/net/liftweb/wizard/WizardSpec.scala
@@ -17,7 +17,7 @@
package net.liftweb
package wizard
-import org.specs.Specification
+import org.specs2.mutable.Specification
import common._
import util._
@@ -26,7 +26,8 @@ import http._
/**
* System under specification for Wizard.
*/
-object WizardSpec extends Specification("Wizard Specification") {
+object WizardSpec extends Specification {
+ "Wizard Specification".title
val session: LiftSession = new LiftSession("", Helpers.randomString(20), Empty)

1 comment on commit 762f746

@fmpwizard

does the success here mean that if

         actor => actor must_== Empty

is not Empty, the test case will pass anyway?

@fmpwizard
Owner

+1

@fmpwizard

I pulled this branch locally and verified that having the success is just to make specs2 happy, if there is a failure in the previous line, we get a failed test.

@nafg
Please sign in to comment.
Something went wrong with that request. Please try again.