Skip to content
CAI
Software that uses CAICheck a score

drapergem/draper

61.4

Adequate · 26 September 2026

1.3k

lines of production code

Ruby

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This release delivers a comprehensive architectural overhaul of the Draper gem, introducing a modular design with distinct \Decorator\ and \CollectionDecorator\ classes, alongside a new \LoadStrategy\ for query methods. The update significantly expands test coverage by establishing a full dummy Rails application for integration testing, adding generators for RSpec, Minitest, and Test::Unit, and implementing a performance benchmarking suite. Additionally, the gem modernizes its dependencies for Rails 5.1+ and 6.0 compatibility, including support for Turbo and GlobalID, while streamlining the generator ecosystem by removing legacy templates.

Features

Add MiniTest generators for decorators

The application now includes new generators for MiniTest, specifically adding support for generating decorator tests. This introduces a new \DecoratorGenerator\ that creates test files in \test/decorators\, supporting both the standard test DSL and the spec-style DSL via the \--spec\ option. Two new template files, \decorator\_spec.rb\ and \decorator\_test.rb\, are added to provide the base structure for these tests.

_lib/generators/mini\test · high confidence

Add RSpec generator for decorator specs

Users can now generate RSpec tests for Draper decorators via the new \rspec:decorator\ generator, which creates a corresponding spec file in \spec/decorators/\.

lib/generators/rspec · high confidence

Add Rails generator for creating Decorator classes

Users can now generate a new decorator class in the application using the built-in Rails generator. This new \decorator\_generator\ creates a decorator file in \app/decorators\ with a template that delegates all methods to the wrapped object. The generator supports an optional \--parent\ option to specify the base class (defaulting to \Draper::Decorator\ if available, otherwise falling back to a basic class structure).

lib/generators/rails · high confidence

Add configuration and test infrastructure for the project

The project now includes configuration files for code quality and testing: \.codeclimate.yml\ for static analysis, \.rspec\ for RSpec defaults, \.rubocop.yml\ for Ruby style enforcement, \.yardopts\ for documentation generation, and a \Guardfile\ to automate running specs on file changes. Additionally, the \Rakefile\ has been updated to organize and run the full test suite, including integration tests across different Rails environments.

(repo-wide) · high confidence

Added Bundler-generated binstubs for 'bundle' and 'rake'

The project now includes generated binstubs for 'bundle' and 'rake' in the 'bin' directory. These scripts facilitate running the respective tools with the correct Bundler environment, ensuring consistent dependency resolution and execution contexts for the application.

bin · high confidence

Added Draper install generator for ApplicationDecorator

Users can now run the Draper install generator to automatically create an ApplicationDecorator class in app/decorators/application\_decorator.rb. This provides a base decorator class with a comment template showing how to access helpers, streamlining the initial setup of the Draper gem in a Rails application.

lib/generators/draper · high confidence

Added Test::Unit generator for decorator tests

A new generator has been added to create default decorator tests using the Test::Unit framework. This allows users to generate test files for their decorators via the command line, specifically targeting the 'test/decorators' directory with a 'Test::Unit' style test file.

_lib/generators/test\unit · high confidence

Adds dedicated Rake task for running decorator tests

A new Rake task is introduced to allow users to run tests for decorators specifically. This task, accessible via \rake test:decorators\, executes all test files matching the pattern \test/decorators/\\/\*\_test.rb\ and ensures the test environment is properly prepared. This provides a more granular way to run decorator tests independently of the full test suite.

lib/draper/tasks · high confidence

Major refactoring of the Draper gem architecture

The library has been completely restructured, replacing the old \Draper::Base\ class with a new modular architecture. Key changes include the introduction of \Draper::Decorator\ and \Draper::CollectionDecorator\ to handle singular and collection decoration respectively, and the addition of \Draper::Decoratable\ to provide a convenient \.decorate\ method on model objects. The gem's version has been bumped to 4.0.6.

lib/draper · high confidence

Behavioural changes

Add controller generator hooks for decorators

The controller and scaffold controller generators now include a hook for a 'decorator' component by default. This means that when generating a new controller or scaffold controller, the system will automatically invoke the decorator generator, streamlining the creation of associated decorator classes.

lib/generators · high confidence

Added compatibility patches for Rails 5 API-only apps, Turbo, and GlobalID

Three new compatibility modules were added to the library to improve integration with modern Rails features. For Rails 5 API-only applications, a patch ensures the controller includes \ActionView::Rendering\ while preserving the original \render\_to\_body\ behavior. Integration with \Turbo::Broadcastable\ is improved by overriding \broadcast\_rendering\_with\_defaults\ to ensure decorated objects are passed to partials. Additionally, \GlobalID\ support is added to decorated objects, allowing them to be passed to background jobs and properly deserialized with their decorators applied.

lib/draper/compatibility · high confidence

Refactor Draper core structure and add query method load strategy

The library's main entry point (lib/draper.rb) has been significantly expanded to include explicit dependencies on ActionView, ActiveModel serialization, and ActiveSupport extensions, alongside a comprehensive list of internal module requires. A new LoadStrategy module has been introduced to handle query method loading for ActiveRecord and Mongoid, with the latter currently raising a NotImplementedError. Additionally, the Draper module now defines UninferrableDecoratorError and UninferrableObjectError, and provides setup methods for ActionController and ActionMailer to integrate Draper's view context and helper support.

lib · high confidence

Refactored ViewContext build strategy to support Rails 6.0 and modernize request handling

The ViewContext build strategy has been refactored to support Rails 6.0 and modernize how the view context is constructed. The new \BuildStrategy\ module introduces a \Fast\ strategy that leverages \ActionView::Base\ directly, and a \Full\ strategy that uses \ActionController::TestRequest.create\ instead of the deprecated \.new\ method, ensuring compatibility with Rails 5.1+ and 6.0. This change also allows for custom default controller configuration, improving performance and stability when using Draper outside of a standard controller/view context.

_lib/draper/view\context · high confidence

Removed legacy Draper model template

The template file for generating a Draper model decorator has been removed. This change eliminates the default class structure that previously inherited from \RailsDecorators::Base\, aligning the generator with the updated structure that now inherits from \ApplicationDecorator\.

lib/generators/draper/model/templates · high confidence

Removed obsolete draper:model generator

The draper:model generator, which previously created decorator files in /app/decorators, has been removed from the codebase. This cleanup eliminates the legacy generator template and its associated usage documentation, reflecting a shift away from the older draper:model command in favor of the newer draper:decorator generator.

lib/generators/draper/model · high confidence

Test coverage

Add Rake tasks for running tests and specs; Add Test::Unit generator for decorator tests; Add dummy Rails application for integration testing; Add generator specs for the Decorator generator; Add integration tests for view and mailer contexts; Add test coverage for PostDecorator; Added DummyApp helper for integration testing; Added Minitest and Test::Unit test suites for decorator helpers, Devise integration, and view context isolation; Added Minitest test helper files for the dummy application; Added RSpec template for decorator specs; Added RSpec test configuration for the dummy application; Added Rails 7 dummy app configuration files for testing; Added Rails test dummy bin script; Added asset manifest for Sprockets compatibility; Added comprehensive test coverage for Draper's core components; Added custom RSpec matcher for text assertions; Added database schema and migrations for the dummy application; Added dummy application scaffolding for integration testing; Added dummy application views for integration testing; Added environment configuration files for development, production, and test environments; Added integration tests for decorator functionality; Added integration tests for decorator specs; Added model files for the dummy application; Added performance benchmarking suite for decorator delegation; Added shared examples for Decoratable behavior; Added shared examples for object equality and view helper delegation; Added test coverage for model and job integration; Added test coverage for the InstallGenerator; Added test coverage for the controller generator; Added test fixtures for controllers and mailers; Added test helper job for ActiveJob integration; Added test integration helpers for RSpec, Minitest, and Devise; Added tests for PostMailer; Added tests for ViewContext build strategies; Added view templates for integration tests; Refactored test infrastructure and added code coverage.

Dependencies

Updated runtime and development dependencies for modern Rails and Ruby versions

The gemspec now requires Active Support, Action Pack, Active Model, and Active Model Serializers version 5.0 or higher, and adds a runtime dependency on ruby2\_keywords. Development dependencies have been updated to include ammeter, rake, rspec-rails, minitest-rails, capybara, rubocop, and simplecov. The Gemfile configures conditional dependencies for JRuby and various Ruby versions, including specific SQLite3 versions, Turbo-Rails, and Redis versions, while also adding ostruct for Ruby 4.0+.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.

Score

  • CAI 50 → 61 (+11.6)
  • Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 100 → 99 (-1.4)
  • Architecture 96 → 69 (-26.6)
  • Maturity 61 → 50 (-10.6)
  • Readiness 25 → 64 (+38.7)
  • Security 70 → 87 (+16.3)

Resolved (13)

  • Coverage not measured — test suite did not build
  • Dimension evaluation failed
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Medium: security finding (details withheld)
  • Medium: security finding (details withheld)
  • Medium: security finding (details withheld)
  • No exposed public API
  • No tests found
  • Test reliability not included
  • The README does not mention how to install Draper or where to find the gem dependency in a Gemfile. (README.md)

New (21)

  • Ambiguous distinction between single undecoration and chain undecoration. It is unclear if undecorate handles nested decorators or if undecorate_chain is the only way to fully unwrap. The naming suggests a functional difference but lacks clarity on the boundary condition.
  • FixmeComment (spec/dummy/config/application.rb)
  • Floating git dependency: rails
  • HackComment (spec/dummy/config/application.rb)
  • HackComment (spec/dummy/config/application.rb)
  • High CVE: [GHSA redacted] (Gemfile)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Inconsistent naming pattern for class introspection. object_class and object_class? exist alongside decorator_class. The ? suffix is used for object_class but not for decorator_class (which is a method returning the class, not a boolean). This inconsistency in suffix usage for similar introspection methods is confusing.
  • Medium CVE: [GHSA redacted] (Gemfile)
  • Medium: security finding (details withheld)
  • Medium: security finding (details withheld)
  • Medium: security finding (details withheld)
  • Medium: security finding (details withheld)
  • No dependency advisory monitoring
  • Orphaned files with no living knowledge
  • Redundant methods for checking decorator class. decorator_class? typically implies a boolean check (does it have one?), while decorator_class returns the class. However, having both on the same module creates confusion about when to use which, especially if decorator_class might return nil.
  • Standard Ruby bang/non-bang convention violation or ambiguity. Usually build creates and build! raises on error, or vice versa depending on context. Without seeing bodies, the distinction is unclear, but having both suggests a need for explicit naming if the behavior isn't strictly standard (e.g., build_silent vs build_strict).
  • …and 1 more

Architecture

  • Containers 0 added · 0 removed · contexts 1 added · 0 removed · edges 0 added · 0 removed

Added bounded contexts (1)

  • draper

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

drapergem/draper was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 26 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 7fc015f80ccb1f0aa7b8ffaa7a50db76d0cc946c — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-7c1cb6328e11.