Sha256: 029e45450ed065786078ca6dd641c36468f8776ba9840be204f2d4cc61823c51

Contents?: true

Size: 977 Bytes

Versions: 48

Compression:

Stored size: 977 Bytes

Contents

require 'spec_helper'

describe FormatParser::ActiveStorage::BlobIO do
  let(:blob_service) { double }
  let(:blob) { double(key: 'blob_key', service: blob_service, byte_size: 43000) }
  let(:io) { described_class.new(blob) }
  let(:fixture_path) { fixtures_dir + '/test.png' }

  it_behaves_like 'an IO object compatible with IOConstraint'

  describe '#read' do
    it 'reads io using download_chunk from ActiveStorage#Service' do
      allow(blob_service).to receive(:download_chunk) { 'a' }

      expect(io.read(1)).to eq('a')
    end

    it 'updates #pos on read' do
      allow(blob_service).to receive(:download_chunk) { 'a' }

      expect { io.read(1) }.to change { io.pos }.from(0).to(1)
    end
  end

  describe '#seek' do
    it 'updates @pos' do
      expect { io.seek(10) }.to change { io.pos }.from(0).to(10)
    end
  end

  describe '#size' do
    it 'returns the size of the blob byte_size' do
      expect(io.size).to eq(blob.byte_size)
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
format_parser-1.7.0 spec/active_storage/blob_io_spec.rb
format_parser-1.6.0 spec/active_storage/blob_io_spec.rb
format_parser-1.5.0 spec/active_storage/blob_io_spec.rb
format_parser-1.4.2 spec/active_storage/blob_io_spec.rb
format_parser-1.4.1 spec/active_storage/blob_io_spec.rb
format_parser-1.4.0 spec/active_storage/blob_io_spec.rb
format_parser-1.3.0 spec/active_storage/blob_io_spec.rb
format_parser-1.2.1 spec/active_storage/blob_io_spec.rb
format_parser-1.2.0 spec/active_storage/blob_io_spec.rb
format_parser-1.1.0 spec/active_storage/blob_io_spec.rb
format_parser-1.0.0 spec/active_storage/blob_io_spec.rb
format_parser-0.29.1 spec/active_storage/blob_io_spec.rb
format_parser-0.29.0 spec/active_storage/blob_io_spec.rb
format_parser-0.28.0 spec/active_storage/blob_io_spec.rb
format_parser-0.27.0 spec/active_storage/blob_io_spec.rb
format_parser-0.26.0 spec/active_storage/blob_io_spec.rb
format_parser-0.25.6 spec/active_storage/blob_io_spec.rb
format_parser-0.25.5 spec/active_storage/blob_io_spec.rb
format_parser-0.25.4 spec/active_storage/blob_io_spec.rb
format_parser-0.25.3 spec/active_storage/blob_io_spec.rb