ctran/annotate_models

Configuration for custom spec directory

Opened this issue · 0 comments

We're breaking apart a monolithic application into discrete business domains and are running into an issue configuring annotate_models to annotate specs under our new file structure. Fortunately we've been able to make this work for models by providing the following configuration:

'model_dir' => "app/models, #{Dir['domains/*/models'].join(', ')}",

However, we'd also like to be able to do this with spec files:

'additional_file_patterns' => Dir['domains/*/spec/models/**/*.rb'],

This matches the files correctly, but incorrectly annotates them (note: the table name ≠ model name):

# == Schema Information
#
# Table name: claim_precertifications
#
#  id                  :bigint           not null, primary key
#  created_at          :datetime         not null
#  updated_at          :datetime         not null
#  claim_id            :bigint
#  precertification_id :bigint
#
# Indexes
#
#  index_claim_precertifications_on_claim_id             (claim_id)
#  index_claim_precertifications_on_precertification_id  (precertification_id)
#
# Foreign Keys
#
#  fk_rails_...  (claim_id => claims.id)
#  fk_rails_...  (precertification_id => precertifications.id)
#
require 'rails_helper'

RSpec.describe CareNetwork::Models::ProviderSelfNomination, type: :model do
  ...

Commands

$ docker compose run --rm app rake annotate_models

Versions

  • annotate (3.2.0)
  • rails (7.0.5)
  • ruby "2.7.6"