Sha256: 4babcd2590e8967b4abf0a425502fb35e4ebb4a45b3da6a988b566569dcab4cf

Contents?: true

Size: 915 Bytes

Versions: 10

Compression:

Stored size: 915 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table::Validatable do
  let(:described_class) { Class.new { include TTY::Table::Validatable } }
  let(:rows) { [['a1', 'a2'], ['b1']] }

  subject { described_class.new }

  it 'raises no exception' do
    rows[1] << ['b2']
    expect { subject.assert_row_sizes(rows) }.not_to raise_error
  end

  it 'raises exception for mismatched rows' do
    expect { subject.assert_row_sizes(rows) }.
      to raise_error(TTY::Table::DimensionMismatchError)
  end

  it "raises exception when :header key has wrong data type" do
    options = {header: 'h1'}
    expect { subject.validate_options!(options) }.
      to raise_error(TTY::Table::InvalidArgument)
  end

  it "raises exception when :rows key has wrong data type" do
    options = {rows: 'a1'}
    expect { subject.validate_options!(options) }.
      to raise_error(TTY::Table::InvalidArgument)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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