Book Image

Mastering play framework for scala

By : Shiti Saxena
Book Image

Mastering play framework for scala

By: Shiti Saxena

Overview of this book

Table of Contents (21 chapters)
Mastering Play Framework for Scala
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with Play
Index

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 and NoTimeConversions 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 and Status define constants for all the standard HTTP headers and HTTP status codes, respectively...