Questo è il mio modello Tag e non so come posso testare la funzionalità Rails.cache.come posso testare la funzione cache rails
class Tag < ActiveRecord::Base
class << self
def all_cached
Rails.cache.fetch("tags.all", :expires_in => 3.hours) do
Tag.order('name asc').to_a
end
end
def find_cached(id)
Rails.cache.fetch("tags/#{id}", :expires_in => 3.hours) do
Tag.find(id)
end
end
end
attr_accessible :name
has_friendly_id :name, :use_slug => true, :approximate_ascii => true
has_many :taggings #, :dependent => :destroy
has_many :projects, :through => :taggings
end
Sai come può essere testato?
E quale archivio cache stai utilizzando nell'ambiente di test? Hai questo in test.env? '' 'config.cache_store =: memory_store''' – knagode
Penso che testare il framework sia perfettamente ok per confermare che funziona nel modo in cui lo capisco. I documenti potrebbero non essere chiari a me, o forse non sono completamente sicuro della mia comprensione. Come con TDD, solo l'atto di scrivere un caso di test può aiutarmi a chiarire esattamente quello che sto cercando di ottenere. –