Sha256: b1287d12942ff0f8e9fde40e427e2ab3c30573c61759c94391836755a0317d61
Contents?: true
Size: 1.69 KB
Versions: 3
Compression:
Stored size: 1.69 KB
Contents
require 'spec_helper' class Something < Redis::Classy end class Another < Something end module Deep class Klass < Another end end describe "RedisClassy" do before do Redis::Classy.flushdb end after do Redis::Classy.flushdb end after(:all) do Redis::Classy.quit end it "should prepend class name to the key" do Something.set("foo", "bar") Something.keys.should == ["foo"] Redis::Classy.keys.should include "Something:foo" Another.set("foo", "bar") Another.keys.should == ["foo"] Redis::Classy.keys.should include "Another:foo" Deep::Klass.set("foo", "bar") Deep::Klass.keys.should == ["foo"] Redis::Classy.keys.should include "Deep::Klass:foo" end it "should delegate class methods" do Something.get("foo").should == nil Something.set("foo", "bar") Something.get("foo").should == "bar" end it "should delegate instance methods with the key binding" do something = Something.new("foo") something.get.should == nil something.set("bar") something.get.should == "bar" end it "should handle multi block" do something = Something.new("foo") Redis::Classy.multi do something.sadd 1 something.sadd 2 something.sadd 3 end something.smembers.should == ['1','2','3'] end it "should battle against mongoid" do # Emulate notorious Mongoid::Extensions::Object::Conversions class Object def self.get(value) value end end # This would have returned "foo" instead of nil, unless we explicitly defined # class methods from Redis::Namespace::COMMANDS Something.get("foo").should == nil class << Object remove_method :get end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redis-classy-1.1.1 | spec/redis_classy_spec.rb |
redis-classy-1.1.0 | spec/redis_classy_spec.rb |
redis-classy-1.0.2 | spec/redis_classy_spec.rb |