Sha256: d6e0b1824b3d083850111caeac8de03c6ed54f27f3a73d5d7b112bbc346a856b

Contents?: true

Size: 921 Bytes

Versions: 19

Compression:

Stored size: 921 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
		sort_by :a_bool
		
	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), a_bool: true)
			end
			
			IndexedObject.indexed(:a_number,3,true).count.should eq(3)
			IndexedObject.indexed(:a_number,3,true) do |o|
				o.should be_a(IndexedObject)
			end
			
		end
				
	end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
redis_object-1.4.9 spec/indices_spec.rb
redis_object-1.4.8 spec/indices_spec.rb
redis_object-1.4.7 spec/indices_spec.rb
redis_object-1.4.6 spec/indices_spec.rb
redis_object-1.4.5 spec/indices_spec.rb
redis_object-1.4.3 spec/indices_spec.rb
redis_object-1.4.2 spec/indices_spec.rb
redis_object-1.4.1 spec/indices_spec.rb
redis_object-1.4.0 spec/indices_spec.rb
redis_object-1.3.9 spec/indices_spec.rb
redis_object-1.3.8 spec/indices_spec.rb
redis_object-1.3.7 spec/indices_spec.rb
redis_object-1.3.6 spec/indices_spec.rb
redis_object-1.3.5 spec/indices_spec.rb
redis_object-1.3.4 spec/indices_spec.rb
redis_object-1.3.3 spec/indices_spec.rb
redis_object-1.3.2 spec/indices_spec.rb
redis_object-1.3.1b spec/indices_spec.rb
redis_object-1.3.1 spec/indices_spec.rb