Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed withMods method on WebSpec to simplify usage

Closes #882
  • Loading branch information...
commit dbce4254ccf992ffa7c2de0aa19f2fa77290c862 1 parent ccb6709
@dchenbecker dchenbecker authored
View
10 web/webkit/src/main/scala/net/liftweb/mockweb/WebSpec.scala
@@ -110,7 +110,6 @@ abstract class WebSpec extends Specification {
mockReq.body = text
mockReq.contentType = contentType
mockReq.method = "POST"
- this
}
/**
@@ -119,7 +118,6 @@ abstract class WebSpec extends Specification {
def withPost (jval : JValue) = withMods { mockReq =>
mockReq.body = jval
mockReq.method = "POST"
- this
}
/**
@@ -128,7 +126,6 @@ abstract class WebSpec extends Specification {
def withPost (node : NodeSeq) = withMods { mockReq =>
mockReq.body = node
mockReq.method = "POST"
- this
}
/**
@@ -140,7 +137,6 @@ abstract class WebSpec extends Specification {
mockReq.body = text
mockReq.contentType = contentType
mockReq.method = "PUT"
- this
}
/**
@@ -149,7 +145,6 @@ abstract class WebSpec extends Specification {
def withPut (jval : JValue) = withMods { mockReq =>
mockReq.body = jval
mockReq.method = "PUT"
- this
}
/**
@@ -158,15 +153,14 @@ abstract class WebSpec extends Specification {
def withPut (node : NodeSeq) = withMods { mockReq =>
mockReq.body = node
mockReq.method = "PUT"
- this
}
/**
* Allows you to specify your own modification function for the servlet request
* prior to initialization.
*/
- def withMods [A](f : MockHttpServletRequest => A) : A = req match {
- case r : MockHttpServletRequest => f(r)
+ def withMods (f : MockHttpServletRequest => Unit) : T = req match {
+ case r : MockHttpServletRequest => f(r); this
case _ => throw new IllegalArgumentException("We can only mutate MockHttpServletRequest instances")
}
}
View
4 web/webkit/src/test/scala/net/liftweb/mockweb/WebSpecSpec.scala
@@ -155,6 +155,10 @@ object WebSpecSpec extends WebSpec {
}
}
+ "properly mutate the request" withSFor(testUrl) withMods(_.contentType = "application/xml") in {
+ (S.request.map(_.xml_?) openOr false) must_== true
+ }
+
"process a JSON RestHelper Request" withReqFor("http://foo.com/api/info.json") in { req =>
(WebSpecSpecRest(req)() match {
case Full(JsonResponse(_, _, _, 200)) => true
Please sign in to comment.
Something went wrong with that request. Please try again.