discourse/plugins/discourse-ai/spec/evals/agent_prompt_loader_spec.rb
Sam e3fae646d4
DEV: AI persona to agent migration (#38319)
Co-authored-by: Keegan George <kgeorge13@gmail.com>
2026-03-10 15:59:45 +11:00

34 lines
948 B
Ruby
Vendored

# frozen_string_literal: true
require_relative "../../evals/lib/agent_prompt_loader"
RSpec.describe DiscourseAi::Evals::AgentPromptLoader do
subject(:loader) { described_class.new }
let(:tmpdir) { Dir.mktmpdir }
let(:yaml_path) { File.join(tmpdir, "custom.yml") }
before do
File.write(yaml_path, <<~YAML)
key: custom_eval_agent
description: Custom prompt for evals
system_prompt: "Always summarize in one sentence."
YAML
allow(Dir).to receive(:glob).and_return([yaml_path])
end
after { FileUtils.remove_entry(tmpdir) }
it "lists agent keys" do
expect(loader.list).to eq([["custom_eval_agent", "Custom prompt for evals"]])
end
it "returns the system prompt for a key" do
expect(loader.find_prompt("custom_eval_agent")).to eq("Always summarize in one sentence.")
end
it "returns nil when the key is missing" do
expect(loader.find_prompt("missing")).to be_nil
end
end