Sha256: 51944508c402d1b4910efcf12d3ffb690a7a15148d8022e9793f066b6a84b6fd

Contents?: true

Size: 944 Bytes

Versions: 9

Compression:

Stored size: 944 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table::ColumnConstraint, 'column widths' do
  let(:header) { ['h1', 'h2', 'h3', 'h4'] }
  let(:rows)   { [['a1', 'a2', 'a3', 'a4'], ['b1', 'b2', 'b3', 'b4']] }
  let(:table)  { TTY::Table.new(header, rows) }

  subject(:columns) { described_class.new(table, renderer) }

  context 'with basic renderer' do
    let(:renderer) { TTY::Table::Renderer::Basic.new(table) }

    it 'calculates columns natural width' do
      expect(columns.natural_width).to eq(11)
    end

    it 'calculates miminimum columns width' do
      expect(columns.minimum_width).to eq(7)
    end
  end

  context 'with ascii renderer' do
    let(:renderer) { TTY::Table::Renderer::ASCII.new(table) }

    it 'calculates columns natural width' do
      expect(columns.natural_width).to eq(13)
    end

    it 'calculates miminimum columns width' do
      expect(columns.minimum_width).to eq(9)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tty-table-0.10.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.9.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.8.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.7.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.6.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.5.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.4.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.3.0 spec/unit/column_constraint/widths_spec.rb
tty-table-0.2.0 spec/unit/column_constraint/widths_spec.rb