Sha256: c9f817fc5d82e82fe297b47103cf9141228295e51b15e981cb3ec85d8477f713

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require_relative '../../spec_helper'

describe DataMapper::Property::Text do
  before :all do
    @name          = :title
    @type          = described_class
    @load_as       = String
    @value         = 'value'
    @other_value   = 'return value'
    @invalid_value = 1
  end

  it_behaves_like 'A public Property'

  describe '.options' do
    subject { described_class.options }

    it { is_expected.to be_kind_of(Hash) }
    it { is_expected.to eql(load_as: @load_as, dump_as: @load_as, length: 65_535, lazy: true) }
  end

  describe 'migration with an index' do
    supported_by :all do
      before do
        Object.send(:remove_const, :Foo) if Object.const_defined?(:Foo)
        @model = DataMapper::Model.new('Foo') do
          storage_names[:default] = 'anonymous'

          property :id,   DataMapper::Property::Serial
          property :body, DataMapper::Property::Text, :index => true
        end
      end

      it 'allows a migration' do
        expect {
          @model.auto_migrate!
        }.not_to raise_error
      end
    end
  end if defined?(DataObjects::SyntaxError)

  describe 'migration with a unique index' do
    supported_by :all do
      before do

        Object.send(:remove_const, :Foo) if Object.const_defined?(:Foo)
        @model = DataMapper::Model.new('Foo') do
          storage_names[:default] = 'anonymous'

          property :id,   DataMapper::Property::Serial
          property :body, DataMapper::Property::Text, :unique_index => true
        end
      end

      it 'allows a migration' do
        expect {
          @model.auto_migrate!
        }.not_to raise_error
      end
    end
  end if defined?(DataObjects::SyntaxError)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sbf-dm-core-1.3.0 spec/public/property/text_spec.rb
sbf-dm-core-1.3.0.beta spec/public/property/text_spec.rb