diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-04-17 10:53:09 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-04-17 10:53:09 +0300 |
commit | c26b126502d4025230aa80e7d26736e1398c5022 (patch) | |
tree | 4eed6390ef5d2671792fc03a64d164a19061acf0 /spec/lib/gitlab/ci/trace | |
parent | ee3b0c3a9ad0823f86b5c798c47c343a812228d0 (diff) |
Make sure @stream.each_line would tag Encoding.default_external
Diffstat (limited to 'spec/lib/gitlab/ci/trace')
-rw-r--r-- | spec/lib/gitlab/ci/trace/stream_spec.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb index 4bbca6d2ea2..6f5c9994f54 100644 --- a/spec/lib/gitlab/ci/trace/stream_spec.rb +++ b/spec/lib/gitlab/ci/trace/stream_spec.rb @@ -34,12 +34,12 @@ describe Gitlab::Ci::Trace::Stream do end context 'when the trace contains ANSI sequence and Unicode' do - let(:stream) do - described_class.new do - File.open(expand_fixture_path('trace/ansi-sequence-and-unicode')) - end + let(:io) do + File.open(expand_fixture_path('trace/ansi-sequence-and-unicode')) end + let(:stream) { described_class.new { io } } + it 'forwards to the next linefeed, case 1' do stream.limit(7) @@ -57,6 +57,16 @@ describe Gitlab::Ci::Trace::Stream do expect(result).to eq("\e[01;32m許功蓋\e[0m\n") expect(result.encoding).to eq(Encoding.default_external) end + + # See https://gitlab.com/gitlab-org/gitlab-ce/issues/30796 + it 'reads in binary, output as Encoding.default_external' do + stream.limit(29) + + result = io.read # Ci::Ansi2html::Converter would read with each_line + + expect(result).to eq("\e[01;32m許功蓋\e[0m\n") + expect(result.encoding).to eq(Encoding.default_external) + end end end |