Чтобы сделать запрос и применить его автоматически в каждом тестовом примере, вам нужно использовать Trait AroundExample, чтобы обернуть каждый тест в вызов S.init:
object LiftBoilerplateSpecs extends Specification with AroundExample {
val session = new LiftSession("", randomString(20), Empty)
def makeReq = {
val mockRequest = new MockHttpServletRequest("http://localhost")
mockRequest.headers = Map("User-Agent" -> List("Safari"))
new Req(Req.NilPath, "", GetRequest, Empty, new HTTPRequestServlet(mockRequest, null),
System.nanoTime, System.nanoTime, false,
() => ParamCalcInfo(Nil, Map(), Nil, Empty), Map())
}
def around[T <% Result](t: => T) = S.init(makeReq, session)(t)
"LiftBoilerplate" should {
"add 'no-js' to the class of an html tag element" in {
val snippet = new LiftBoilerplate
val result = snippet.render(<html><head></head><body>test</body></html>)
result must ==/(<html class="no-js"><head></head><body>test</body></html>)
}
}
}