heat
8/7/2015 - 4:49 PM

RequestSpec.scala

import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._
import play.api.libs.ws._

import play.api.test._
import play.api.test.Helpers._

import scala.concurrent.{ExecutionContext, Await}

@RunWith(classOf[JUnitRunner])
class ApplicationSpec extends Specification {
  val ec: ExecutionContext = ExecutionContext.global;

  "A WS Request " should {

    "Return a 404 not found" in new WithApplication{
      // await is from play.api.test.FutureAwaits
      val request = WS.url("http://httpbin.org/status/404").get();
      val result = Helpers.await(request)

      result.status must_==(NOT_FOUND)
    }
  }
}