Dissecting PlaySpecification
The tests written using Specs2 can also be written as follows:
class UtilSpec extends PlaySpecification {...}
PlaySpecification
is a trait that provides the required helper methods to test a Play application using Specs2. It is defined as:
trait PlaySpecification extends Specification with NoTimeConversions with PlayRunners with HeaderNames with Status with HttpProtocol with DefaultAwaitTimeout with ResultExtractors with Writeables with RouteInvokers with FutureAwaits { }
Let's scan through the API exposed by each of these traits to understand its significance:
Specification
andNoTimeConversions
are traits of Specs2.NoTimeConversions
can be used to deactivate the time conversions.PlayRunners
provides helper methods to execute a block of code in a running application or server with or without specifying the browser.HeaderNames
andStatus
define constants for all the standard HTTP headers and HTTP status codes, respectively...