BodySpecBuilder

Configures request body matching inside RequestSpecificationBuilder.body.

Example:

body {
form {
field("user", "alice")
file("avatar") { filename { it?.endsWith(".png") == true } }
}
bytes { it?.isNotEmpty() == true }
}

Functions

Link copied to clipboard
fun bytes(matcher: Matcher<ByteArray?>)

Matches the raw request body bytes using a Kotest Matcher.

fun bytes(value: ByteArray)

Matches the raw request body bytes exactly.

fun bytes(predicate: (ByteArray?) -> Boolean)

Matches the raw request body bytes using predicate.

Link copied to clipboard
fun contentType(matcher: Matcher<ContentType?>)

Requires the request body content type to satisfy matcher.

fun contentType(contentType: ContentType)
fun contentType(contentType: String)

Requires the request body content type to equal contentType.

Link copied to clipboard
fun form(encoding: FormEncoding = FormEncoding.AUTO, block: FormSpecBuilder.() -> Unit)

Matches an HTML form body.

Link copied to clipboard
fun multipart(contentType: ContentType, block: MultipartSpecBuilder.() -> Unit)

Matches a multipart request by ContentType.

fun multipart(contentType: String, block: MultipartSpecBuilder.() -> Unit)

Matches a multipart request by content type string, such as "multipart/mixed".

Link copied to clipboard
fun predicate(description: String? = null, predicate: (P?) -> Boolean)

Adds a typed request-body predicate in the same body block.

Link copied to clipboard
fun text(matcher: Matcher<String?>)

Matches the raw request body text using a Kotest Matcher.

fun text(predicate: (String?) -> Boolean)

Matches the raw request body text using predicate.

fun text(value: String)

Matches the raw request body text exactly.