discourse/spec/support/shared_examples_for_stats_c...

27 lines
794 B
Ruby
Raw Normal View History

2015-07-07 00:52:19 -04:00
shared_examples_for 'stats cachable' do
describe 'fetch_cached_stats' do
after do
$redis.del(described_class.stats_cache_key)
end
2015-07-07 00:52:19 -04:00
it 'returns the cached stats' do
stats = described_class.fetch_stats.to_json
$redis.set(described_class.stats_cache_key, stats)
expect(described_class.fetch_cached_stats).to eq(JSON.parse(stats))
2015-07-07 00:52:19 -04:00
end
it 'returns fetches the stats if stats has not been cached' do
Timecop.freeze do
$redis.del(described_class.stats_cache_key)
expect(described_class.fetch_cached_stats).to eq(JSON.parse(described_class.fetch_stats.to_json))
end
2015-07-07 00:52:19 -04:00
end
end
describe 'fetch_stats' do
it 'has not been implemented' do
2015-07-07 00:52:19 -04:00
expect{ described_class.fetch_stats }.to_not raise_error
end
end
end