Skip to content

Conversation

@iamnamananand996
Copy link
Contributor

@iamnamananand996 iamnamananand996 commented Dec 7, 2025

Description

Linear ticket: Closes FER-7955

Implements three improvements to Ruby SDK wire test generation:

  1. Client reuse: The client is now instantiated once in a setup method and stored in @client, following the PHP/Python pattern for better performance
  2. AST-level snippet handling: Replaced fragile regex-based snippet patching with AST-level code generation using a new skipClientInstantiation option
  3. Centralized test utilities: Helper methods are now generated in a shared WireMockTestCase base class (following PHP/Python pattern), reducing code duplication across test files

Link to Devin run: https://app.devin.ai/sessions/6e5c0237738043a1b60de9c92fdae6e1
Requested by: [email protected] (@iamnamananand996)

Changes Made

  • Added skipClientInstantiation option to EndpointSnippetGenerator that generates method calls on existing @client instance variable
  • Updated DynamicSnippetsGenerator.generateSnippetAst to accept and pass through options
  • Refactored WireTestGenerator to:
    • Generate a setup method that creates @client with auth and base_url
    • Use snippetAst instead of string snippets in test cases
    • Remove ~270 lines of regex-based methods (processSnippetForWireMock, injectAuthIntoSnippet, injectBaseUrlIntoRequestOptions, etc.)
    • Inherit from WireMockTestCase instead of Minitest::Test
  • Updated WireTestSetupGenerator to generate wiremock_test_case.rb base class containing:
    • WIREMOCK_BASE_URL and WIREMOCK_ADMIN_URL constants
    • Skip logic for wire tests (RUN_WIRE_TESTS env var check)
    • verify_request_count helper method
    • Docker healthcheck configuration

Testing

  • Lint checks pass (pnpm run check)
  • Compilation succeeds (pnpm compile)
  • Seed tests pass for exhaustive and examples fixtures with wire-tests enabled
  • Generated test files verified to inherit from WireMockTestCase correctly

Human Review Checklist

  • Verify WireMockTestCase base class is generated with correct Ruby syntax and documentation
  • Verify test files properly use require_relative "wiremock_test_case" and inherit from WireMockTestCase
  • Verify auth handling in setup method works for all auth schemes (bearer, header, basic, oauth, inferred)
  • Verify X-Test-Id header is properly passed through request_options in generated tests

…T-level snippet handling

- Add skipClientInstantiation support to Ruby dynamic snippets generator
- Refactor WireTestGenerator to create client once in setup method and reuse across tests
- Replace fragile regex-based snippet patching with AST-level code generation
- Remove processSnippetForWireMock, injectAuthIntoSnippet, injectBaseUrlIntoRequestOptions methods

This follows the PHP/Python pattern for better performance and more robust code generation.

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration bot changed the title feat(ruby-sdk): improve wire test generation with client reuse and AST-level snippet handling feat(ruby): improve wire test generation with client reuse and AST-level snippet handling Dec 7, 2025
@iamnamananand996 iamnamananand996 changed the title feat(ruby): improve wire test generation with client reuse and AST-level snippet handling chore(ruby): improve wire test generation with client reuse and AST-level snippet handling Dec 7, 2025
@devin-ai-integration devin-ai-integration bot changed the title chore(ruby): improve wire test generation with client reuse and AST-level snippet handling feat(ruby): improve wire test generation with client reuse and AST-level snippet handling Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants