Sha256: 18f9aad147fc7a8cf7c88bc1c66606530038ba6cb8579a5bcb3b3bdadd117131

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Table::Operation::AlignmentSet, '#call' do
  let(:object) { described_class.new alignments, widths }
  let(:value)  { 'a1' }
  let(:field)  { TTY::Table::Field.new(value)}

  subject { object.call(field, 0, 0) }

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

    it { is_expected.to eq("#{value}  ") }
  end

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

    it { is_expected.to eq("  #{value}") }
  end

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

    it { is_expected.to eq("#{value}") }
  end

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

    it { is_expected.to eq("#{value}") }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.1.2 spec/tty/table/operation/alignment_set/call_spec.rb
tty-0.1.1 spec/tty/table/operation/alignment_set/call_spec.rb
tty-0.1.0 spec/tty/table/operation/alignment_set/call_spec.rb