I just released a new gem, RubyLLM::Test. It makes it easy to test application code that interacts with LLM’s via the RubyLLM gem.
I struggled with how to do this, and after iterating a few times landed on what I think is a clean solution.
RubyLLM::Test.stub_response("Outlook good")
chat = RubyLLM.chat
response = chat.ask "What are the odds this works?"
assert_equal "Outlook good", response.content
If you use RubyLLM, I hope you’ll check this out and it improves your tests.