Sha256: a8aa62fa9d30f7e4a640dbd5716d5416957a18b0b7f212c6ae7288a85540878d

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

describe MeteorMotion::Collections::Default do
	
	describe 'CRUD tasks' do

		before do
			@coll = MeteorMotion::Collections::Default.new('temp')
		end

		it 'adds an object to the collection and finds it' do
			@coll.add('abc', {a: 1, b:2})
			@coll.find('abc').should.not.be.equal nil
		end

		it 'adds the correct fields to the object' do
			@coll.add('abc', {a: 1, b:2})

			@coll.find('abc')[:a].should.be.equal 1
			@coll.find('abc')[:b].should.be.equal 2
		end

		it 'updates an objects fields' do
			@coll.add('abc', {a: 1, b:2})
			@coll.find('abc')[:a].should.be.equal 1

			@coll.update('abc', {a: 2}, nil)
			@coll.find('abc')[:a].should.be.equal 2
		end

		it 'clears an objects fields' do
			@coll.add('abc', {a: 1, b:2})
			@coll.find('abc')[:a].should.be.equal 1

			@coll.update('abc', nil, [:a])
			@coll.find('abc')[:a].should.be.equal nil
		end

		it 'removes an object from the collection' do
			@coll.add('abc', {a: 1, b:2})

			@coll.remove('abc')
			@coll.find('abc').should.be.equal nil
		end

	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meteor-motion-0.1.0 spec/collections/default_spec.rb