Sha256: 1c55148a53c7022daaab7d71f7de77b50ae23c710ad6f56c0bbcbd5b2f697efd

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require File.expand_path("../../spec_helper", __FILE__)

RSpec.describe Attachie::FileDriver do
  let(:driver) { Attachie::FileDriver.new("/tmp/attachie") }

  describe "#presigned_post" do
    it "raises NotSupported" do
      expect { driver.presigned_post("path", "bucket") }.to raise_error(Attachie::NotSupported)
    end
  end

  describe "#store" do
    it "stores a blob" do
      begin
        driver.store("name", "blob", "bucket")

        expect(driver.exists?("name", "bucket")).to be(true)
        expect(driver.value("name", "bucket")).to eq("blob")
      ensure
        driver.delete("name", "bucket")
      end
    end
  end

  describe" #store_multipart" do
    it "stores a blob via multipart upload" do
      begin
        driver.store_multipart("name", "bucket") do |upload|
          upload.upload_part("chunk1")
          upload.upload_part("chunk2")
        end

        expect(driver.exists?("name", "bucket")).to be(true)
        expect(driver.value("name", "bucket")).to eq("chunk1chunk2")
      ensure
        driver.delete("name", "bucket")
      end
    end
  end

  describe "#delete" do
    it "deletes a blob" do
      begin
        driver.store("name", "blob", "bucket")
        expect(driver.exists?("name", "bucket")).to be(true)

        driver.delete("name", "bucket")
        expect(driver.exists?("name", "bucket")).to be(false)
      ensure
        driver.delete("name", "bucket")
      end
    end
  end

  describe "#info" do
    it "returns info about the object" do
      begin
        driver.store("name.txt", "blob", "bucket")

        expect(driver.info("name.txt", "bucket")).to match(
          content_length: 4,
          content_type: "text/plain",
          last_modified: anything
        )
      ensure
        driver.delete("name.txt", "bucket")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
attachie-1.0.1 spec/attachie/file_driver_spec.rb
attachie-1.0.0 spec/attachie/file_driver_spec.rb