title: How can I unit test this Play Scala controller using Specs2?
body: <p>I have the following controller code which connects to a MongoDB instance, retrieves some data then maps the data to a JSON list of friends, how can I unit test it using Specs2? </p>
  
  <pre><code>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 =&gt; Ok(Json.toJson(futureFriendList)) }
    }
  
  }
  </code></pre>