Sha256: c8554698d1ecdb160bb5f7ccbb1e9ff161ed01120a20d0d4490d0efe51242800

Contents?: true

Size: 662 Bytes

Versions: 3

Compression:

Stored size: 662 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Table::Operations, '#new' do
  let(:object) { described_class }
  let(:row)    { [1,2,3] }
  let(:table)  { TTY::Table.new :rows => [row] }
  let(:callable) {
    Class.new do
      def call(val, row, col)
        val.value= val.value + 1
      end
    end
  }
  let(:instance) { callable.new }

  subject { object.new table }

  before { subject.add(:alignment, instance) }

  it 'stores away operations' do
    expect(subject.operations[:alignment]).to include(instance)
  end

  it 'runs selected operations' do
    subject.run_operations(:alignment)
    expect(table.data[0]).to eql([2,3,4])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-0.1.2 spec/tty/table/operations/new_spec.rb
tty-0.1.1 spec/tty/table/operations/new_spec.rb
tty-0.1.0 spec/tty/table/operations/new_spec.rb