debian-mirror-gitlab/spec/models/ci/build_trace_spec.rb

36 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Ci::BuildTrace do
2019-12-21 20:55:43 +05:30
let(:build) { build_stubbed(:ci_build) }
let(:state) { nil }
let(:data) { StringIO.new('the-stream') }
let(:stream) do
Gitlab::Ci::Trace::Stream.new { data }
end
2020-07-28 23:09:34 +05:30
subject { described_class.new(build: build, stream: stream, state: state) }
2019-12-21 20:55:43 +05:30
shared_examples 'delegates methods' do
it { is_expected.to delegate_method(:state).to(:trace) }
it { is_expected.to delegate_method(:append).to(:trace) }
it { is_expected.to delegate_method(:truncated).to(:trace) }
it { is_expected.to delegate_method(:offset).to(:trace) }
it { is_expected.to delegate_method(:size).to(:trace) }
it { is_expected.to delegate_method(:total).to(:trace) }
it { is_expected.to delegate_method(:id).to(:build).with_prefix }
it { is_expected.to delegate_method(:status).to(:build).with_prefix }
it { is_expected.to delegate_method(:complete?).to(:build).with_prefix }
end
2020-07-28 23:09:34 +05:30
it_behaves_like 'delegates methods'
2019-12-21 20:55:43 +05:30
2020-07-28 23:09:34 +05:30
it 'returns formatted trace' do
expect(subject.lines).to eq([
{ offset: 0, content: [{ text: 'the-stream' }] }
])
2019-12-21 20:55:43 +05:30
end
end