# 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