feat(ruby): add Ruby on Rails support (rspec, rubocop, rake, bundle)#724
Merged
pszymkowiak merged 4 commits intortk-ai:developfrom Mar 19, 2026
Merged
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. E2E smoke tests (scripts/test-ruby.sh) covering all 4 commands. 56 new unit tests + 4 inline TOML tests. All 1035 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Navid EMAD <navid.emad@yespark.fr>
Rails' `rake test` ignores positional file args; use `TEST=path` syntax. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Navid EMAD <navid.emad@yespark.fr>
This was referenced Mar 19, 2026
Closed
Integrate ARCHITECTURE.md Ruby Module Architecture section and CLAUDE.md module table/fork-features from PR rtk-ai#643. Update PR description attribution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Navid EMAD <navid.emad@yespark.fr>
8 tasks
PR description lives on GitHub, no need to track in the codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Navid EMAD <navid.emad@yespark.fr>
Collaborator
|
Tested on a real Ruby project with rspec, rubocop, rake, bundler. Results
Savings are low on this small test project (3 specs, 4 files). Expected 60%+ on real Rails projects with hundreds of tests. Quality
Note: rubocop stderr contains cops config warnings (~200 lines) that pass through unfiltered — this is rubocop's behavior when no LGTM — ready to merge. |
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, 4 inline TOML tests, and 23 E2E assertions in
scripts/test-ruby.sh— all 1035 tests passing.New Commands
rtk rspec--format json), text fallback with state-machine parserrtk rubocoprtk rake testrtk bundle installok bundle: completeon successKey Design Decisions (click to expand)
--format jsonfor rspec/rubocop unless user specified-f/--format/-fj/--format=.... Skips in rubocop autocorrect mode (-a,-A).Finished intiming, Capybara screenshots (keeps path only).fallback_tail(). Logs serde error on final fallback.fallback_tail()instead of feeding JSON through the text parser.bundle install/updateusesmatch_outputshort-circuit (90%+ savings on success) — natural fit for TOML DSL over 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)
ruby_exec(tool)bundle execwhenGemfileexists. Transitive deps likerakestill go through bundler.fallback_tail(output, label, n)exit_code_from_output(output, label)128 + signalon Unix.count_tokens(text)Discover Registry: Detection patterns for
rspec,rubocop,rake test,rails test,bundle install/update(withbundle execandbin/variants).Hook Integration
The discover registry now correctly rewrites the following commands:
rtk rspecrspecbundle exec rspecbin/rspecrtk rubocoprubocopbundle exec rubocoprtk rake testrake testrails testbundle exec rake testbundle exec rails testbin/rails testrtk bundle ...bundle installbundle updateHow to Test
Documentation
Attribution
Note
This PR unifies 5 competing implementations. Below is what was taken from each and why.
PR #198 (by @deril) — RSpec only
Incorporated:
#[serde(default)]onbacktracefield — reviewer-requested fix for RSpec versions that omit backtrace from JSON.Not taken: Simpler rspec implementation — superseded by #292/#643's more robust version.
PR #292 (by @navidemad) — RSpec + RuboCop
Incorporated:
rspec_cmd.rs,rubocop_cmd.rs, and shared utils (ruby_exec,fallback_tail,exit_code_from_output,count_tokens)test-ruby.sh) — used as base for the unifiedscripts/test-ruby.shPR #379 (by @navidemad) — Bundle + Rails (TOML DSL hybrid)
Incorporated:
bundle install/update— simpler than a full Rust module for low-savings commandstest-bundle-rails.sh) — contributed the rake test and bundle install sections toscripts/test-ruby.shNot taken: The 7 Rails TOML filters (db:migrate, generate, etc.) — lower savings (10-40%) and tightly coupled to TOML DSL internals. Also
rails_cmd.rsroutes/other routing — too complex for initial merge.PR #534 (by @cosgroveb) — RSpec with parser trait
Incorporated: Improved format flag detection — handles
-fj,-fjson,-fdocumentation,--format=...patterns that the other PRs missed, plus 4 dedicated tests.Not taken:
parsermodule trait-based architecture (adds indirection without benefit for standalone modules), tempfile--outapproach (adds complexity),Gemfile.lockdetection (theGemfilecheck is simpler).PR #643 (by @Maimer) — Most Complete
Incorporated:
rake_cmd.rs(unique to this PR — only implementation of Minitest parsing), discover rules structure (most comprehensive),bundle-install.toml, ARCHITECTURE.md Ruby Module Architecture section and CLAUDE.md module table/fork-features updates. Preferred as base when approaches conflicted.Summary
rspec_cmd.rs+ #534 format detection
+ #198 serde fix
rubocop_cmd.rsrake_cmd.rsbundle-install.toml+ #379 (concept)
utils.rsadditionsdiscover/rules.rsscripts/test-ruby.sh+ #379 (rake/bundle sections)
scripts/test-all.sh(Ruby conditional section)
README.md,CHANGELOG.mdARCHITECTURE.md,CLAUDE.mdCloses #292, #379
Based on work by @deril (#198), @cosgroveb (#534), and @Maimer (#643) — thank you for your contributions.