Sha256: 5c0fe0defe3cc07d01053de300c617104f93cda3a7952c73f87f2457dfabd282

Contents?: true

Size: 805 Bytes

Versions: 21

Compression:

Stored size: 805 Bytes

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

describe "auto table" do
  it "converts nonarrays to arrays and renders" do
    require 'set'
    # rubinius sorts Set#to_a differently
    arr = RUBY_DESCRIPTION.include?('rubinius') ? Set.new([1,2,3]).to_a : [1,2,3]

    expected_table = <<-TABLE.unindent
    +-------+
    | value |
    +-------+
    | #{arr[0]}     |
    | #{arr[1]}     |
    | #{arr[2]}     |
    +-------+
    3 rows in set
    TABLE
    Helpers::AutoTable.render(::Set.new([1,2,3])).should == expected_table
  end

  it "renders hash" do
    expected_table = <<-TABLE.unindent
    +---+-------+
    | 0 | 1     |
    +---+-------+
    | a | 12345 |
    +---+-------+
    1 row in set
    TABLE
    Helpers::AutoTable.render({:a=>12345}).should == expected_table
  end
end

Version data entries

21 entries across 20 versions & 3 rubygems

Version Path
hirb-0.6.1 test/auto_table_test.rb