Sha256: 0daa42fc8ea740b10c403ac3a3a114d5c5abecc263e1974e3ffb5fcd2572856d
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
require 'spec_helper' describe "ReadLimiter" do let(:io) { StringIO.new(Random.new.bytes(1024)) } it 'does not enforce any limits with default arguments' do reader = FormatParser::ReadLimiter.new(io) 2048.times { reader.seek(1) } 2048.times { reader.read(4) } end it 'enforces the number of seeks' do reader = FormatParser::ReadLimiter.new(io, max_seeks: 4) 4.times { reader.seek(1) } expect { reader.seek(1) }.to raise_error(/Seek budget exceeded/) end it 'enforces the number of reads' do reader = FormatParser::ReadLimiter.new(io, max_reads: 4) 4.times { reader.read(1) } expect { reader.read(1) }.to raise_error(/calls exceeded \(4 max\)/) end it 'enforces the number of bytes read' do reader = FormatParser::ReadLimiter.new(io, max_bytes: 512) reader.read(512) expect { reader.read(1) }.to raise_error(/bytes budget \(512\) exceeded/) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
format_parser-0.1.1 | spec/read_limiter_spec.rb |
format_parser-0.1.0 | spec/read_limiter_spec.rb |