Sha256: e40eb8a0971b4f4b0d7f348fc26de33ad615fa1695b0fce08533a1acc756ea05

Contents?: true

Size: 894 Bytes

Versions: 2

Compression:

Stored size: 894 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'spec_helper'

describe TTY::Table::Renderer::Basic, 'truncation' do
  let(:header) { ['header1', 'head2', 'h3'] }
  let(:rows) { [['a1111111', 'a222', 'a3333333'], ['b111', 'b2222222', 'b333333']]}
  let(:table) { TTY::Table.new header, rows }

  subject { described_class.new(table, options) }

  context 'without column widths' do
    let(:options) { {} }

    it "doesn't shorten the fields" do
      subject.render.should == <<-EOS.normalize
        header1  head2    h3      
        a1111111 a222     a3333333
        b111     b2222222 b333333 
      EOS
    end
  end

  context 'with column widths' do
    let(:options) { { column_widths: [3, 5, 7] } }

    it 'shortens the fields' do
      subject.render.should == <<-EOS.normalize
        he… head2 h3     
        a1… a222  a33333…
        b1… b222… b333333
      EOS
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tty-0.0.11 spec/tty/table/renderer/basic/truncation_spec.rb
tty-0.0.10 spec/tty/table/renderer/basic/truncation_spec.rb