require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require 'hx' require 'set' describe Hx::Cache do before(:each) do @source = FakeSource.new @source.add_entry('foo', 'BLAH') @source.add_entry('bar', 'EEP') @cache = Hx::Cache.new(@source) end it "should return itself from each_entry" do @cache.each_entry {}.should == @cache end it "enumerates the same entries from the source" do @cache.each_entry do |path, entry| entry.should == @source.get_entry(path) end end it "only reads the source once" do @cache.each_entry {} def @source.each_entry raise RuntimeError, "should not be called" end @cache.each_entry {} end end