Sha256: 7a7155629275e805f8ad0ecdbd001d84262fdabf11ede71de0257857ee25e112

Contents?: true

Size: 833 Bytes

Versions: 10

Compression:

Stored size: 833 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table::Row, '#new' do
  let(:object) { described_class }

  subject { object.new data }

  context 'with no arguments' do
    let(:data) { [] }

    it { is_expected.to be_instance_of(object) }

    it { is_expected.to be_empty }

    it { expect(subject.attributes).to eq([]) }

    it { expect(subject.data).to eq({}) }
  end

  context 'with Array argument' do
    let(:data) { ['a'] }

    it { is_expected.to be_instance_of(object) }

    it { expect(subject.attributes).to eq([0]) }

    it { expect(subject.to_hash).to eq({0 => "a"}) }
  end

  context 'with Hash argument' do
    let(:data) { {id: 'a'} }

    it { should be_instance_of(object) }

    it { expect(subject.attributes).to eq([:id]) }

    it { expect(subject.to_hash).to eq({:id => 'a'}) }
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tty-table-0.10.0 spec/unit/row/new_spec.rb
tty-table-0.9.0 spec/unit/row/new_spec.rb
tty-table-0.8.0 spec/unit/row/new_spec.rb
tty-table-0.7.0 spec/unit/row/new_spec.rb
tty-table-0.6.0 spec/unit/row/new_spec.rb
tty-table-0.5.0 spec/unit/row/new_spec.rb
tty-table-0.4.0 spec/unit/row/new_spec.rb
tty-table-0.3.0 spec/unit/row/new_spec.rb
tty-table-0.2.0 spec/unit/row/new_spec.rb
tty-table-0.1.0 spec/unit/row/new_spec.rb