Sha256: f164ad96d4cfae9aa2ffa2c7ecb4b3fd8a7e49db9413e4f751604d499df6d2ec

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

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

require 'spec_helper'

describe TTY::Table::Border::ASCII, '#rendering' do

  subject { described_class.new(column_widths) }

  context 'with empty row' do
    let(:row) { TTY::Table::Row.new([]) }
    let(:column_widths) { []}

    it 'draws top line' do
      subject.top_line.should == "++"
    end

    it 'draws middle line' do
      subject.separator.should == "++"
    end

    it 'draw bottom line' do
      subject.bottom_line.should == "++"
    end

    it 'draws row line' do
      subject.row_line(row).should == "||"
    end
  end

  context 'with row' do
    let(:column_widths) { [2,2,2] }
    let(:row) { TTY::Table::Row.new(['a1', 'a2', 'a3']) }

    it 'draws top line' do
      subject.top_line.should == "+--+--+--+"
    end

    it 'draw middle line' do
      subject.separator.should == "+--+--+--+"
    end

    it 'draw bottom line' do
      subject.bottom_line.should == "+--+--+--+"
    end

    it 'draws row line' do
      subject.row_line(row).should == "|a1|a2|a3|"
    end
  end

  context 'with multiline row' do
    let(:row) { TTY::Table::Row.new(["a1\nb1\nc1", 'a2', 'a3']) }
    let(:column_widths) { [2,2,2]}

    it 'draws row line' do
      subject.row_line(row).should == <<-EOS.normalize
        |a1|a2|a3|
        |b1|  |  |
        |c1|  |  |
      EOS
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tty-0.0.10 spec/tty/table/border/ascii/rendering_spec.rb