14 tests across 4 files covering the gem's public surface:
test/opencode/loading_test.rb (5 tests)
- All 12 gem-provided constants resolve after require
- Transitively-loaded opencode-ruby constants are present
- Opencode::Session source_location points at this gem
- Opencode::Client source_location points at opencode-ruby
- Opencode::Rails::VERSION matches semver
test/opencode/error_reporter_test.rb (3 tests)
- report is no-op without adapter (returns nil)
- report forwards error + opts to adapter
- report works with no kwargs
test/opencode/exchange_test.rb (3 tests)
- Initializes with empty / nil / Array(coerced) messages
- tool_artifacts(exclude:) doesn't raise on empty input
test/opencode/artifact_test.rb (3 tests)
- Filename/content/content_type/metadata readers
- metadata defaults to {} when omitted
- Trust metadata round-trips
Behavioral tests for Session/Turn/MessageArtifacts (AR + ActiveStorage
fixtures) stay in the host application (ajent-rails) where the
integration environment exists. Same pattern as opencode-ruby:
- gem smoke tests prove load-time correctness
- host tests prove integration correctness
27 lines
962 B
Ruby
27 lines
962 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
|
|
# Smoke test for Opencode::Exchange — verifies it instantiates, can be
|
|
# given empty input, and exposes the public surface (`tool_artifacts`).
|
|
# Deeper behavioral tests live in the host application
|
|
# (test/lib/opencode/rails/exchange_test.rb) where AR fixtures, real
|
|
# wire shapes, and the apply-patch event stream are available.
|
|
class Opencode::ExchangeTest < Minitest::Test
|
|
def test_initializes_with_empty_messages
|
|
exchange = Opencode::Exchange.new([])
|
|
assert_equal [], exchange.tool_artifacts
|
|
end
|
|
|
|
def test_initializes_with_nil_messages_via_array_coerce
|
|
exchange = Opencode::Exchange.new(nil)
|
|
assert_equal [], exchange.tool_artifacts
|
|
end
|
|
|
|
def test_tool_artifacts_supports_exclude_kwarg
|
|
exchange = Opencode::Exchange.new([])
|
|
# Should not raise when given an exclude list against empty input.
|
|
assert_equal [], exchange.tool_artifacts(exclude: %w[notes.md])
|
|
end
|
|
end
|