Skip to content

Commit

Permalink
Raises an error if a non-existent cache is accessed
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neighman committed Jun 22, 2008
1 parent 177a0b2 commit 6783a5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/merb-cache/merb-cache.rb
Expand Up @@ -7,6 +7,7 @@ class << self
# value<Hash> : Requires a hash with to describe the cache. See Merb::Cache.register
def [](name)
active_stores
raise Merb::Cache::Store::NotFound, "Could not find the #{name} cache" unless Merb::Cache::Store === @active_stores[name]
@active_stores[name]
end

Expand Down
18 changes: 15 additions & 3 deletions spec/cache_store_spec.rb
Expand Up @@ -51,17 +51,29 @@
lambda do
Merb::Cache.register(:custom_store, :path => "does/not/exist", :class_name => "NotHere")
end.should raise_error(Merb::Cache::Store::NotFound)
Merb::Cache[:custom_store].should be_nil
end

it "should raise an error when accessing a cache that does not exist" do
lambda do
Merb::Cache[:not_there]
end.should raise_error(Merb::Cache::Store::NotFound)
end

it "should setup multiple stores" do
pending "Write it man you lazy bugger"
Merb::Cache.setup(:custom_store1, :memcached)
Merb::Cache.setup(:custom_store2, :mintcache)
Merb::Cache[:custom_store1].should be_a_kind_of(Merb::Cache::MemcachedStore)
Merb::Cache[:custom_store2].should be_a_kind_of(Merb::Cache::MintcachedStore)
end

it "should return the registered_stores" do
pending "Write it you lazy bugger"
Merb::Cache.registered_stores.keys.should include(:memcached, :mintcache)
Merb::Cache.registered_stores[:memcached].keys.should include(:path, :class_name)
Merb::Cache.registered_stores[:mintcache].keys.should include(:path, :class_name)
end



it "should return the active_stores" do
pending "Write it you lazy bugger"
end
Expand Down

0 comments on commit 6783a5e

Please sign in to comment.