diff --git a/lib/lrucache.rb b/lib/lrucache.rb index 735873c..221a63a 100644 --- a/lib/lrucache.rb +++ b/lib/lrucache.rb @@ -13,7 +13,7 @@ def initialize(opts={}) @ttl = Float(opts[:ttl] || 0) @soft_ttl = Float(opts[:soft_ttl] || 0) @retry_delay = Float(opts[:retry_delay] || 0) - raise "max_size must not be negative" if @max_size < 0 + raise "max_size must be greater than 0" if @max_size < 1 raise "ttl must not be negative" if @ttl < 0 raise "soft_ttl must not be negative" if @soft_ttl < 0 raise "retry_delay must not be negative" if @retry_delay < 0 diff --git a/spec/lrucache_spec.rb b/spec/lrucache_spec.rb index 8a1e00e..0e8a2d9 100644 --- a/spec/lrucache_spec.rb +++ b/spec/lrucache_spec.rb @@ -10,8 +10,9 @@ it "should raise an exception if :max_size parameter can't be converted to an integer" do expect { LRUCache.new(:max_size => "moocow") }.to raise_exception end - it "should raise an exception if :max_size parameter is converted to a negative integer" do + it "should raise an exception if :max_size parameter is converted to a non-positive integer" do expect { LRUCache.new(:max_size => -1) }.to raise_exception + expect { LRUCache.new(:max_size => 0) }.to raise_exception end it "should default :default to nil" do