org.http4k.hamkrest.response.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4k-testing-hamkrest Show documentation
Show all versions of http4k-testing-hamkrest Show documentation
A set of Hamkrest matchers for common http4k types
package org.http4k.hamkrest
import com.natpryce.hamkrest.Matcher
import com.natpryce.hamkrest.equalTo
import org.http4k.core.Response
import org.http4k.core.Status
import org.http4k.core.cookie.Cookie
import org.http4k.core.cookie.cookies
fun hasStatus(expected: Status): Matcher = httpMessageHas("Status", Response::status, equalTo(expected))
fun hasStatusDescription(expected: String): Matcher =
httpMessageHas("Status description",{ it.status.description }, equalTo(expected))
fun hasSetCookie(expected: Cookie): Matcher = hasSetCookie(expected.name, equalTo(expected))
fun hasSetCookie(name: String, expected: Matcher): Matcher = httpMessageHas("Cookie '$name'", { r: Response -> r.cookies().find { name == it.name }!! }, expected)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy