Sha256: 10a6623415f49090f95f8723a62e2b8b4085dca950ada614b0fdb43fc70d18ab

Contents?: true

Size: 706 Bytes

Versions: 3

Compression:

Stored size: 706 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'Hash Source' do
  it 'just works in a console' do
    expected = <<~TABLE
      +---+---+---+
      | a | b | c |
      +---+---+---+
      | 1 | 2 | 3 |
      +---+---+---+
    TABLE
    {a: 1, b: 2, c: 3}.to_table.text_table.to_s.should == expected
  end

  it 'just works with print' do
    expected = <<~TABLE
      +---+---+---+
      | a | b | c |
      +---+---+---+
      | 1 | 2 | 3 |
      +---+---+---+
    TABLE

    begin
      orig_stdout = $stdout
      sio = StringIO.new
      $stdout = sio
      print({a: 1, b: 2, c: 3}.to_table)
      sio.string.should == expected
    ensure
      $stdout = orig_stdout
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tablesmith-0.6.2 spec/hash_table_spec.rb
tablesmith-0.6.0 spec/hash_table_spec.rb
tablesmith-0.5.0 spec/hash_table_spec.rb