Sha256: 09d09e7c5ee5d0430d9463b103193a13ee239830340173c2642c7bf741c70e32

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

describe Mongo::Grid::File::Metadata do

  describe '#==' do

    let(:upload_date) do
      Time.now.utc
    end

    let(:metadata) do
      described_class.new(:filename => 'test.txt', :length => 7, :uploadDate => upload_date)
    end

    context 'when the other is not metadata' do

      it 'returns false' do
        expect(metadata).to_not eq('test')
      end
    end

    context 'when the other object is metadata' do

      context 'when the documents are equal' do

        it 'returns true' do
          expect(metadata).to eq(metadata)
        end
      end

      context 'when the documents are not equal' do

        let(:other) do
          described_class.new(:filename => 'testing.txt')
        end

        it 'returns false' do
          expect(metadata).to_not eq(other)
        end
      end
    end
  end

  describe '#initialize' do

    context 'when provided only a filename and length' do

      let(:metadata) do
        described_class.new(:filename => 'test.txt', :length => 7)
      end

      it 'sets the default id' do
        expect(metadata.id).to be_a(BSON::ObjectId)
      end

      it 'sets the upload date' do
        expect(metadata.upload_date).to be_a(Time)
      end

      it 'sets the chunk size' do
        expect(metadata.chunk_size).to eq(Mongo::Grid::File::Chunk::DEFAULT_SIZE)
      end

      it 'sets the content type' do
        expect(metadata.content_type).to eq(Mongo::Grid::File::Metadata::DEFAULT_CONTENT_TYPE)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo-2.0.0.rc spec/mongo/grid/file/metadata_spec.rb
mongo-2.0.0.beta spec/mongo/grid/file/metadata_spec.rb