1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
# frozen_string_literal: true
require "spec_helper"
describe Clamp::Help::Builder do
subject(:builder) { described_class.new }
def output
builder.string
end
describe "#line" do
it "adds a line of text" do
builder.line("blah")
expect(output).to eq("blah\n")
end
end
describe "#row" do
it "adds two strings separated by spaces" do
builder.row("LHS", "RHS")
expect(output).to eq(" LHS RHS\n")
end
end
context "with multiple rows" do
before do
builder.row("foo", "bar")
builder.row("flibble", "blurk")
builder.row("x", "y")
end
let(:expected_output) do
[
" foo bar\n",
" flibble blurk\n",
" x y\n"
]
end
it "arranges them in two columns" do
expect(output.lines).to eq expected_output
end
end
context "with a mixture of lines and rows" do
before do
builder.line("ABCDEFGHIJKLMNOP")
builder.row("flibble", "blurk")
builder.line("Another section heading")
builder.row("x", "y")
end
let(:expected_output) do
[
"ABCDEFGHIJKLMNOP\n",
" flibble blurk\n",
"Another section heading\n",
" x y\n"
]
end
it "still arranges them in two columns" do
expect(output.lines).to eq expected_output
end
end
end
|