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.8.6 spec/list_spec.rb