Class: RSpec::LLM::Adapters::Fake::Stub

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/llm/adapters/fake.rb

Overview

Builder returned by #respond_to / #respond_to_pattern so callers can chain ‘.with(text)` or `.with { |prompt| … }`.

Instance Method Summary collapse

Constructor Details

#initialize(parent, matcher) ⇒ Stub

Returns a new instance of Stub.



20
21
22
23
# File 'lib/rspec/llm/adapters/fake.rb', line 20

def initialize(parent, matcher)
  @parent = parent
  @matcher = matcher
end

Instance Method Details

#with(text = nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


25
26
27
28
29
30
# File 'lib/rspec/llm/adapters/fake.rb', line 25

def with(text = nil, &block)
  raise ArgumentError, "pass text or a block" if text.nil? && block.nil?

  @parent.send(:register, @matcher, text || block)
  @parent
end