Sha256: d9cf503f423bb5ab2aff33752e7772ecd220e81f4aae0b294dfbc2b1ada4f1b8

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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 }

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.1.2 spec/tty/table/header/call_spec.rb
tty-0.1.1 spec/tty/table/header/call_spec.rb
tty-0.1.0 spec/tty/table/header/call_spec.rb