Gut.Test (gut v0.2.0)

Copy Markdown View Source

A deterministic adapter for tests.

Configure it in config/test.exs to prevent tests from making LLM requests:

config :gut, adapter: Gut.Test

The adapter selects the first choice by default. To control calls made by application code, register a stub in the test process:

Gut.Test.stub(fn _subject, question, _choices ->
  if question == "Which team?", do: :technical, else: :billing
end)

The stub must return an offered choice value. Stubs are local to the test process and are visible to tasks started by it. Other processes do not inherit them. Concurrent tests can use different stubs.

Summary

Functions

Registers a choice function for the current test process.

Functions

stub(fun)

@spec stub((String.t(), String.t(), [{String.t(), String.t()}] -> term())) :: :ok

Registers a choice function for the current test process.