diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-04-18 12:03:02 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-04-18 12:12:06 +0300 |
commit | b07da07c82e17f0be5bb5398b9b0cfec52cf2d2b (patch) | |
tree | 972eea6314234e051b4b37202fbd19866177033e /spec | |
parent | ec9f6180bc4684521444ee0681308bf4c9c71297 (diff) |
Just enforce the output encoding for Ansi2html
Fixes https://sentry.gitlap.com/gitlab/gitlabcom/issues/27545/
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/trace/stream_spec.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb index 03f040f4465..40ac5a3ed37 100644 --- a/spec/lib/gitlab/ci/trace/stream_spec.rb +++ b/spec/lib/gitlab/ci/trace/stream_spec.rb @@ -71,12 +71,20 @@ describe Gitlab::Ci::Trace::Stream do end describe '#append' do + let(:tempfile) { Tempfile.new } + let(:stream) do described_class.new do - StringIO.new("12345678") + tempfile.write("12345678") + tempfile.rewind + tempfile end end + after do + tempfile.unlink + end + it "truncates and append content" do stream.append("89", 4) stream.seek(0) @@ -84,6 +92,17 @@ describe Gitlab::Ci::Trace::Stream do expect(stream.size).to eq(6) expect(stream.raw).to eq("123489") end + + it 'appends in binary mode' do + '😺'.force_encoding('ASCII-8BIT').each_char.with_index do |byte, offset| + stream.append(byte, offset) + end + + stream.seek(0) + + expect(stream.size).to eq(4) + expect(stream.raw).to eq('😺') + end end describe '#set' do |