Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/dsl/functional/roast_dsl_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,39 @@ class RoastDSLExamplesTest < FunctionalTest
assert_empty stderr
end

test "VCR infrastructure works for DSL chat workflows" do
workflow_code = <<~RUBY
# typed: false
# frozen_string_literal: true

#: self as Roast::DSL::Workflow

config do
chat(:test) do
model("gpt-4o")
assume_model_exists!
end
end

execute do
chat(:test) { "What is the deepest lake?" }
end
RUBY

VCR.use_cassette("dsl_vcr_test") do
stdout, stderr = in_sandbox :vcr_test do
File.write("dsl/vcr_test.rb", workflow_code)
result = Roast::DSL::Workflow.from_file("dsl/vcr_test.rb", EMPTY_PARAMS)
File.delete("dsl/vcr_test.rb")
result
end

assert_empty stderr
assert_predicate stdout, :present?
assert_match(/deepest/i, stdout)
end
end

test "simple_repeat.rb workflow runs successfully" do
stdout, stderr = in_sandbox :simple_repeat do
Roast::DSL::Workflow.from_file("dsl/simple_repeat.rb", EMPTY_PARAMS)
Expand Down
15 changes: 15 additions & 0 deletions test/dsl/support/functional_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@ module DSL
class FunctionalTest < ActiveSupport::TestCase
setup do
Roast::Helpers::Logger.reset

# Configure environment variables for VCR testing (same pattern as YAML tests)
# DSL chat cogs respect OPENAI_API_BASE environment variable
unless ENV["RECORD_VCR"]
ENV["OPENAI_API_KEY"] = "dummy-key"
ENV["GOOGLE_API_KEY"] = "dummy-key"
ENV["OPENAI_API_BASE"] = "http://mytestingproxy.local/v1"
end
end

# Set up a temporary sandbox directory with all the examples
# Parameter workflow_id is an arbitrary namespace/subdirectory within the sandbox
# Returns an array of strings [stdio_output, stderr_output]
def in_sandbox(workflow_id, &block)
_run_in_sandbox(workflow_id, &block)
end

private

# Internal helper that sets up sandbox environment
def _run_in_sandbox(workflow_id, &block)
root_project_path = Dir.pwd
examples_source_path = File.join(root_project_path, "dsl")

Expand Down
Loading