Sha256: 526011e08dbe5133e30ed19e3796704379cc771483f8f938f3bf82d53b9a988e

Contents?: true

Size: 969 Bytes

Versions: 29

Compression:

Stored size: 969 Bytes

Contents

module Ddr::Models
  RSpec.describe WithContentFile do

    let(:obj) { FactoryGirl.create(:component) }

    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) { double(value: "foo", algorithm: "SHA1") }
      expect { WithContentFile.new(obj) { |p| nil } }.to raise_error(ChecksumInvalid)
    end

  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ddr-models-3.0.8 spec/models/with_content_file_spec.rb
ddr-models-3.0.7 spec/models/with_content_file_spec.rb
ddr-models-3.0.6 spec/models/with_content_file_spec.rb
ddr-models-3.0.5 spec/models/with_content_file_spec.rb
ddr-models-3.0.4 spec/models/with_content_file_spec.rb
ddr-models-3.0.3 spec/models/with_content_file_spec.rb
ddr-models-3.0.2 spec/models/with_content_file_spec.rb
ddr-models-3.0.1 spec/models/with_content_file_spec.rb
ddr-models-3.0.0 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.rc6 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.rc5 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.rc4 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.rc3 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.rc2 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.rc1 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.beta.22 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.beta.21 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.beta.20 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.beta.18 spec/models/with_content_file_spec.rb
ddr-models-3.0.0.beta.17 spec/models/with_content_file_spec.rb