Sha256: 45eb85a5793dc4c9c03e4ee85a2e0f2254e8c17442de962dbe25456ad3f2e443

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

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

  it_should_behave_like 'A public Property'

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

    it { should be_kind_of(Hash) }

    it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_string, :length => 50) }
  end

  if RUBY_VERSION >= "1.9"
    describe 'encoding' do
      let(:model) do
        Class.new do
          include ::DataMapper::Resource
          property :bin_data, ::DataMapper::Property::Binary
        end
      end

      it 'should always dump with BINARY' do
        model.bin_data.dump("foo".freeze).encoding.names.should include("BINARY")
      end

      it 'should always load with BINARY' do
        model.bin_data.load("foo".freeze).encoding.names.should include("BINARY")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghost_dm-core-1.3.0.beta spec/public/property/binary_spec.rb