【发布时间】:2014-04-12 12:21:36
【问题描述】:
我有以下连接到 MongoDB 实例的控制器代码,检索一些数据,然后将数据映射到 JSON 朋友列表,我如何使用 Specs2 对其进行单元测试?
object Friends extends Controller with MongoController {
def collection: JSONCollection = db.collection[JSONCollection]("friends")
def list = Action.async {
val cursor: Cursor[Friend] = collection.find(Json.obj()).cursor[Friend]
val futureFriendList: Future[List[Friend]] = cursor.collect[List]()
futureFriendList.map { friends => Ok(Json.toJson(futureFriendList)) }
}
}
【问题讨论】:
标签: mongodb scala unit-testing playframework playframework-2.0