Sha256: ea87f116a17f42b2609f5cf1b0f3c04f9d509dc9229533950d7a4f80155d67a9

Contents?: true

Size: 877 Bytes

Versions: 41

Compression:

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

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

end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.11.18 spec/list_spec.rb
fedux_org-stdlib-0.11.17 spec/list_spec.rb
fedux_org-stdlib-0.11.16 spec/list_spec.rb
fedux_org-stdlib-0.11.15 spec/list_spec.rb
fedux_org-stdlib-0.11.14 spec/list_spec.rb
fedux_org-stdlib-0.11.12 spec/list_spec.rb
fedux_org-stdlib-0.11.11 spec/list_spec.rb
fedux_org-stdlib-0.11.9 spec/list_spec.rb
fedux_org-stdlib-0.11.8 spec/list_spec.rb
fedux_org-stdlib-0.11.7 spec/list_spec.rb
fedux_org-stdlib-0.11.6 spec/list_spec.rb
fedux_org-stdlib-0.11.5 spec/list_spec.rb
fedux_org-stdlib-0.11.4 spec/list_spec.rb
fedux_org-stdlib-0.11.3 spec/list_spec.rb
fedux_org-stdlib-0.11.2 spec/list_spec.rb
fedux_org-stdlib-0.11.1 spec/list_spec.rb
fedux_org-stdlib-0.11.0 spec/list_spec.rb
fedux_org-stdlib-0.10.9 spec/list_spec.rb
fedux_org-stdlib-0.10.8 spec/list_spec.rb
fedux_org-stdlib-0.10.7 spec/list_spec.rb