Sha256: 21f3bc27e889439cdf9e4cfc9ead354fad36bd8f5eef209cdf85ea2537dfbc0f
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
# -*- encoding: utf-8 -*- require 'spec_helper' describe TTY::Table, '#rotate' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } subject { described_class.new(header, rows) } before { subject.orientation = :horizontal } context 'with default' do context 'without header' do let(:header) { nil } it 'preserves orientation' do expect(subject.header).to be_nil expect(subject.rotate.to_a).to eql rows end end context 'with header' do it 'preserves orientation' do expect(subject.rotate.to_a).to eql [header] + rows end end end context 'with no header' do let(:header) { nil } it 'rotates the rows' do subject.orientation = :vertical expect(subject.rotate.to_a).to eql [ ['a1', 'b1'], ['a2', 'b2'], ['a3', 'b3'], ] expect(subject.header).to be_nil end it 'rotates the rows back' do subject.orientation = :vertical subject.rotate subject.orientation = :horizontal expect(subject.rotate.to_a).to eql rows expect(subject.header).to eql header end end context 'with header' do it 'rotates the rows and merges header' do subject.orientation = :vertical expect(subject.rotate.to_a).to eql [ ['h1', 'a1', 'b1'], ['h2', 'a2', 'b2'], ['h3', 'a3', 'b3'], ] expect(subject.header).to be_empty end it 'rotates the rows and header back' do subject.orientation = :vertical subject.rotate expect(subject.orientation).to be_a TTY::Table::Orientation::Vertical subject.orientation = :horizontal expect(subject.rotate.to_a).to eql [header] + rows expect(subject.header).to eql header end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tty-0.0.10 | spec/tty/table/rotate_spec.rb |