Sha256: 9c3ae2ecea2e8c8904f875bcaacd9061ff8b814fa0eb425a8e82d1caa78e2aeb

Contents?: true

Size: 716 Bytes

Versions: 3

Compression:

Stored size: 716 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Table::Renderer::Basic, '#column_widths' do
  let(:rows)   { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
  let(:renderer) { described_class.new(table) }

  subject { renderer.render }

  context 'with rows only' do
    let(:rows)  { [['a1a', 'a2a2a2'], ['b1b1b', 'b2b2']] }
    let(:table) { TTY::Table.new rows }

    it 'calculates column widths' do
      expect(renderer.column_widths).to eq([5,6])
    end
  end

  context 'with header' do
    let(:header) { ['header1', 'head2', 'h3'] }
    let(:table)  { TTY::Table.new header, rows }

    it 'calcualtes column widths with header' do
      expect(renderer.column_widths).to eq([7,5,2])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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