Sha256: ec4fc6cf729f5f8b912bf54938970b3a83505a91a030ac507f30e4827dd7788d

Contents?: true

Size: 778 Bytes

Versions: 4

Compression:

Stored size: 778 Bytes

Contents

require "spec_helper"

RSpec.describe Carrierwave::Base64::Base64StringIO do
  context "correct image data" do
    let(:image_data) { "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABKdhH//2Q==" }
    subject { described_class.new image_data }

    it "determines the image format from the Dara URI scheme" do
      expect(subject.image_format).to eql("jpg")
    end

    it "should respond to :original_filename" do
      expect(subject.original_filename).to eql("image.jpg")
    end
  end

  context "incorrect image data" do
    it "raises an ArgumentError if Data URI scheme format is missing" do
      expect do
        described_class.new("/9j/4AAQSkZJRgABAQEASABIAADKdhH//2Q==")
      end.to raise_error(Carrierwave::Base64::Base64StringIO::ArgumentError)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
carrierwave-base64-1.3 spec/base64_string_io_spec.rb
carrierwave-base64-1.2 spec/base64_string_io_spec.rb
carrierwave-base64-1.1 spec/base64_string_io_spec.rb
carrierwave-base64-1.0 spec/base64_string_io_spec.rb