Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Unit tests pass now
Browse files Browse the repository at this point in the history
  • Loading branch information
mslinn committed Feb 24, 2013
1 parent 7400f00 commit 22fa381
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 34 deletions.
3 changes: 2 additions & 1 deletion app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import scala.Some
import play.api.Logger

object Application extends Controller {
val welcomeMsg = "Play Scala File Upload"

def index = Action {
Ok(views.html.index("Your new application is ready."))
Ok(views.html.index(welcomeMsg))
}

def upload = Action(streamingBodyParser) { request =>
Expand Down
9 changes: 1 addition & 8 deletions app/views/index.scala.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
@(message: String)

@main("Play Scala File Upload") {

@main(message) {
@helper.form(action = routes.Application.upload, 'enctype -> "multipart/form-data") {

<input type="file" name="file">
<p><input type="submit"></p>

}



}
21 changes: 7 additions & 14 deletions test/ApplicationSpec.scala
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
package test

import org.specs2.mutable._

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.
*/
class ApplicationSpec extends Specification {

"Application" should {

"send 404 on a bad request" in {
running(FakeApplication()) {
route(FakeRequest(GET, "/boum")) must beNone
route(FakeRequest(GET, "/boum")) must beNone
}
}

"render the index page" in {
running(FakeApplication()) {
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.")
contentAsString(home) must contain (controllers.Application.welcomeMsg)
}
}
}
}
}
13 changes: 2 additions & 11 deletions test/IntegrationSpec.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package test

import org.specs2.mutable._

import play.api.test._
Expand All @@ -10,19 +8,12 @@ import play.api.test.Helpers._
* An integration test will fire up a whole play application in a real (or headless) browser
*/
class IntegrationSpec extends Specification {

"Application" should {

"work from within a browser" in {
running(TestServer(3333), HTMLUNIT) { browser =>

browser.goTo("http://localhost:3333/")

browser.pageSource must contain("Your new application is ready.")

browser.pageSource must contain(controllers.Application.welcomeMsg)
}
}

}

}
}

0 comments on commit 22fa381

Please sign in to comment.