Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. require File.join(File.dirname(__FILE__) , "helpers")
  2.  
  3. def fill_cache(cache)
  4. cache[:key1] = "value1"
  5. cache[:key2] = "value2"
  6. end
  7.  
  8. describe "Waves::Cache" do
  9. before do
  10. cache = Waves::Cache.new
  11. fill_cache cache
  12. end
  13.  
  14. it "can find a value in the cache" do
  15. cache[:key1].should == "value1"
  16. end
  17.  
  18. it "can delete a value from the cache" do
  19. fill_cache cache
  20. cache.delete(:key1)
  21. cache[:key1].should == nil
  22. cache[:key2].should == "value2"
  23. end
  24.  
  25. it "can clear the cache" do
  26. fill_cache cache
  27. cache.clear
  28. cache[:key1].should == nil
  29. cache[:key2].should == nil
  30. end
  31.  
  32. end
  33.  
  34. require 'layers/cache/file_cache'
  35. describe "Waves::Layers::FileCache" do
  36.  
  37. before do
  38. cache = Waves::Layers::FileCache.new('.')
  39. fill_cache cache
  40. end
  41.  
  42. it "can find a value in the cache" do
  43. cache[:key1].should == "value1"
  44. end
  45.  
  46. it "can delete a value from the cache" do
  47. fille_cache cache
  48. cache.delete(:key1)
  49. cache[:key1].should == nil
  50. cache[:key2].should == "value2"
  51. end
  52.  
  53. it "can clear the cache" do
  54. fill_cache cache
  55. cache.clear
  56. cache[:key1].should == nil
  57. cache[:key2].should == nil
  58. end
  59.  
  60. end
Add Comment
Please, Sign In to add comment