Sha256: aee6c00ccc638a2fa017fe4109dee1cfd7ec98d7d6493b99a45fc717399537ac
Contents?: true
Size: 1004 Bytes
Versions: 55
Compression:
Stored size: 1004 Bytes
Contents
module Ddr::Models RSpec.describe WithContentFile do let(:obj) { FactoryGirl.create(:component) } before { obj.content.checksumType = "SHA-1" obj.save! } it "yields a temp file path to the block and deletes the temp file afterwards" do WithContentFile.new(obj) do |path| @path = path expect(File.exist?(path)).to be true end expect(File.exist?(@path)).to be false end it "deletes the temp file even when an exception is raised in the block" do begin WithContentFile.new(obj) do |path| @path = path expect(File.exist?(path)).to be true raise Error, "error" end rescue Error expect(File.exist?(@path)).to be false end end it "raises an exception when the checksum verification fails" do allow(obj.content).to receive(:checksum) { "foo" } expect { WithContentFile.new(obj) { |p| nil } }.to raise_error(ChecksumInvalid) end end end
Version data entries
55 entries across 55 versions & 1 rubygems