Sha256: b5abf00eb7a9ac128e709301c4ce91c290701b3e00ac2a344c71f8f04e145ab8

Contents?: true

Size: 720 Bytes

Versions: 10

Compression:

Stored size: 720 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.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

10 entries across 10 versions & 1 rubygems

Version Path
tty-table-0.10.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.9.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.8.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.7.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.6.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.5.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.4.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.3.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.2.0 spec/unit/renderer/basic/extract_column_widths_spec.rb
tty-table-0.1.0 spec/unit/renderer/basic/extract_column_widths_spec.rb