Architecture testing for Ruby

ArchUnitRuby

Build a dependency graph from a Ruby codebase and guard cycles, layers, naming, metrics, slices, and diagrams as ordinary tests. The working prototype ships as the archunit gem and includes source-generated API documentation.

Working previewRuby 3.3+MIT

RubyGems

gem install archunit
architecture_spec.rb
require 'archunit'

RSpec.describe 'architecture' do
  it 'keeps API away from persistence' do
    rule = ArchUnit.project_files
      .in_folder('app/api/**')
      .should_not.depend_on_files
      .in_folder('app/database/**')

    expect(rule).to pass
  end
end

Capabilities

What ArchUnitRuby brings to the test suite.

The family shares a recognizable architecture vocabulary while each implementation stays honest about its language, toolchain, and maturity.

01

File, layer, and slice dependency rules

02

RSpec and Minitest integrations

03

Naming, location, and external-module policies

04

Metrics and dependency graph reports

05

PlantUML adherence and exports

06

Structured violations and custom predicates

Current maturity

Working preview

A working executable prototype published as version 0.0.1 and tested on current Ruby releases.

LanguageRuby
Release0.0.1 preview
RuntimeRuby 3.3+
LicenseMIT

Where it fits

Put boundaries next to the code they protect.

Common starting points for ArchUnitRuby include the following project shapes.

Rails applicationsRuby servicesGemsModular monoliths

Make the first boundary executable.

Add one meaningful rule, run it with the existing tests, and grow the architecture suite as the system reveals where it needs protection.

Start with ArchUnitRuby ↗