Sha256: 8ecf2504c954e9626b75d653279815e096419e59f967109df259edb46f43c614

Contents?: true

Size: 799 Bytes

Versions: 6

Compression:

Stored size: 799 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

module IndexSpec
	
	TestValues = {
		date: Date.today,
		number: 27,
		int: 356192,
		float: 72.362517,
		bool: true,
		# boolean: false,
		# array: [:test1,:test2],
		json: {test1: true, test2: "false"}
	}
	
	TestData = TestValues.inject({}){|acc,(k,v)| acc["a_#{k}".to_sym] = v; acc }
	
	# Delicious pizza!
	class IndexedObject < RedisObject
		
		TestValues.keys.each do |type|
			send(type.to_sym,"a_#{type}".to_sym)
		end
		
		sort_by :a_number
		
	end
	
	describe Seabright::Indices do
		before do
			RedisObject.store.flushdb
		end
		
		it "indexes on integer field" do
			
			5.times do
				obj = IndexedObject.create(a_number: Random.rand(100))
			end
			
			IndexedObject.indexed(:a_number,3,true).count.should eq(3)
			
		end
				
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
redis_object-1.2.3 spec/indices_spec.rb
redis_object-1.2.2 spec/indices_spec.rb
redis_object-1.2.1 spec/indices_spec.rb
redis_object-1.2 spec/indices_spec.rb
redis_object-1.1 spec/indices_spec.rb
redis_object-0.5.0 spec/indices_spec.rb