Sha256: f3b17fee426266d9304d61e259d102f52a206a09d8682c1dde9bb2ddc941b567

Contents?: true

Size: 967 Bytes

Versions: 9

Compression:

Stored size: 967 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table::Operation::Alignment, '#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

9 entries across 9 versions & 1 rubygems

Version Path
tty-table-0.10.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.9.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.8.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.7.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.6.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.5.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.4.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.3.0 spec/unit/operation/alignment/call_spec.rb
tty-table-0.2.0 spec/unit/operation/alignment/call_spec.rb