Sha256: c348e9c052a940012e5f52ad3e7486501441c5d85108e3b869aaa143575cf9c5

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

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

module DumpingSpec
	
	class DumpableObject < RedisObject
		
		int :phone
		bool :mailed
		date :canceled_at
				
	end
	
	class GenericObject < RedisObject
		
		json :complex
		
	end
	
	describe Seabright::Triggers do
		before do
			RedisObject.store.flushdb
			5.times do
				d = DumpableObject.create(phone: Random.rand(100)*555, mailed: true, canceled_at: Time.now)
				d << GenericObject.create(complex: {woot: true, ohnoes: false})
			end
		end
		
		it "can dump an object" do
			
			r = DumpableObject.latest.to_yaml
			r.size.should > 100
			
		end
		
		it "can dump to json" do
			
			r = DumpableObject.latest.to_json
			r.size.should > 100
			
		end
		
		it "can dump errthing" do
			
			r = RedisObject.dump_everything(:yml)
			r.size.should > 100
			# r = RedisObject.dump_everything(:json)
			# r.size.should > 100
			
		end
		
		it "can dump a single class" do
			
			r = RedisObject.dump_everything(:yml)
			r.size.should > 100
			d = DumpableObject.dump_all(:yml)
			d.size.should > 100
			d.size.should < r.size
			# r = RedisObject.dump_everything(:json)
			# r.size.should > 100
			
		end
		
		it "can load back in a dump" do
			
			r = RedisObject.dump_everything(:yml)
			r.size.should > 100
			RedisObject.store.flushdb
			RedisObject.load_dump r, :yml
			DumpableObject.latest.generic_objects.count.should eq(1)
			
			# r = RedisObject.dump_everything(:json)
			# r.size.should > 100
			# RedisObject.store.flushdb
			# RedisObject.load_dump r, :json
			# DumpableObject.latest.generic_objects.count.should eq(1)
			
		end
		
	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
redis_object-1.5.1 spec/dumping_spec.rb
redis_object-1.5.0 spec/dumping_spec.rb
redis_object-1.4.9 spec/dumping_spec.rb
redis_object-1.4.8 spec/dumping_spec.rb
redis_object-1.4.7 spec/dumping_spec.rb
redis_object-1.4.6 spec/dumping_spec.rb
redis_object-1.4.5 spec/dumping_spec.rb