Automatically generating types by running tests
summary
A gem named RBS Trace gem on RubyGems automatically records argument and return classes during tests and inserts RBS comments into method definitions; it uses TracePoint plus binding hacks to get argument values, call_allocations and Prism to detect void usage, and unbound-method tricks to recover ActiveRecord and BasicObject class names. It works on real Rails apps (Redmine, Mastodon), supports RSpec/Minitest and parallel tests via a per-worker .rbs merge workflow, and slows tests by 5.4x and 3.8x locally, 1.5x in CI.
AI-written summary · about
chapters (13)
- 0:00Introduction to talk
- 1:05What is RBS Trace
- 2:37How to use RBS Trace
- 3:22Generating types from tests
- 4:51Testing in Rails apps
- 5:33Performance impact
- 7:25Design and development challenges
- 10:28Implementing the gem
- 11:13Handling basic object classes
- 12:16Active Record relation names
- 14:02Void type handling
- 17:51Parallel test support
- 21:52Future developments
related talks
22mStatic typing with RBS in Ruby
40mAutomated Type Contracts Generation for Ruby
28mA Plan towards Ruby 3 Types
37mChecking Your Types: An Overview of Ruby's Type System
32mThe State of Ruby 3 Typing
53mRuby.inspect
53mAn introduction to typed Ruby programming
22mEnjoy Ruby Programming in IDE and TypeProf
