<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,61 @@
 require File.dirname(__FILE__) + '/spec_helper'
 
-describe &quot;api_cache&quot; do
-  it &quot;should do nothing&quot; do
-    true.should == true
+describe APICache do
+  before :each do
+    APICache.start(APICache::MemoryStore)
+    @key = 'random_key'
+    @data = 'some bit of data'
   end
-end
\ No newline at end of file
+  
+  describe &quot;get method&quot; do
+    it &quot;should fetch data from the cache if the state is :current&quot; do
+      APICache.cache.should_receive(:state).and_return(:current)
+      APICache.cache.should_receive(:get).and_return(@data)
+      
+      APICache.get(@key).should == @data
+    end
+    
+    it &quot;should make new request to API if the state is :refetch&quot; do
+      APICache.cache.should_receive(:state).and_return(:refetch)
+      APICache.api.should_receive(:get).with(@key, 5).and_return(@data)
+      
+      APICache.get(@key).should == @data
+    end
+    
+    it &quot;should return the cached value if the api cannot fetch data and state is :refetch&quot; do
+      APICache.cache.should_receive(:state).and_return(:refetch)
+      APICache.api.should_receive(:get).with(@key, 5).and_raise(APICache::CannotFetch)
+      APICache.cache.should_receive(:get).and_return(@data)
+      
+      APICache.get(@key).should == @data
+    end
+    
+    it &quot;should make new request to API if the state is :invalid&quot; do
+      APICache.cache.should_receive(:state).and_return(:invalid)
+      APICache.api.should_receive(:get).with(@key, 5).and_return(@data)
+      
+      APICache.get(@key).should == @data
+    end
+    
+    it &quot;should raise an exception if the api cannot fetch data and state is :invalid&quot; do
+      APICache.cache.should_receive(:state).and_return(:invalid)
+      APICache.api.should_receive(:get).with(@key, 5).and_raise(APICache::CannotFetch)
+      
+      lambda { APICache.get(@key).should }.should raise_error(APICache::NotAvailableError)
+    end
+    
+    it &quot;should make new request to API if the state is :missing&quot; do
+      APICache.cache.should_receive(:state).and_return(:missing)
+      APICache.api.should_receive(:get).with(@key, 5).and_return(@data)
+      
+      APICache.get(@key).should == @data
+    end
+    
+    it &quot;should raise an exception if the api cannot fetch data and state is :missing&quot; do
+      APICache.cache.should_receive(:state).and_return(:missing)
+      APICache.api.should_receive(:get).with(@key, 5).and_raise(APICache::CannotFetch)
+      
+      lambda { APICache.get(@key).should }.should raise_error(APICache::NotAvailableError)
+    end
+  end
+end</diff>
      <filename>spec/api_cache_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,5 @@
 $TESTING=true
-$:.push File.join(File.dirname(__FILE__), '..', 'lib')
\ No newline at end of file
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')
+require &quot;rubygems&quot;
+require &quot;api_cache&quot;
+require &quot;spec&quot;</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>760fa6e3e2747cdb9977391686ad7e7b6339d202</id>
    </parent>
  </parents>
  <author>
    <name>Martyn Loughran</name>
    <email>martyn@new-bamboo.co.uk</email>
  </author>
  <url>http://github.com/methodmissing/api_cache/commit/6e17b9a61bae708a99c593f7589fd624f8bed387</url>
  <id>6e17b9a61bae708a99c593f7589fd624f8bed387</id>
  <committed-date>2008-06-06T07:19:05-07:00</committed-date>
  <authored-date>2008-06-06T07:19:05-07:00</authored-date>
  <message>Added some basic specs for APICache.get().

The options aren't yet tested and the APICache::API and APICache::Cache are
completely mocked.</message>
  <tree>5d0c0638e2e31247e5a2247457d21559bc84044f</tree>
  <committer>
    <name>Martyn Loughran</name>
    <email>martyn@new-bamboo.co.uk</email>
  </committer>
</commit>
