spec/jruby_memcache_spec.rb in jruby-memcache-client-1.6.1 vs spec/jruby_memcache_spec.rb in jruby-memcache-client-1.7.0
- old
+ new
@@ -1,16 +1,18 @@
require 'java'
require File.dirname(__FILE__) + '/../lib/memcache'
describe MemCache do
- before(:all) do
+ before :all do
@server = "127.0.0.1:11211"
@client = MemCache.new @server
- @client.flush_all
end
- after(:each) do
+ before :each do
+ @client.flush_all
+ end
+ after :each do
@client.flush_all
end
it "should return nil for a non-existent key" do
@client.get('non-existent-key').should be_nil
@@ -34,10 +36,19 @@
it "should work with an explicit pool name" do
@client = MemCache.new([@server], :pool_name => 'new_pool')
@client.pool_name.should == 'new_pool'
end
+
+ it "should work with an error handler" do
+ include_class 'com.meetup.memcached.MemcachedClient'
+ java_memcache_client = mock.as_null_object
+ MemcachedClient.stub!(:new => java_memcache_client)
+ error_handler = Object.new
+ java_memcache_client.should_receive(:error_handler=).with(error_handler)
+ @client = MemCache.new([@server], :error_handler => error_handler)
+ end
end
describe "namespacing" do
before(:each) do
@ns = 'namespace'
@@ -187,10 +198,10 @@
# this test fails w/o the Base64 encoding step
obj = { :foo => 900 }
@client.set('obj', obj)
@client.get('obj').should == obj
end
-
+
it %[should work with binary blobs] do
# this test fails w/o the Base64 encoding step
blob = "\377\330\377\340\000\020JFIF\000\001\001\000\000\001\000\001\000\000\377"
@client.set('blob', blob)
@client.get('blob').should == blob