1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
# frozen_string_literal: true
require "test_prof/ext/string_truncate"
using TestProf::StringTruncate
describe TestProf::StringTruncate do
it "doesn't modify if less than limit", :aggregate_failures do
expect("abc".truncate).to eq "abc"
expect("abcdefgh".truncate(10)).to eq "abcdefgh"
end
it "has default limit of 30" do
expect((("a".."z").to_a.join * 2).truncate).to eq "abcdefghijklm...mnopqrstuvwxyz"
end
it "works with custom length", :aggregate_failures do
expect("abcdefgh".truncate(5)).to eq "a...h"
expect("abcdef".truncate(5)).to eq "a...f"
end
end
|