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-2.10.0 spec/active_storage/blob_io_spec.rb
format_parser-2.9.0 spec/active_storage/blob_io_spec.rb
format_parser-2.8.0 spec/active_storage/blob_io_spec.rb
format_parser-2.7.2 spec/active_storage/blob_io_spec.rb
format_parser-2.7.1 spec/active_storage/blob_io_spec.rb
format_parser-2.7.0 spec/active_storage/blob_io_spec.rb
format_parser-2.6.0 spec/active_storage/blob_io_spec.rb
format_parser-2.5.0 spec/active_storage/blob_io_spec.rb
format_parser-2.4.5 spec/active_storage/blob_io_spec.rb
format_parser-2.4.4 spec/active_storage/blob_io_spec.rb
format_parser-2.4.3 spec/active_storage/blob_io_spec.rb
format_parser-2.3.0 spec/active_storage/blob_io_spec.rb
format_parser-2.2.1 spec/active_storage/blob_io_spec.rb
format_parser-2.2.0 spec/active_storage/blob_io_spec.rb
format_parser-2.1.0 spec/active_storage/blob_io_spec.rb
format_parser-2.0.0 spec/active_storage/blob_io_spec.rb
format_parser-2.0.0.pre.4 spec/active_storage/blob_io_spec.rb
format_parser-2.0.0.pre.3 spec/active_storage/blob_io_spec.rb
format_parser-2.0.0.pre.2 spec/active_storage/blob_io_spec.rb
format_parser-2.0.0.pre spec/active_storage/blob_io_spec.rb