← ClaudeAtlas

coldbox-testing-http-methodslisted

Use this skill when simulating HTTP requests in ColdBox tests using the get(), post(), put(), patch(), delete(), or request() methods, setting request headers (Authorization, Accept, Content-Type), sending JSON request bodies, asserting response status with toHaveStatus(), checking validation errors with toHaveInvalidData(), or understanding the difference between execute() (event-based) and the HTTP method helpers (route/URL-based).
ColdBox/skills · ★ 0 · Testing & QA · score 61
Install: claude install-skill ColdBox/skills
# HTTP Method Testing in ColdBox ## When to Use HTTP Method Helpers vs execute() | Method | What it simulates | Use for | |---|---|---| | `execute( event )` | ColdBox event string (e.g. `"users.index"`) | Directly calling a handler action — no routing | | `get/post/put/patch/delete( route )` | HTTP verb + URL/route | Testing REST APIs, routing, verb constraints | | `request( method, route )` | Generic — any HTTP verb | Non-standard verbs or programmatic verb selection | > `get()`, `post()`, etc. route through the full ColdBox routing layer, so they also test URL mappings and HTTP-method-constrained routes. --- ## Signatures All HTTP helpers share the same parameter set: ```boxlang function get( required string route, // URL or named route struct params = {}, // query string / form params struct headers = {}, // HTTP headers any body = "" // raw request body (string or struct) ) {} // identical signature for post(), put(), patch(), delete() function request( required string method, // HTTP verb required string route, struct params = {}, struct headers = {}, any body = "" ) {} ``` All helpers return the **event/request context** object (same as `execute()`). --- ## GET Requests ```boxlang it( "lists users", () => { var event = get( route = "/api/users" ) expect( event.getResponse() ).toHaveStatus( 200 ) var body = deserializeJSON( event.getRenderedContent() ) expect( body.data