Sha256: 078f8da95b01cf7a12c713c1aa8dd6e119c145de504f96690dacf3bc48417c90

Contents?: true

Size: 896 Bytes

Versions: 2

Compression:

Stored size: 896 Bytes

Contents

RSpec.describe Defile::Backend::FileSystem do
  let(:backend) { Defile::Backend::FileSystem.new(File.expand_path("tmp/store1", Dir.pwd), max_size: 100) }

  it_behaves_like :backend

  describe "#upload" do
    it "efficiently copies a file if it has a path" do
      path = File.expand_path("tmp/test.txt", Dir.pwd)
      File.write(path, "hello")

      uploadable = Defile::FileDouble.new("wrong")
      allow(uploadable).to receive(:path).and_return(path)

      file = backend.upload(uploadable)

      expect(backend.get(file.id).read).to eq("hello")
    end

    it "ignores path if it doesn't exist" do
      path = File.expand_path("tmp/doesnotexist.txt", Dir.pwd)

      uploadable = Defile::FileDouble.new("yes")
      allow(uploadable).to receive(:path).and_return(path)

      file = backend.upload(uploadable)

      expect(backend.get(file.id).read).to eq("yes")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defile-0.2.1 spec/defile/backend/file_system_spec.rb
defile-0.2.0 spec/defile/backend/file_system_spec.rb