Skip to content

Instantly share code, notes, and snippets.

@kenji0x02
Last active January 27, 2016 15:36
Show Gist options
  • Save kenji0x02/3f990df8e91223df3c5c to your computer and use it in GitHub Desktop.
Save kenji0x02/3f990df8e91223df3c5c to your computer and use it in GitHub Desktop.
Play2Authを使ったときのコントローラーテストミニマム
package controllers.user
import controllers.auth.AuthConfigImpl
import org.specs2.mutable._
import play.api.test._
import play.api.test.Helpers._
import jp.t2v.lab.play2.auth.test.Helpers._
class UserTest extends Specification {
sequential
// Play2AuthのTestを使うための設定
object config extends AuthConfigImpl
"list" should {
"OK for Administrator" in new WithApplication(FakeApplication()) {
// 第二引数はDBのindexを指定
val res = route(FakeRequest(GET, "/user/list").withLoggedIn(config)(1)).get
status(res) must equalTo(OK)
}
}
}
@kenji0x02
Copy link
Author

user情報はDBに登録済みとする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment