From 2f6780969318c08c7a0a0e8e52a7dad33ff53786 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Thu, 22 Jan 2015 20:58:09 +0100 Subject: Bootstrap Play Scala project --- test/ApplicationSpec.scala | 30 ++++++++++++++++++++++++++++++ test/IntegrationSpec.scala | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/ApplicationSpec.scala create mode 100644 test/IntegrationSpec.scala (limited to 'test') diff --git a/test/ApplicationSpec.scala b/test/ApplicationSpec.scala new file mode 100644 index 0000000..6e20bd5 --- /dev/null +++ b/test/ApplicationSpec.scala @@ -0,0 +1,30 @@ +import org.specs2.mutable._ +import org.specs2.runner._ +import org.junit.runner._ + +import play.api.test._ +import play.api.test.Helpers._ + +/** + * Add your spec here. + * You can mock out a whole application including requests, plugins etc. + * For more information, consult the wiki. + */ +@RunWith(classOf[JUnitRunner]) +class ApplicationSpec extends Specification { + + "Application" should { + + "send 404 on a bad request" in new WithApplication{ + route(FakeRequest(GET, "/boum")) must beNone + } + + "render the index page" in new WithApplication{ + val home = route(FakeRequest(GET, "/")).get + + status(home) must equalTo(OK) + contentType(home) must beSome.which(_ == "text/html") + contentAsString(home) must contain ("Your new application is ready.") + } + } +} diff --git a/test/IntegrationSpec.scala b/test/IntegrationSpec.scala new file mode 100644 index 0000000..652edde --- /dev/null +++ b/test/IntegrationSpec.scala @@ -0,0 +1,24 @@ +import org.specs2.mutable._ +import org.specs2.runner._ +import org.junit.runner._ + +import play.api.test._ +import play.api.test.Helpers._ + +/** + * add your integration spec here. + * An integration test will fire up a whole play application in a real (or headless) browser + */ +@RunWith(classOf[JUnitRunner]) +class IntegrationSpec extends Specification { + + "Application" should { + + "work from within a browser" in new WithBrowser { + + browser.goTo("http://localhost:" + port) + + browser.pageSource must contain("Your new application is ready.") + } + } +} -- cgit v1.2.3