expectNotAllowedMethods function

  1. @experimental
Future<void> expectNotAllowedMethods(
  1. FutureOr<Response> handler(
    1. RequestContext
    ), {
  2. required TestRequestContext contextBuilder(
    1. HttpMethod
    ),
  3. required List<HttpMethod> allowedMethods,
})

Expect that all methods except allowedMethods are not supported.

Implementation

@experimental
Future<void> expectNotAllowedMethods(
  FutureOr<Response> Function(RequestContext) handler, {
  required TestRequestContext Function(HttpMethod) contextBuilder,
  required List<HttpMethod> allowedMethods,
}) async {
  final methods = HttpMethod.values.where((m) => !allowedMethods.contains(m));
  for (final method in methods) {
    final context = contextBuilder(method);
    final response = await handler(context.context);
    expect(response, isMethodNotAllowed);
  }
}