
import play.api.test._
import play.api.test.Helpers._
import org.specs2.mock._
import controllers.UserController
import org.specs2.mutable.Before
import services.UserService
import play.api.i18n.MessagesApi
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner
import scala.concurrent.Future
import models.User

@RunWith(classOf[JUnitRunner])
class UserControllerUnitSpec extends PlaySpecification with Mockito {
  "UserController" should {
    "render the users page" in {
      val userService = mock[UserService]
      val messagesApi = mock[MessagesApi]
      val controller = new UserController(userService, messagesApi)
      
      userService.findAll() returns Future.successful(
        Seq(User(Some(1), "a@b.com", Some("Tom"), Some("Tommyknocker"))))
      val result = controller.getUsers()(FakeRequest())

      status(result) must equalTo(OK)
      contentAsString(result) must contain("a@b.com")
    }
  }
}
