Trait/Object

org.iainhull.resttest

RestMatchers

Related Docs: object RestMatchers | package resttest

Permalink

trait RestMatchers extends AnyRef

Adds ScalaTest support to the RestTest Dsl.

The should keyword is added to Api.RequestBuilder and Api.Response expressions, the RequestBuilder is executed first and should applied to the Response.

The have keyword supports Extractors.ExtractorLikes. See ExtractorToHavePropertyMatcher for more details.

Example
using (_ url "http://api.rest.org/person") { implicit rb =>
  GET should have (statusCode(Status.OK), jsonBodyAsList[Person] === EmptyList)

  val (status, id) = POST body personJson returning (statusCode, headerText("X-Person-Id"))
  status should be(Status.Created)

  val foo = GET / id should have (statusCode(Status.OK), jsonBodyAs[Person] === Jason)

  GET should have (statusCode === Status.OK, jsonBodyAsList[Person] === Seq(Jason))

  DELETE / id should have (statusCode === Status.OK)

  GET / id should have (statusCode === Status.NotFound)

  GET should have (statusCode(Status.OK), jsonBodyAsList[Person] === EmptyList)
}
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RestMatchers
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit class ExtractorToHavePropertyMatcher[T] extends AnyRef

    Permalink

    Implicitly add operations to Extractors.Extractor that create HavePropertyMatchers.

    Implicitly add operations to Extractors.Extractor that create HavePropertyMatchers.

    This adds support for reusing Extractors in should have(...) expressions, for example

    response should have(statusCode(Status.OK))
  2. implicit class OptionExtractorToHavePropertyMatcher extends HavePropertyMatcher[Dsl.Response, String]

    Permalink

    Implicitly convert an Extractors.Extractor that returns any type of Option into a HavePropertyMatcher.

    Implicitly convert an Extractors.Extractor that returns any type of Option into a HavePropertyMatcher.

    This adds support for reusing Extractor[Option[_]]s in should have(...) expressions, for example

    response should have(header("header2"))
    response should have(body)

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. implicit def extractorToShouldWrapper[T](extractor: Dsl.ExtractorLike[T])(implicit response: Dsl.Response): scalatest.Matchers.AnyShouldWrapper[T]

    Permalink
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. implicit def methodToShouldWrapper(method: Dsl.Method)(implicit builder: Dsl.RequestBuilder, client: Dsl.HttpClient): scalatest.Matchers.AnyShouldWrapper[Dsl.Response]

    Permalink
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. implicit def requestBuilderToShouldWrapper(builder: Dsl.RequestBuilder)(implicit client: Dsl.HttpClient): scalatest.Matchers.AnyShouldWrapper[Dsl.Response]

    Permalink

    Implicitly execute a Api.RequestBuilder and convert the Api.Response into a AnyRefShouldWrapper

    Implicitly execute a Api.RequestBuilder and convert the Api.Response into a AnyRefShouldWrapper

    This adds support for ScalaTest's ShouldMatchers to RequestBuilder

  18. implicit def responseToShouldWrapper(response: Dsl.Response): scalatest.Matchers.AnyShouldWrapper[Dsl.Response]

    Permalink

    Implicitly convert a Api.Response into a AnyRefShouldWrapper

    Implicitly convert a Api.Response into a AnyRefShouldWrapper

    This adds support for ScalaTest's ShouldMatchers to Response

  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  20. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped