Added tests for Repository#build_cache

This commit is contained in:
Yorick Peterse 2016-03-17 18:15:09 +01:00
parent 3d7feeede3
commit dd4b789765
1 changed files with 30 additions and 0 deletions

View File

@ -780,4 +780,34 @@ describe Repository, models: true do
end
end
end
describe '#build_cache' do
let(:cache) { repository.send(:cache) }
it 'builds the caches if they do not already exist' do
expect(cache).to receive(:exist?).
exactly(repository.cache_keys.length).
times.
and_return(false)
repository.cache_keys.each do |key|
expect(repository).to receive(key)
end
repository.build_cache
end
it 'does not build any caches that already exist' do
expect(cache).to receive(:exist?).
exactly(repository.cache_keys.length).
times.
and_return(true)
repository.cache_keys.each do |key|
expect(repository).to_not receive(key)
end
repository.build_cache
end
end
end