Module: RSpec::LLM::Helpers

Defined in:
lib/rspec/llm/helpers.rb

Overview

Methods mixed into example groups via RSpec.configure (see rspec.rb).

Instance Method Summary collapse

Instance Method Details

#llmObject

The configured client wrapped as an Adapter. Returns nil if not configured.



8
9
10
# File 'lib/rspec/llm/helpers.rb', line 8

def llm
  RSpec::LLM.client
end

#stub_llm {|fake| ... } ⇒ Object

Configure a Fake adapter and yield it for stubbing. Replaces the global client for the duration of the example. After the example RSpec::LLM is reset via the ‘after` hook installed in rspec.rb.

Yields:

  • (fake)


15
16
17
18
19
20
# File 'lib/rspec/llm/helpers.rb', line 15

def stub_llm
  fake = RSpec::LLM::Adapters::Fake.new
  yield fake if block_given?
  RSpec::LLM.configuration.client = fake
  fake
end

#stub_llm_judge {|fake| ... } ⇒ Object

Same, but installs the fake as the judge.

Yields:

  • (fake)


23
24
25
26
27
28
# File 'lib/rspec/llm/helpers.rb', line 23

def stub_llm_judge
  fake = RSpec::LLM::Adapters::Fake.new
  yield fake if block_given?
  RSpec::LLM.configuration.judge = fake
  fake
end