{"id":13872219,"url":"https://github.com/BinaryBirds/vapor-spec","last_synced_at":"2025-07-16T02:30:33.475Z","repository":{"id":63905916,"uuid":"262351899","full_name":"BinaryBirds/vapor-spec","owner":"BinaryBirds","description":"Unit testing Vapor applications through declarative specifications.","archived":false,"fork":false,"pushed_at":"2023-07-18T10:47:45.000Z","size":20,"stargazers_count":37,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-30T17:21:56.253Z","etag":null,"topics":["tdd","unit-test","vapor","vapor-4","xctest","xctvapor"],"latest_commit_sha":null,"homepage":"https://binarybirds.com","language":"Swift","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BinaryBirds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-05-08T14:57:08.000Z","updated_at":"2024-08-27T23:17:56.000Z","dependencies_parsed_at":"2022-11-28T19:30:25.226Z","dependency_job_id":null,"html_url":"https://github.com/BinaryBirds/vapor-spec","commit_stats":null,"previous_names":["binarybirds/spec"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryBirds%2Fvapor-spec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryBirds%2Fvapor-spec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryBirds%2Fvapor-spec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BinaryBirds%2Fvapor-spec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BinaryBirds","download_url":"https://codeload.github.com/BinaryBirds/vapor-spec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226095608,"owners_count":17572961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tdd","unit-test","vapor","vapor-4","xctest","xctvapor"],"created_at":"2024-08-05T23:00:37.080Z","updated_at":"2024-11-23T20:30:45.593Z","avatar_url":"https://github.com/BinaryBirds.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# VaporSpec\n\nUnit testing [Vapor](https://github.com/vapor/vapor) applications through declarative specifications.\n\n## Install\n\nAdd the repository as a dependency:\n\n```swift\n.package(url: \"https://github.com/binarybirds/vapor-spec\", from: \"2.0.0\"),\n```\n\nAdd VaporSpec to the target dependencies:\n\n```swift\n.product(name: \"VaporSpec\", package: \"vapor-spec\"),\n```\n\nUpdate the packages and you are ready.\n\n## Usage example\n\n### Api\n\n```swift\nimport XCTest\n@testable import VaporSpec\n\nfinal class VaporSpecTests: XCTestCase {\n\n    func testStatusCode() throws {\n        let app = Application(.testing)\n        defer { app.shutdown() }\n\n        try app\n            .spec()\n            .get(\"foo\")\n            .expect(.notFound)\n            .test()\n    }\n    \n    func testHeaderValues() throws {\n        let app = Application(.testing)\n        app.routes.get(\"hello\") { _ in \"hello\" }\n        defer { app.shutdown() }\n\n        try app\n            .spec()\n            .get(\"hello\")\n            .expect(\"Content-Length\", [\"5\"])\n            .expect(\"Content-Type\", [\"text/plain; charset=utf-8\"])\n            .test()\n    }\n    \n    func testContentTypeHeader() throws {\n        let app = Application(.testing)\n        app.routes.get(\"hello\") { _ in \"hello\" }\n        defer { app.shutdown() }\n\n        try app\n            .spec()\n            .get(\"hello\")\n            .expect(\"text/plain; charset=utf-8\")\n            .test()\n    }\n    \n    func testBodyValue() throws {\n        let app = Application(.testing)\n        app.routes.get(\"hello\") { _ in \"hello\" }\n        defer { app.shutdown() }\n\n        try app\n            .spec()\n            .get(\"hello\")\n            .expect(closure: { res in\n                let string = res.body.string\n                XCTAssertEqual(string, \"hello\")\n            })\n            .test()\n    }\n    \n    func testJSON() throws {\n        struct Test: Codable, Content {\n            let foo: String\n            let bar: Int\n            let baz: Bool\n        }\n\n        let app = Application(.testing)\n        app.routes.post(\"foo\") { req in try req.content.decode(Test.self) }\n        defer { app.shutdown() }\n\n        let input = Test(foo: \"foo\", bar: 42, baz: true)\n        try app\n            .spec()\n            .post(\"foo\")\n            .json(input, Test.self) { res in\n                XCTAssertEqual(input.foo, res.foo)\n                XCTAssertEqual(input.bar, res.bar)\n                XCTAssertEqual(input.baz, res.baz)\n            }\n            .test()\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBinaryBirds%2Fvapor-spec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBinaryBirds%2Fvapor-spec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBinaryBirds%2Fvapor-spec/lists"}