Sha256: 50ec5cf3ab9de9e8502322f7a453262fb7c902cfe86c1c433a504ceff34d9362

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table, '#to_s' do
  let(:header)   { ['h1', 'h2', 'h3'] }
  let(:rows)     { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }

  subject(:table) { described_class.new(header, rows) }

  context 'without renderer' do
    it 'displayes basic table' do
      expect(table.render(:basic)).to eq unindent(<<-EOS)
        h1 h2 h3
        a1 a2 a3
        b1 b2 b3
      EOS
    end
  end

  context 'without border' do
    it 'displays table' do
      expect(table.to_s).to eq unindent(<<-EOS)
        h1 h2 h3
        a1 a2 a3
        b1 b2 b3
      EOS
    end
  end

  context 'with ascii border' do
    it 'displays table' do
      expect(table.render(:ascii)).to eq unindent(<<-EOS)
        +--+--+--+
        |h1|h2|h3|
        +--+--+--+
        |a1|a2|a3|
        |b1|b2|b3|
        +--+--+--+
      EOS
    end
  end

  context 'with unicode border' do
    it 'displays table' do
      expect(table.render(:unicode)).to eq unindent(<<-EOS)
        ┌──┬──┬──┐
        │h1│h2│h3│
        ├──┼──┼──┤
        │a1│a2│a3│
        │b1│b2│b3│
        └──┴──┴──┘
      EOS
    end
  end
end # to_s

Version data entries

9 entries across 9 versions & 1 rubygems

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