Sha256: e49378b80d9efbd6054e348ab1ef7cabc7d28dad9d47a534c723775b22185875

Contents?: true

Size: 949 Bytes

Versions: 8

Compression:

Stored size: 949 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 { should == field }
  end

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

    it { should == field + '    ' }

    it_should_behave_like 'lower column width'
  end

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

    it { should == '  ' + 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 { should == '  ' + field + '   ' }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tty-0.0.11 spec/tty/table/operation/alignment/format_spec.rb
tty-0.0.10 spec/tty/table/operation/alignment/format_spec.rb
tty-0.0.9 spec/tty/table/operation/alignment/format_spec.rb
tty-0.0.8 spec/tty/table/operation/alignment/format_spec.rb
tty-0.0.7 spec/tty/table/operation/alignment/format_spec.rb
tty-0.0.6 spec/tty/table/operation/alignment/format_spec.rb
tty-0.0.5 spec/tty/table/operation/alignment/format_spec.rb
tty-0.0.4 spec/tty/table/operation/alignment/format_spec.rb