Sha256: a87e0db34b70cb155f7182569aa15157d7b220243083ab31ecdfe155675fa2b5

Contents?: true

Size: 729 Bytes

Versions: 9

Compression:

Stored size: 729 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table::Operation::Truncation, '#call' do
  let(:text)   { '太丸ゴシック体' }
  let(:field)  { TTY::Table::Field.new(text) }

  subject(:operation) { described_class.new(column_widths) }

  context 'without column width' do
    let(:column_widths) { [] }

    it "truncates string" do
      expect(operation.call(field, 0, 0)).to eql(text)
    end
  end

  context 'with column width ' do
    let(:column_widths) { [6, 8] }

    it "truncates string for 0 column" do
      expect(operation.call(field, 0, 0)).to eql('太丸…')
    end

    it "truncates string for 1 column" do
      expect(operation.call(field, 0, 1)).to eql('太丸ゴ…')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tty-table-0.10.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.9.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.8.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.7.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.6.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.5.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.4.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.3.0 spec/unit/operation/truncation/call_spec.rb
tty-table-0.2.0 spec/unit/operation/truncation/call_spec.rb