Sha256: a05164b53b63e1a3f162b71514cab18db479da25c706fa076ea874d7a5668d81

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'spec_helper'

describe TTY::Table::Row, '#new' do
  let(:yields) { [] }
  let(:value)  { 'a1' }
  let(:header) { ['Header1']}
  let(:row)    { [ value ] }
  let(:object) { described_class.new row, header }

  context 'with block' do
    subject { object.each { |field| yields << field } }

    it 'yields only fields' do
      subject
      yields.each { |field| expect(field).to be_instance_of(value.class) }
    end

    it 'yields rows with expected attributes' do
      subject
      yields.each { |field| expect(field).to eql(value) }
    end

    it 'yields each row' do
      expect { subject }.to change { yields }.
        from( [] ).
        to( yields )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tty-0.0.11 spec/tty/table/row/each_spec.rb
tty-0.0.10 spec/tty/table/row/each_spec.rb