Sha256: 5f487e0d6676f413e5302377ee10b6e1ab9bba3a6f9a43f44e4e1dadc3529273

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 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(:renderer) { described_class.new(table, options) }

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

    it "doesn't shorten the fields" do
      expect(renderer.render).to eq <<-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
      expect(renderer.render).to eq <<-EOS.normalize
        he… head2 h3     
        a1… a222  a33333…
        b1… b222… b333333
      EOS
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.1.2 spec/tty/table/renderer/basic/truncation_spec.rb
tty-0.1.1 spec/tty/table/renderer/basic/truncation_spec.rb
tty-0.1.0 spec/tty/table/renderer/basic/truncation_spec.rb