Sha256: 1b2ac929bed79bf926fdd90c3cb5e2b22592cf7e39429b9ae291b73c0eb5e747

Contents?: true

Size: 572 Bytes

Versions: 9

Compression:

Stored size: 572 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table, '#each' do
  let(:header) { ['Header1'] }
  let(:rows)   { [['a1'], ['b1']] }

  subject(:table) { described_class.new(header, rows) }

  context 'with no block' do
    it { expect(table.each).to be_instance_of(to_enum.class) }

    it 'yields the expected values' do
      expect(table.each.to_a).to eql(table.to_a)
    end
  end

  context 'with block' do
    it 'yields each row' do
      yields = []
      table.each { |row| yields << row }
      expect(yields).to eql(table.to_a)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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