Potenial fix for 'marshal data too short' error - Ref #685

This commit is contained in:
erwanlr
2014-09-11 20:04:24 +02:00
parent f89463c4d8
commit a6b0548426
2 changed files with 22 additions and 8 deletions

View File

@@ -41,9 +41,25 @@ describe CacheFileStore do
end
end
describe '#read_entry (nonexistent entry)' do
it 'should return nil' do
expect(@cache.read_entry(Digest::SHA1.hexdigest('hello world'))).to be_nil
describe '#read_entry' do
after { expect(@cache.read_entry(key)).to eq @expected }
context 'when the entry does not exist' do
let(:key) { Digest::SHA1.hexdigest('hello world') }
it 'should return nil' do
@expected = nil
end
end
context 'when the file exist but is empty (marshal data too short error)' do
let(:key) { 'empty-file' }
it 'returns nil' do
File.new(File.join(@cache.storage_path, key), File::CREAT)
@expected = nil
end
end
end