Browse files

moneta spec

  • Loading branch information...
1 parent 1778622 commit 25251c6ce871188f004841eb370799cbd12f646c @kristianmandrup committed Nov 23, 2011
Showing with 62 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. BIN lib/cantango/.DS_Store
  3. +28 −0 lib/cantango/configuration/cache.rb
  4. +31 −0 spec/cantango/cache/moneta_spec.rb
View
3 .gitignore
@@ -14,6 +14,9 @@ doc
# jeweler generated
pkg
+.DS_Store
+*/.DS_Store
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
#
# * Create a file at ~/.gitignore
View
BIN lib/cantango/.DS_Store
Binary file not shown.
View
28 lib/cantango/configuration/cache.rb
@@ -0,0 +1,28 @@
+module CanTango
+ class Configuration
+ class Engines
+ class Cache < Engine
+
+ def compile state
+ raise "Must be set to :on or :off" if ![:on, :off].include? state
+ @compile = state
+ end
+
+ def compile?
+ @compile ||= :on
+ @compile == :on
+ end
+
+ def store &block
+ @store ||= ns::Store.new
+ # CanTango::Ability::Cache::MonetaCache
+ @store.default_class ||= CanTango::Ability::Cache::SessionCache
+ yield @store if block
+ @store
+ end
+ end
+ end
+ end
+end
+
+
View
31 spec/cantango/cache/moneta_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+require "moneta/adapters/memory"
+
+shared_examples_for "a read/write Moneta cache" do
+ types = {
+ "String" => ["key", "key2"],
+ "Object" => [{:foo => :bar}, {:bar => :baz}]
+ }
+
+ types.each do |type, (key, key2)|
+ it "reads from keys that are #{type}s like a Hash" do
+ @cache[key].should == nil
+ end
+ end
+end
+
+describe "Moneta::Adapters::Memory" do
+ #class EmptyMiddleware
+ #include Moneta::Middleware
+ #end
+
+ before(:each) do
+ @cache = Moneta::Builder.build do
+ run Moneta::Adapters::Memory
+ end
+ @cache.clear
+ end
+
+ it_should_behave_like "a read/write Moneta cache"
+end

0 comments on commit 25251c6

Please sign in to comment.