From 8616c70a94945ca8f773e3066853e308de7f1a97 Mon Sep 17 00:00:00 2001 From: Daniel Widgren Date: Thu, 12 Feb 2026 08:57:35 +0100 Subject: [PATCH] feat: add ex_doc config, README, and docs CI step Configure rebar3_ex_doc for hexdocs generation. Add README.md and ex_doc step to CI workflow. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/erlang.yml | 2 ++ README.md | 56 ++++++++++++++++++++++++++++++++++++ rebar.config | 9 ++++++ 3 files changed, 67 insertions(+) create mode 100644 README.md diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 454a011..307d443 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -33,3 +33,5 @@ jobs: run: rebar3 eunit - name: Run CT run: rebar3 ct + - name: Generate docs + run: rebar3 ex_doc diff --git a/README.md b/README.md new file mode 100644 index 0000000..f0cf15a --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# nova_test + +Testing library for [Nova](https://github.com/novaframework/nova) framework applications. + +Provides an HTTP client for integration tests and a mock request builder for unit tests. + +## Installation + +Add `nova_test` to your test dependencies in `rebar.config`: + +```erlang +{profiles, [ + {test, [ + {deps, [ + {nova_test, "~> 0.1"} + ]} + ]} +]}. +``` + +## Usage + +### Integration tests + +Start the application under test and make HTTP requests: + +```erlang +nova_test:start(), +{200, Headers, Body} = nova_test:get("/api/users", #{}). +``` + +### Assertion macros + +Include the header for convenient assertions: + +```erlang +-include_lib("nova_test/include/nova_test.hrl"). + +?assertStatus(200, Response), +?assertJson(#{<<"name">> => <<"alice">>}, Response), +?assertHeader(<<"content-type">>, <<"application/json">>, Response). +``` + +### Mock requests + +Build mock Cowboy requests for unit-testing controllers without HTTP: + +```erlang +Req = nova_test_request:new(<<"GET">>, <<"/users">>), +Req2 = nova_test_request:set_body(Req, <<"{\"name\":\"alice\"}">>), +Result = my_controller:handle(Req2). +``` + +## License + +MIT diff --git a/rebar.config b/rebar.config index 5a0d729..ce6831d 100644 --- a/rebar.config +++ b/rebar.config @@ -4,6 +4,15 @@ {nova, "~> 0.13"} ]}. +{project_plugins, [rebar3_ex_doc]}. + +{hex, [{doc, #{provider => ex_doc}}]}. + +{ex_doc, [{proglang, erlang}, + {main, <<"readme">>}, + {extras, [<<"README.md">>, <<"LICENSE">>]}, + {source_url, <<"https://github.com/novaframework/nova_test">>}]}. + {profiles, [ {test, [ {erl_opts, [debug_info, nowarn_export_all]},