Sha256: 2ff6696bc8e8f04f5f90e7390be641f4c4e2097009b462f9b5018465e8378379

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe PrivatePlease::Report::Table do
  let(:col_1) { %w(a b c) }
  let(:col_2) { %w(X Y Z) }

  def table(col_1, col_2)
    PrivatePlease::Report::Table.new(col_1, col_2)    
  end
#------------------------------------------------------------------------------
  
  it 'wraps 2 columns of data' do
    t = table(col_1, col_2)
    t.col_1.should == col_1
    t.col_2.should == col_2
  end

  it 'pads with nil whichever column is shorter' do
    table(['1'], %w(a b c)).tap do |t|
      t.col_1.should == ['1', nil, nil]
      t.col_2.should == %w(a b c)
    end
    table(%w(a b c), ['1']).tap do |t|
      t.col_1.should == %w(a b c)
      t.col_2.should == ['1', nil, nil]
    end
    
  end  

  example '#rows returns an array of [String, String]' do
    t = table(['1', '2'], col_2)
    t.rows.should == [
        ['1', 'X'],
        ['2', 'Y'],
        [nil, 'Z'],
    ]
  end

  example '#empty?' do
    table(['1', '2'], []).should_not be_empty    
    table([], ['1', '2']).should_not be_empty    
    table([], []        ).should     be_empty    
  end

  example '#longest_value_length' do
    table(['a', '12345'], ['b', 'c']).longest_value_length.should == '12345'.length     
    table(['b'], ['a', '12345']     ).longest_value_length.should == '12345'.length     
    table([], []                    ).longest_value_length.should == 0     
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
private_please-0.0.5 spec/05_reporting/report_table_spec.rb
private_please-0.0.4 spec/05_reporting/report_table_spec.rb