Skip to content

Commit

Permalink
Merge pull request #22 from ondra-m/bytesize-on-nil
Browse files Browse the repository at this point in the history
bytesize on nil
  • Loading branch information
piotrmurach committed Jul 3, 2016
2 parents a3b9e24 + 9eed29c commit 6338a08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tty/command/truncator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/unit/truncator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 6338a08

Please sign in to comment.