From fd4bf200cf77511dbf10b5486f3f26827998509c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Morav=C4=8D=C3=ADk?= Date: Sun, 3 Jul 2016 16:26:46 +0200 Subject: [PATCH 1/2] bytesize on nil --- lib/tty/command/truncator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tty/command/truncator.rb b/lib/tty/command/truncator.rb index 99a032f..99760ac 100644 --- a/lib/tty/command/truncator.rb +++ b/lib/tty/command/truncator.rb @@ -102,7 +102,7 @@ def append(value, dst) dst << value[0...offset] value = value[offset..-1] end - value + value.to_s end end # Truncator end # Command From 9eed29c0273922645a04069b8d88070fbc15296d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Morav=C4=8D=C3=ADk?= Date: Sun, 3 Jul 2016 19:26:31 +0200 Subject: [PATCH 2/2] bytesize on nil test --- spec/unit/truncator_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/unit/truncator_spec.rb b/spec/unit/truncator_spec.rb index fb49bb1..c3566df 100644 --- a/spec/unit/truncator_spec.rb +++ b/spec/unit/truncator_spec.rb @@ -26,6 +26,15 @@ expect(truncator.read).to eq("abcd") end + it "writes more bytes letter" do + truncator = described_class.new(max_size: 1000) + + multibytes_string = "’test’" + + expect { truncator.write(multibytes_string) }.to_not raise_error + expect(truncator.read).to eq(multibytes_string) + end + it "overflows prefix and suffix " do truncator = described_class.new(max_size: 2)