diff --git a/docs/_reference/ecosystem.md b/docs/_reference/ecosystem.md index 9def0c3e6..0fda0fe3d 100644 --- a/docs/_reference/ecosystem.md +++ b/docs/_reference/ecosystem.md @@ -30,6 +30,7 @@ After reading this guide, you will know: * How `RubyLLM::Monitoring` provides dashboards and alerts for RubyLLM activity * How `RubyLLM::RedCandle` enables local model execution from Ruby * How OpenTelemetry instrumentation for RubyLLM provides observability into your LLM applications +* How to test application code by stubbing responses with `RubyLLM::Test` * Where to find community projects and how to contribute your own ## RubyLLM::Schema @@ -282,6 +283,48 @@ For detailed documentation and examples, visit the [RubyLLM::Tribunal repository --- +## RubyLLM::Test + +**Test Application Code by Stubbing LLM Responses** + +[`RubyLLM::Test`](https://github.com/RockSolt/ruby_llm-test) allows you to stub LLM responses in your tests, making it easier to test application logic without relying on calls to external systems. + +### Why Use RubyLLM::Test? + +When writing tests for code that interacts with LLMs, you may want to: + +- Ensure your application logic behaves correctly without making real API calls +- Test edge cases and error handling +- Control the responses from the LLM for deterministic tests + +### Key Features + +- Clear syntax for defining stubs and expected responses +- Support for multiple stubs in a single test +- Validate arguments, such as model or tool calls, passed to the LLM +- Works with RSpec and Minitest + +### Usage + +```ruby +RubyLLM::Test.stub_response("Outlook good") + +chat = RubyLLM.chat +response = chat.ask "What are the odds this works?" + +assert_equal "Outlook good", response.content +``` + +### Installation + +Add the gem to the test group in your Gemfile, or install it directly: + +```bash +gem install ruby_llm-test +``` + +--- + ## Community Projects The RubyLLM ecosystem is growing! If you've built a library or tool that extends RubyLLM, we'd love to hear about it. Consider: