Skip to content

add JRPC::Transport::Test to use in tests#26

Merged
senid231 merged 1 commit into
masterfrom
test-transport
May 29, 2026
Merged

add JRPC::Transport::Test to use in tests#26
senid231 merged 1 commit into
masterfrom
test-transport

Conversation

@senid231

@senid231 senid231 commented May 29, 2026

Copy link
Copy Markdown
Member

closes #10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new in-process transport double JRPC::Transport::Test to the library (not autoloaded), so user code that talks to a JSON-RPC server via SimpleClient/SharedClient can be unit-tested without standing up a real server. The new transport combines the use cases previously served by the spec-only TransportDouble (for SimpleClient) and FakeSharedTransport (for SharedClient), exposing a high-level handler API (on('method') { ... }) plus a low-level escape hatch (push_response / push_raise, strict: false) for malformed/orphan/id-mismatch scenarios. A Unix socketpair backs the transport so SharedClient's IO.select loop works correctly.

Changes:

  • New lib/jrpc/transport/test.rb implementing the Transport::Base contract with handlers, recordings, raw scripting, and FD lifecycle (close keeps FDs alive; shutdown and a GC finalizer release them).
  • New spec/transport/test_spec.rb exercising the transport with both SimpleClient and SharedClient, including strict-mode, error mapping, fail_connect, and notification recording.
  • Documentation in README.md (new "Testing" section) and a CHANGELOG.md entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
lib/jrpc/transport/test.rb New library transport double with handler API, raw escape hatch, socketpair-backed IO.select support, and shutdown/finalizer FD cleanup.
spec/transport/test_spec.rb New spec covering the transport against SimpleClient and SharedClient.
README.md New "Testing" section documenting JRPC::Transport::Test, handlers, strict mode, raw API, and shutdown.
CHANGELOG.md Changelog entry under "New" for the test transport.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/jrpc/transport/test.rb
Comment thread lib/jrpc/transport/test.rb
Comment thread lib/jrpc/transport/test.rb
Comment thread spec/transport/test_spec.rb
@github-actions

Copy link
Copy Markdown
Package Line Rate Branch Rate Complexity Health
jrpc 93% 81% 0
Summary 93% (772 / 834) 81% (234 / 290) 0

@senid231 senid231 merged commit bf062ae into master May 29, 2026
2 checks passed
@senid231 senid231 deleted the test-transport branch May 29, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add test transport

2 participants