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.8.3 spec/list_spec.rb
fedux_org-stdlib-0.8.0 spec/list_spec.rb
fedux_org-stdlib-0.7.33 spec/list_spec.rb
fedux_org-stdlib-0.7.31 spec/list_spec.rb
fedux_org-stdlib-0.7.30 spec/list_spec.rb
fedux_org-stdlib-0.7.29 spec/list_spec.rb
fedux_org-stdlib-0.7.28 spec/list_spec.rb
fedux_org-stdlib-0.7.27 spec/list_spec.rb
fedux_org-stdlib-0.7.26 spec/list_spec.rb
fedux_org-stdlib-0.7.25 spec/list_spec.rb
fedux_org-stdlib-0.7.24 spec/list_spec.rb
fedux_org-stdlib-0.7.23 spec/list_spec.rb
fedux_org-stdlib-0.7.22 spec/list_spec.rb
fedux_org-stdlib-0.7.21 spec/list_spec.rb
fedux_org-stdlib-0.7.20 spec/list_spec.rb
fedux_org-stdlib-0.7.19 spec/list_spec.rb
fedux_org-stdlib-0.7.18 spec/list_spec.rb
fedux_org-stdlib-0.7.17 spec/list_spec.rb
fedux_org-stdlib-0.7.16 spec/list_spec.rb
fedux_org-stdlib-0.7.15 spec/list_spec.rb