Sha256: 64c5937b314d90091917c83941f7dc1555c41e0446c9246e792981f10691cd9b

Contents?: true

Size: 1.98 KB

Versions: 3

Compression:

Stored size: 1.98 KB

Contents

RSpec.describe TTY::Box, ':padding option' do
  it "padds internal content without position arguments" do
    box = TTY::Box.frame(width: 30, height: 6, padding: 1) do
      "Drawing a box in terminal emulator"
    end

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

  it "padds internal content with with padding as integer" do
    box = TTY::Box.frame(top: 0, left: 0, width: 30, height: 6, padding: 1) do
      "Drawing a box in terminal emulator"
    end

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

  it "padds internal content with padding as array" do
    box = TTY::Box.frame(top: 0, left: 0, width: 30, height: 6, padding: [1,3,1,3]) do
      "Drawing a box in terminal emulator"
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

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