Sha256: f6a922c333e2e2e0855f85fd9f6662372cd1eb421cde73ff79bed11d5bb493ae

Contents?: true

Size: 1014 Bytes

Versions: 9

Compression:

Stored size: 1014 Bytes

Contents

# coding: utf-8

require 'spec_helper'

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

  subject(:operation) { described_class.new(column_widths) }

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

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

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

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

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