Permalink
Browse files

proc should also be converted to string after called

  • Loading branch information...
jaxi committed Jan 26, 2014
1 parent 73232cb commit 860fab173c2903c614c8486ba2062066e7905799
Showing with 8 additions and 3 deletions.
  1. +1 −1 lib/dalli/client.rb
  2. +7 −2 test/test_dalli.rb
View
@@ -354,7 +354,7 @@ def key_without_namespace(key)
end
def namespace
- @options[:namespace].is_a?(Proc) ? @options[:namespace].call : @options[:namespace].to_s
+ @options[:namespace].is_a?(Proc) ? @options[:namespace].call.to_s : @options[:namespace].to_s
end
def normalize_options(opts)
View
@@ -24,9 +24,14 @@
end
end
- it 'namespace attribute should be a string' do
+ it 'return string type for namespace attribute' do
dc = Dalli::Client.new('foo', :namespace => :wunderschoen)
assert_equal "wunderschoen", dc.send(:namespace)
+ dc.close
+
+ dc = Dalli::Client.new('foo', :namespace => Proc.new{:wunderschoen})
+ assert_equal "wunderschoen", dc.send(:namespace)
+ dc.close
end
end
@@ -48,7 +53,7 @@
end
end
- it 'is OK if namespace is a symbol' do
+ it 'allow namespace to be a symbol' do
memcached(19122, '', :namespace => :wunderschoen) do |dc|
dc.set "x" * 251, 1
assert 1, dc.get("#{'x' * 200}:md5:#{Digest::MD5.hexdigest('x' * 251)}")

0 comments on commit 860fab1

Please sign in to comment.