Sha256: 6618c626f8a876b995490535d133bfe57b934803678c9363668d0817c9273cef

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

# encoding: utf-8
require 'spec_helper'
require 'fedux_org_stdlib/list'

RSpec.describe List do
  context '#to_a' do
    it 'returns data as array' do
      list = List.new(
        [
          { name: 'user1' }
        ]
      )

      expect(list.to_a).to include(name: 'user1')
    end

    it 'handles non array input as well' do
      list = List.new(name: 'user1', age: 30)

      expect(list.to_a).to include(name: 'user1', age: 30)
    end
  end

  context '#to_s' do
    it 'converts data to table' do
      list = List.new(name: 'user1', age: 30)

      expect(list.to_s).to include('| 30  | user1 |')
    end

    it 'passes options to table helper' do
      list = List.new(name: 'user1', age: 30)
      expect_result = <<-EOS.strip_heredoc
        ****** 1. row ******
         Age: 30
        Name: user1
        1 row in set
      EOS

      expect(list.to_s(style: :vertical)).to include expect_result
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.8.5 spec/list_spec.rb
fedux_org-stdlib-0.8.4 spec/list_spec.rb