feat(ruby): add Ruby on Rails support (rspec, rubocop, rake, bundle)#723
Closed
navidemad wants to merge 3 commits intortk-ai:developfrom
Closed
feat(ruby): add Ruby on Rails support (rspec, rubocop, rake, bundle)#723navidemad wants to merge 3 commits intortk-ai:developfrom
navidemad wants to merge 3 commits intortk-ai:developfrom
Conversation
Unifies 5 competing PRs (rtk-ai#198, rtk-ai#292, rtk-ai#379, rtk-ai#534, rtk-ai#643) into a single coherent implementation. New commands: - rtk rspec: JSON parsing with text fallback (60%+ savings) - rtk rubocop: JSON parsing, group by cop/severity (60%+ savings) - rtk rake test: Minitest state machine parser (85-90% savings) - rtk bundle install: TOML filter, strip Using lines (90%+ savings) Shared infrastructure: ruby_exec(), fallback_tail(), exit_code_from_output(), count_tokens() in utils.rs. Discover/rewrite rules for rspec, rubocop, rake, rails, bundle including bundle exec and bin/ variants. 56 new unit tests + 4 inline TOML tests. All 1035 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add scripts/test-ruby.sh — creates a temp Rails app and exercises: - rspec: JSON/text fallback, pending, empty suite, failure caps - rubocop: JSON, autocorrect, offenses, severity ordering - rake test: minitest pass/fail, exit code propagation - bundle install: TOML filter idempotent run - exit code preservation, bundle exec variants, token savings Also add Ruby section to scripts/test-all.sh (rspec, rubocop, rake). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep as local-only reference. Content lives in the PR body on GitHub. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f8242e6 to
dc45389
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unifies 5 competing PRs (#198, #292, #379, #534, #643) into a single coherent Ruby on Rails implementation for RTK.
Adds RSpec, RuboCop, Minitest (via rake/rails test), and Bundler support with 3 new Rust command modules, 1 TOML filter, shared Ruby infrastructure, and automatic discover/rewrite rules.
Includes 56 unit tests across the 3 modules and 4 inline TOML tests — all 1035 tests passing.
New Commands
rtk rspec--format jsonautomatically. Falls back to text parsing when user specifies a custom format.rtk rubocop--format json, groups offenses by cop name and severity. Skips JSON in autocorrect mode (-a,-A).rtk rake testrtk bundle installUsinglines, short-circuits took bundle: completeon success.Key Design Decisions (click to expand)
--format jsonunless user specified-f/--format/-fj/--format=.... Detects autocorrect mode (-a,-A) in rubocop to skip JSON.Finished intiming, and Capybara screenshot details (keeps only path).fallback_tail(). Logs serde error on final fallback for debugging.fallback_tail()instead of feeding JSON through the text parser.bundle install/updatehas simple output with amatch_outputshort-circuit (90%+ savings on success), making it a natural fit for the TOML DSL rather than a full Rust module.saturating_subthroughout, graceful degradation on parse failure.exit_code_from_outputreturns128 + signalon Unix per convention.Shared Infrastructure & Registry (click to expand)
Shared Infrastructure (
utils.rs)ruby_exec(tool)— Auto-detectsbundle execwhenGemfileexists in working directory. Transitive deps likerake(pulled in viarails) still go through bundler for version isolation.fallback_tail(output, label, n)— Last-resort filter fallback showing final N lines with diagnostic logging.exit_code_from_output(output, label)— Signal-aware exit code extraction: returns128 + signalon Unix per convention.count_tokens(text)— Shared test helper for token savings assertions.Discover Registry
rspec,rubocop,rake test,rails test,bundle install/update(withbundle execandbin/variants)bin/rspec,bin/rails test,bundle exec rake testHook Integration
The discover registry now correctly rewrites the following commands:
rtk rspecrspec,bundle exec rspec,bin/rspecrtk rubocoprubocop,bundle exec rubocoprtk rake testrake test,rails test,bundle exec rake test,bundle exec rails test,bin/rails testrtk bundle ...bundle install,bundle updateHow to Test
Attribution
Note
This PR unifies 5 competing implementations. Below is what was taken from each and why.
PR #198 (by @deril) — RSpec only
#[serde(default)]onbacktracefield — reviewer-requested fix for RSpec versions that omit backtrace from JSONPR #292 (by @navidemad) — RSpec + RuboCop
rspec_cmd.rs,rubocop_cmd.rs, and shared utils (ruby_exec,fallback_tail,exit_code_from_output,count_tokens) — the most mature implementations with noise-stripping regex, 3-tier JSON fallback, state-machine text parser, and signal-aware exit codes. E2E smoke test script (test-ruby.sh) used as base for the unified E2E script.PR #379 (by @navidemad) — Bundle + Rails (TOML DSL hybrid)
bundle install/update— simpler than a full Rust module for low-savings commands. E2E smoke test script (test-bundle-rails.sh) contributed the rake test and bundle install E2E sections.rails_cmd.rsroutes/other routing — too complex for initial mergePR #534 (by @cosgroveb) — RSpec with parser trait
-fj,-fjson,-fdocumentation,--format=...patterns that the other PRs missed, plus 4 dedicated testsparsermodule trait-based architecture (adds indirection without benefit for standalone modules), tempfile--outapproach (adds complexity and temp file cleanup),Gemfile.lockdetection (theGemfilecheck is simpler and covers the same cases)PR #643 (by @Maimer) — Most Complete
rake_cmd.rs(unique to this PR — only implementation of Minitest parsing), discover rules structure (most comprehensive),bundle-install.toml. Preferred as base when approaches conflicted.Summary
rspec_cmd.rsrubocop_cmd.rsrake_cmd.rsbundle-install.tomlutils.rsadditionsdiscover/rules.rsscripts/test-ruby.shscripts/test-all.shCloses #292, #379
Based on work by @deril (#198), @cosgroveb (#534), and @Maimer (#643) — thank you for your contributions.