Sha256: 0af9eca5be2c323abb9b9aff0ef084f026c8ef6acbdcca74626c6e0d57eddfb1

Contents?: true

Size: 626 Bytes

Versions: 6

Compression:

Stored size: 626 Bytes

Contents

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

require 'spec_helper'

describe TTY::Table::Renderer::Basic, '#extract_column_widths' do
  let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }

  subject { described_class.new }

  it 'calculates column widths' do
    rows = [['a1a', 'a2a2a2'], ['b1b1b', 'b2b2']]
    table = TTY::Table.new rows, :renderer => :basic
    subject.render(table)
    table.column_widths.should == [5,6]
  end

  it 'calcualtes column widths with header' do
    header = ['header1', 'head2', 'h3']
    table = TTY::Table.new header, rows
    subject.render(table)
    table.column_widths.should == [7,5,2]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tty-0.0.9 spec/tty/table/renderer/basic/extract_column_widths_spec.rb
tty-0.0.8 spec/tty/table/renderer/basic/extract_column_widths_spec.rb
tty-0.0.7 spec/tty/table/renderer/basic/extract_column_widths_spec.rb
tty-0.0.6 spec/tty/table/renderer/basic/extract_column_widths_spec.rb
tty-0.0.5 spec/tty/table/renderer/basic/extract_column_widths_spec.rb
tty-0.0.4 spec/tty/table/renderer/basic/extract_column_widths_spec.rb