Sha256: 51563f2a8db31c7dd98d3399479a8751de957a84eb289877c9bc838157f71be3

Contents?: true

Size: 974 Bytes

Versions: 1

Compression:

Stored size: 974 Bytes

Contents

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

require 'spec_helper'

describe TTY::Table, 'options' do
  let(:rows)   { [['a1', 'a2'], ['b1', 'b2']] }
  let(:widths) { nil }
  let(:aligns) { [] }
  let(:object) {
    described_class.new rows,
      :column_widths => widths,
      :column_aligns  => aligns,
      :renderer => :basic
  }

  subject { object.to_s; object.renderer }

  its(:column_widths) { should == [2,2] }

  its(:alignments) { should be_kind_of TTY::Table::Operation::AlignmentSet }

  it 'is empty' do
    subject.alignments.to_a.should be_empty
  end

  context '#column_widths' do
    let(:widths) { [10, 10] }

    its(:column_widths) { should == widths }
  end

  context '#column_widths empty' do
    let(:widths) { [] }

    it { expect { subject }.to raise_error(TTY::InvalidArgument) }
  end

  context '#column_aligns' do
    let(:aligns) { [:center, :center] }

    it 'unwraps original array' do
      subject.alignments.to_a.should == aligns
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tty-0.0.7 spec/tty/table/options_spec.rb