Skip to content

Instantly share code, notes, and snippets.

@mielientiev
Created April 27, 2016 11:37
Show Gist options
  • Save mielientiev/9cc4b8cc418e93e625990701f6260ee8 to your computer and use it in GitHub Desktop.
Save mielientiev/9cc4b8cc418e93e625990701f6260ee8 to your computer and use it in GitHub Desktop.
//Controller
import play.api.mvc.{Action, Controller}
class HelloWorldController extends Controller {
def helloWorld() = Action {
Ok("Hello World")
}
}
//Test
import org.scalatestplus.play.{OneAppPerTest, PlaySpec}
import play.api.test.FakeRequest
import play.api.test.Helpers._
class HelloWorldSpec extends PlaySpec with OneAppPerTest {
"HelloWorld controller" should {
"return 'Hello World' string" in {
val page = route(app, FakeRequest(GET, "/")).get
status(page) mustBe OK
contentAsString(page) mustBe "Hello World"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment