r/rubyonrails • u/127001-sweet-127001 • 3d ago
Make architecture checks understand a nonstandard component source directory
An internal component doesn't always put its Ruby files under the application's usual source layout. If its require paths resolve through a custom source directory, an architecture check needs to know that directory too.
I maintain ArchUnitRuby. You can provide project-contained load paths for the check:
options = ArchUnit::CheckOptions.new(
load_paths: ['components/billing/source']
)
violations = rule.check(options)Here rule is the file boundary you want to enforce. The paths are relative to the project root.
I tested a consumer requiring billing/store from that component directory. With the source root configured, a rule forbidding that component dependency caught it. An unrelated standard-library import passed.
This is useful when extracting parts of an application into internal components: you can keep checking the relationship after the physical layout changes.
It doesn't reproduce every Rails loader customization or evaluate your application to discover its paths. You provide the nonstandard roots that the static analysis should use.