Sha256: 51462a4c56fa3394c6c4e843bd1d4fcee2a19f33e0f63f2336d21630321fbbb7

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

require 'rails_helper'

RSpec.describe 'rake rails_rbi:models', type: :task do
  let!(:generated_dir_path) { Rails.root.join("sorbet", "rails-rbi", "models") }

  it "preloads the Rails environment" do
    expect(task.prerequisites).to include("environment")
  end

  it "generates model files correctly" do
    task.invoke
    expect_files(
      base_dir: generated_dir_path,
      files: [
        'potion.rbi',
        'robe.rbi',
        'school.rbi',
        'spell_book.rbi',
        'squib.rbi',
        'wand.rbi',
        'wizard.rbi',
      ]
    )
    if Object.const_defined?('ActiveStorage')
      expect_files(
        base_dir: generated_dir_path.join('active_storage'),
        files: [
          'attachment.rbi',
          'blob.rbi',
        ],
      )
    end
    if Object.const_defined?('ActiveRecord::InternalMetadata')
      expect_files(
        base_dir: generated_dir_path.join('active_record'),
        files: [
          'internal_metadata.rbi',
          'schema_migration.rbi',
        ]
      )
    end
  end

  it 'generates selected model correctly' do
    task.invoke("Wizard")
    expect_files(
      base_dir: generated_dir_path,
      files: [
        'squib.rbi',
        'wizard.rbi',
      ]
    )
  end

  it 'generates more than 1 selected models correctly' do
    task.invoke("Wizard", "SpellBook")
    expect_files(
      base_dir: generated_dir_path,
      files: [
        'spell_book.rbi',
        'squib.rbi',
        'wizard.rbi',
      ]
    )
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sorbet-rails-0.6.2 spec/rake_rails_rbi_models_spec.rb
sorbet-rails-0.6.1 spec/rake_rails_rbi_models_spec.rb
sorbet-rails-0.6.0 spec/rake_rails_rbi_models_spec.rb
sorbet-rails-0.5.9.1 spec/rake_rails_rbi_models_spec.rb
sorbet-rails-0.5.9 spec/rake_rails_rbi_models_spec.rb