Sha256: e502adc92ed8bd30a4d75f555504e8d06248e4ef0619d26f118efd2ce4549896

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

RSpec.describe TTY::Box, ':align option' do
  it "aligns content without positioning" do
    box = TTY::Box.frame(width: 26, height: 4, align: :center) do
      "Drawing a box in terminal emulator"
    end

    expect(box).to eq([
      "┌────────────────────────┐\n",
      "│   Drawing a box in     │\n",
      "│   terminal emulator    │\n",
      "└────────────────────────┘\n"
    ].join)
  end

  it "aligns content with the option" do
    box = TTY::Box.frame(top: 0, left: 0, width: 26, height: 4, align: :center) do
      "Drawing a box in terminal emulator"
    end

    expect(box).to eq([
      "\e[1;1H┌────────────────────────┐",
      "\e[2;1H│   Drawing a box in     \e[2;26H│",
      "\e[3;1H│   terminal emulator    \e[3;26H│",
      "\e[4;1H└────────────────────────┘"
    ].join)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tty-box-0.4.1 spec/unit/align_spec.rb
tty-box-0.4.0 spec/unit/align_spec.rb
tty-box-0.3.0 spec/unit/align_spec.rb
tty-box-0.2.1 spec/unit/align_spec.rb