Sha256: 05a4cdaac93015e1cc94ded5f657c2cb2f88bed86170c8229365b1bbe77c18be

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Table::Operation::Alignment, '#new' do
  let(:object) { described_class.new alignment }
  let(:field) { "aaaa"}
  let(:space) { '' }
  let(:column_width) { 8 }

  subject { object.format field, column_width, space }

  shared_examples_for 'lower column width' do
    let(:column_width) { 2 }

    it { is_expected.to eql(field) }
  end

  context 'left aligend' do
    let(:alignment) { :left }

    it { is_expected.to eq(field + '    ') }

    it_should_behave_like 'lower column width'
  end

  context 'center aligned' do
    let(:alignment) { :center }

    it { is_expected.to eql('  ' + field + '  ') }

    it_should_behave_like 'lower column width'
  end

  context 'right aligned' do
    let(:alignment) { :right }

    it_should_behave_like 'lower column width'
  end

  context 'with space' do
    let(:alignment) { :center }
    let(:space) { ' '}

    it { is_expected.to  eql('  ' + field + '   ') }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.1.2 spec/tty/table/operation/alignment/format_spec.rb
tty-0.1.1 spec/tty/table/operation/alignment/format_spec.rb
tty-0.1.0 spec/tty/table/operation/alignment/format_spec.rb