Module: Omnibot::Testing

Defined in:
lib/omnibot/testing.rb

Defined Under Namespace

Modules: Helpers Classes: FakeChat, FakeMessage, FakeTokens, FakeToolCall, StubBuilder

Class Method Summary collapse

Class Method Details

.fake!Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/omnibot/testing.rb', line 8

def fake!
  @original_factory ||= Omnibot.chat_factory
  fake = ->(model:, agent_class: nil, **) {
    FakeChat.new(agent_class: agent_class)
  }
  Omnibot.chat_factory = fake
  # Override beats per-agent chat_factory declarations, so specs stay
  # offline even for agents that configure their own factory.
  Omnibot.chat_factory_override = fake
end

.reset!Object



19
20
21
22
23
24
# File 'lib/omnibot/testing.rb', line 19

def reset!
  Omnibot.chat_factory = @original_factory if @original_factory
  @original_factory = nil
  Omnibot.chat_factory_override = nil
  scripts.clear
end

.script_for(agent_class) ⇒ Object



27
# File 'lib/omnibot/testing.rb', line 27

def script_for(agent_class) = scripts[agent_class] ||= []

.scriptsObject



26
# File 'lib/omnibot/testing.rb', line 26

def scripts = @scripts ||= {}