Sha256: f2ef28d59eb961f5b7fba3dd7d24ce919c7d68d1975f6cc302354502999fd4c7

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.1.2 spec/tty/table/row/new_spec.rb
tty-0.1.1 spec/tty/table/row/new_spec.rb
tty-0.1.0 spec/tty/table/row/new_spec.rb