Sha256: 3ecc127a31d4f6ad3a2f4811a2d35300d3f5d80387df1e99a7d81c114f919923

Contents?: true

Size: 941 Bytes

Versions: 46

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

require_relative '../../../lib/declare_schema/field_declaration_dsl'

RSpec.describe DeclareSchema::FieldDeclarationDsl do
  let(:model) { TestModel.new }
  subject { declared_class.new(model) }

  context 'Using declare_schema' do
    before do
      load File.expand_path('prepare_testapp.rb', __dir__)

      class TestModel < ActiveRecord::Base
        declare_schema do
          string :name, limit: 127

          timestamps
        end
      end
    end

    it 'has fields' do
      expect(TestModel.field_specs).to be_kind_of(Hash)
      expect(TestModel.field_specs.keys).to eq(['name', 'created_at', 'updated_at'])
      expect(TestModel.field_specs.values.map(&:type)).to eq([:string, :datetime, :datetime])
    end

    it 'stores limits' do
      expect(TestModel.field_specs['name'].limit).to eq(127), TestModel.field_specs['name'].inspect
    end
  end

  # TODO: fill out remaining tests
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
declare_schema-1.4.0 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.11 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.6 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.6.colin.1 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.5 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.5.colin.1 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.9 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.4 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.4.colin.1 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.8 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.3 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.3.colin.1 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.7 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.6 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.5 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.4 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.3 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.2 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.4.0.colin.1 spec/lib/declare_schema/field_declaration_dsl_spec.rb
declare_schema-1.3.2 spec/lib/declare_schema/field_declaration_dsl_spec.rb