File: string_truncate_spec.rb

package info (click to toggle)
ruby-test-prof 1.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,448 kB
  • sloc: ruby: 13,093; sh: 4; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 595 bytes parent folder | download
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