Permalink
Browse files

lift-webkit

  • Loading branch information...
1 parent 5ab5f45 commit 762f7463cd7708fe69d033190aa619ee014c34b6 @nafg nafg committed Jul 31, 2012
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
@@ -16,15 +16,16 @@
package net.liftweb
package mocks
-import org.specs.Specification
+import org.specs2.mutable.Specification
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"
@@ -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
@@ -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,20 +191,16 @@ 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) {
expectations
}
}
}
- }(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)
- }
+ })
}
}
@@ -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)
@@ -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
}
}
}
@@ -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)
}
}
@@ -17,15 +17,16 @@
package net.liftweb
package http
-import _root_.org.specs.Specification
+import org.specs2.mutable.Specification
import common._
/**
* System under specification for FactoryMaker.
*/
-object FactoryMakerSpec extends Specification("FactoryMaker Specification") {
+object FactoryMakerSpec extends Specification {
+ "FactoryMaker Specification".title
object MyFactory extends Factory {
@@ -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

fmpwizard Aug 20, 2012

Owner

does the success here mean that if

         actor => actor must_== Empty

is not Empty, the test case will pass anyway?

@fmpwizard

fmpwizard Aug 20, 2012

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 via email Aug 23, 2012

Contributor
}
}
@@ -17,15 +17,16 @@
package net.liftweb
package http
-import org.specs.Specification
+import org.specs2.mutable.Specification
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,30 +41,27 @@ 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
}
}
}
"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
}
@@ -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")
@@ -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 {
@@ -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
}
Oops, something went wrong.

1 comment on commit 762f746

Owner

fmpwizard commented on 762f746 Aug 20, 2012

+1

Please sign in to comment.