Sha256: 5a0dd375448b1c493b354fcaad71a1547607e2ec78f126f808cda19f237c14e3

Contents?: true

Size: 975 Bytes

Versions: 3

Compression:

Stored size: 975 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Table::Operation::Wrapped, '#call' do
  let(:padding) { TTY::Table::Padder.parse }
  let(:object) { described_class.new(column_widths, padding) }
  let(:text)   { 'ラドクリフ、マラソン五輪代表に1万m出場にも含み' }
  let(:field)  { TTY::Table::Field.new(text) }

  context 'without column width' do
    let(:column_widths) { [] }

    it "doesn't wrap string" do
      object.call(field, 0, 0)
      expect(field.value).to eql(text)
    end
  end

  context 'with column width' do
    let(:column_widths) { [12, 14] }

    it "wraps string for 0 column" do
      object.call(field, 0, 0)
      expect(field.value).to eql("ラドクリフ、マラソン五輪\n代表に1万m出場にも含み")
    end

    it "wraps string for 1 column" do
      object.call(field, 0, 1)
      expect(field.value).to eql("ラドクリフ、マラソン五輪代表\nに1万m出場にも含み")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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