Sha256: 720e8af177160defe4940473988d268317de1c24bc0916855d9a651ad0fd8ff5

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'rails'
require 'rails/generators'

module Generators
  module DeclareSchema
    module Migration
      RSpec.describe Migrator do
        before do
          ActiveRecord::Base.connection.tables
        end

        subject { described_class.new }

        describe 'format_options' do
          let(:mysql_longtext_limit) { 0xffff_ffff }

          context 'MySQL' do
            before do
              expect(::DeclareSchema::Model::FieldSpec).to receive(:mysql_text_limits?).and_return(true)
            end

            it 'returns text limits' do
              expect(subject.format_options({ limit: mysql_longtext_limit }, :text)).to eq(["limit: #{mysql_longtext_limit}"])
            end
          end

          context 'non-MySQL' do
            before do
              expect(::DeclareSchema::Model::FieldSpec).to receive(:mysql_text_limits?).and_return(false)
            end

            it 'returns text limits' do
              expect(subject.format_options({ limit: mysql_longtext_limit }, :text)).to eq([])
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
declare_schema-0.3.0.pre.1 spec/lib/generators/declare_schema/migration/migrator_spec.rb
declare_schema-0.2.0 spec/lib/generators/declare_schema/migration/migrator_spec.rb