Sha256: 0ad3b7fa088cec2669fb206e11d7e4793ceab0b431a4f5c6df9f9b1e9a48e70c

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

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

require 'spec_helper'

describe TTY::Table::Operation::AlignmentSet, '#align_rows' do
  let(:object)  { described_class.new alignments }
  let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }

  subject { object.align_rows rows, :column_widths => widths }

  context 'aligned with column widths and no alignments' do
    let(:alignments) { [] }
    let(:widths) { [4, 4] }

    it { should be_instance_of(Array) }

    it { should == [['a1  ', 'a2  '], ['b1  ', 'b2  ']] }
  end

  context 'aligned with column widths and alignments' do
    let(:alignments) { [:right, :left] }
    let(:widths) { [4, 4] }

    it { should be_instance_of(Array) }

    it { should == [['  a1', 'a2  '], ['  b1', 'b2  ']] }
  end

  context 'aligned with no column widths and no alignments' do
    let(:alignments) { [] }
    let(:widths) { [] }

    it { should be_instance_of(Array) }

    it { should == [['a1', 'a2'], ['b1', 'b2']] }
  end

  context 'aligned with no column widths and alignments' do
    let(:alignments) { [:right, :left] }
    let(:widths) { [] }

    it { should be_instance_of(Array) }

    it { should == [['a1', 'a2'], ['b1', 'b2']] }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.0.7 spec/tty/table/operation/alignment_set/align_rows_spec.rb
tty-0.0.6 spec/tty/table/operation/alignment_set/align_rows_spec.rb
tty-0.0.5 spec/tty/table/operation/alignment_set/align_rows_spec.rb