Create a gist now

Instantly share code, notes, and snippets.

A complete example of using Around
/**
* For those examples using Around may not be very different from a simple method call with a call-by-name
* parameter.
*
* The only difference is that the http object is a named context that you can compose with other setups, like a Before setup:
*
* http://etorreborre.github.com/specs2/guide/org.specs2.guide.SpecStructure.html#Composing+contexts
*/
class AcceptanceSpec extends Specification { def is =
"This specification has examples which must be executed inside an http session" ^
"Example 1 is executed inside the session" ! http(e1)^
"Example 2 is also executed inside the session" ! http(e2)^
end
def e1 = success
def e2 = success
object http extends Around {
def around[T <% Result](t: =>T) = openHttpSession("test") {
t // execute t inside a http session
}
}
}
class UnitSpec extends org.specs2.mutable.Specification {
"This specification has examples which must be executed inside an http session" >> {
"Example 1 is executed inside the session" >> http {
success
}
"Example 2 is also executed inside the session" >> http {
success
}
}
object http extends Around {
def around[T <% Result](t: =>T) = openHttpSession("test") {
t // execute t inside a http session
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment