Sha256: 330e32d544ecdce4b936332a99f6e56537767db33dc4c79481c9f8d459c341b4

Contents?: true

Size: 910 Bytes

Versions: 26

Compression:

Stored size: 910 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
      EOS

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

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.7.14 spec/list_spec.rb
fedux_org-stdlib-0.7.12 spec/list_spec.rb
fedux_org-stdlib-0.7.11 spec/list_spec.rb
fedux_org-stdlib-0.7.10 spec/list_spec.rb
fedux_org-stdlib-0.7.8 spec/list_spec.rb
fedux_org-stdlib-0.7.7 spec/list_spec.rb