blob: 14e2a9625fe09bc76c63737408e4e31d98375d10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
require 'fast_spec_helper'
RSpec.describe Gitlab::Ci::Ansi2json::Result do
let(:stream) { StringIO.new('hello') }
let(:state) { Gitlab::Ci::Ansi2json::State.new(nil, stream.size) }
let(:offset) { 0 }
let(:params) do
{ lines: [], state: state, append: false, truncated: false, offset: offset, stream: stream }
end
subject { described_class.new(**params) }
describe '#size' do
before do
stream.seek(5) # move stream cursor to the end
end
context 'when offset is at the start' do
let(:offset) { 0 }
it 'returns the full size' do
expect(subject.size).to eq(5)
end
end
context 'when offset is not zero' do
let(:offset) { 2 }
it 'returns the remaining size' do
expect(subject.size).to eq(3)
end
end
end
describe '#total' do
it 'returns size of stread' do
expect(subject.total).to eq(5)
end
end
end
|