Sha256: c03afa5c41bc10064f6f8d225c1530ba926cc162e76ee5f8ee88f1cab1dec0be

Contents?: true

Size: 660 Bytes

Versions: 10

Compression:

Stored size: 660 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table::Header, '#call' do
  let(:object) { described_class.new(attributes) }
  let(:attributes) { [:id, :name, :age] }

  subject { object[attribute] }

  context 'with a known attribute' do
    context 'when symbol' do
      let(:attribute) { :age }

      it { is_expected.to eq(2) }
    end

    context 'when integer' do
      let(:attribute) { 1 }

      it { is_expected.to eq(:name) }
    end
  end

  context 'with an unknown attribute' do
    let(:attribute) { :mine }

    it { expect { subject }.to raise_error(TTY::Table::UnknownAttributeError, "the header 'mine' is unknown")}
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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