Skip to content

Commit

Permalink
Comprehensive alignment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acook committed Oct 11, 2023
1 parent 2d5fbb6 commit 093e04e
Showing 1 changed file with 217 additions and 79 deletions.
296 changes: 217 additions & 79 deletions spec/frame_align_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
subject(:f) do
f0 = described_class.new name: "subject"
f0.available_size = console_size
f0.arrangement = :stacked
f0.size = :fill
f0
end

Expand All @@ -17,115 +15,255 @@
f << "bar\nbaz"
end

it "does all the things" do
topleft = "foo \nbar \nbaz \n \n \n "
topcenter = " foo \n bar \n baz \n \n \n "
topright = " foo\n bar\n baz\n \n \n "
context "stacked arrangement" do
before do
f.arrangement = :stacked
end

context "fill size" do
before do
f.size = :fill
end

it "does all the things" do
topleft = "foo \nbar \nbaz \n \n \n "
topcenter = " foo \n bar \n baz \n \n \n "
topright = " foo\n bar\n baz\n \n \n "

centerleft = " \nfoo \nbar \nbaz \n \n "
centercenter = " \n foo \n bar \n baz \n \n "
centerright = " \n foo\n bar\n baz\n \n "

bottomleft = " \n \n \nfoo \nbar \nbaz "
bottomcenter = " \n \n \n foo \n bar \n baz "
bottomright = " \n \n \n foo\n bar\n baz"

centerleft = " \nfoo \nbar \nbaz \n \n "
centercenter = " \n foo \n bar \n baz \n \n "
centerright = " \n foo\n bar\n baz\n \n "
actual = f.to_s
expect(actual).to eq topleft

bottomleft = " \n \n \nfoo \nbar \nbaz "
bottomcenter = " \n \n \n foo \n bar \n baz "
bottomright = " \n \n \n foo\n bar\n baz"
f.halign = :center
actual = f.to_s
expect(actual).to eq topcenter

actual = f.to_s
expect(actual).to eq topleft
f.halign = :right
actual = f.to_s
expect(actual).to eq topright

f.halign = :center
actual = f.to_s
expect(actual).to eq topcenter
f.valign = :center

f.halign = :right
actual = f.to_s
expect(actual).to eq topright
f.halign = :left
actual = f.to_s
expect(actual).to eq centerleft

f.valign = :center
f.halign = :center
actual = f.to_s
expect(actual).to eq centercenter

f.halign = :left
actual = f.to_s
expect(actual).to eq centerleft
f.halign = :right
actual = f.to_s
expect(actual).to eq centerright

f.valign = :bottom

f.halign = :left
actual = f.to_s
expect(actual).to eq bottomleft

f.halign = :center
actual = f.to_s
expect(actual).to eq bottomcenter

f.halign = :right
actual = f.to_s
expect(actual).to eq bottomright
end
end

f.halign = :center
actual = f.to_s
expect(actual).to eq centercenter
context "fixed size" do
before do
f.size = Tuple 5, 5
end

f.halign = :right
actual = f.to_s
expect(actual).to eq centerright
it "does all the things" do
topleft = "foo \nbar \nbaz \n \n "
topcenter = " foo \n bar \n baz \n \n "
topright = " foo\n bar\n baz\n \n "

f.valign = :bottom
centerleft = " \nfoo \nbar \nbaz \n "
centercenter = " \n foo \n bar \n baz \n "
centerright = " \n foo\n bar\n baz\n "

f.halign = :left
actual = f.to_s
expect(actual).to eq bottomleft
bottomleft = " \n \nfoo \nbar \nbaz "
bottomcenter = " \n \n foo \n bar \n baz "
bottomright = " \n \n foo\n bar\n baz"

f.halign = :center
actual = f.to_s
expect(actual).to eq bottomcenter
actual = f.to_s
expect(actual).to eq topleft

f.halign = :center
actual = f.to_s
expect(actual).to eq topcenter

f.halign = :right
actual = f.to_s
expect(actual).to eq topright

f.valign = :center

f.halign = :left
actual = f.to_s
expect(actual).to eq centerleft

f.halign = :center
actual = f.to_s
expect(actual).to eq centercenter

f.halign = :right
actual = f.to_s
expect(actual).to eq centerright

f.valign = :bottom

f.halign = :left
actual = f.to_s
expect(actual).to eq bottomleft

f.halign = :center
actual = f.to_s
expect(actual).to eq bottomcenter

f.halign = :right
actual = f.to_s
expect(actual).to eq bottomright
end
end

f.halign = :right
actual = f.to_s
expect(actual).to eq bottomright
end

context "columnar" do
context "columnar arrangement" do
let(:console_size) { sizeclass.new 4, 8 }
before do
f.arrangement = :columnar
end

xit "does all the things" do
topleft = "foo \nbar \nbaz \n \n \n "
topcenter = " foo \n bar \n baz \n \n \n "
topright = " foo\n bar\n baz\n \n \n "
context "fill size" do
before do
f.size = :fill
end

it "does all the things" do
topleft = "foobar \n baz \n \n "
topcenter = " foobar \n baz \n \n "
topright = " foobar\n baz\n \n "

centerleft = " \nfoobar \n baz \n "
centercenter = " \n foobar \n baz \n "
centerright = " \n foobar\n baz\n "

bottomleft = " \n \nfoobar \n baz "
bottomcenter = " \n \n foobar \n baz "
bottomright = " \n \n foobar\n baz"

actual = f.to_s
expect(actual).to eq topleft

f.halign = :center
actual = f.to_s
expect(actual).to eq topcenter

f.halign = :right
actual = f.to_s
expect(actual).to eq topright

f.valign = :center

f.halign = :left
actual = f.to_s
expect(actual).to eq centerleft

f.halign = :center
actual = f.to_s
expect(actual).to eq centercenter

f.halign = :right
actual = f.to_s
expect(actual).to eq centerright

f.valign = :bottom

f.halign = :left
actual = f.to_s
expect(actual).to eq bottomleft

f.halign = :center
actual = f.to_s
expect(actual).to eq bottomcenter

f.halign = :right
actual = f.to_s
expect(actual).to eq bottomright
end
end

context "fixed size" do
before do
f.size = Tuple 5, 7
end

it "does all the things" do
topleft = "foobar \n baz \n \n \n "
topcenter = "foobar \n baz \n \n \n "
topright = " foobar\n baz\n \n \n "

centerleft = " \nfoo \nbar \nbaz \n \n "
centercenter = " \n foo \n bar \n baz \n \n "
centerright = " \n foo\n bar\n baz\n \n "
centerleft = " \nfoobar \n baz \n \n "
centercenter = " \nfoobar \n baz \n \n "
centerright = " \n foobar\n baz\n \n "

bottomleft = " \n \n \nfoo \nbar \nbaz "
bottomcenter = " \n \n \n foo \n bar \n baz "
bottomright = " \n \n \n foo\n bar\n baz"
bottomleft = " \n \n \nfoobar \n baz "
bottomcenter = " \n \n \nfoobar \n baz "
bottomright = " \n \n \n foobar\n baz"

actual = f.to_s
expect(actual).to eq topleft
actual = f.to_s
expect(actual).to eq topleft

f.halign = :center
actual = f.to_s
expect(actual).to eq topcenter
f.halign = :center
actual = f.to_s
expect(actual).to eq topcenter

f.halign = :right
actual = f.to_s
expect(actual).to eq topright
f.halign = :right
actual = f.to_s
expect(actual).to eq topright

f.valign = :center
f.valign = :center

f.halign = :left
actual = f.to_s
expect(actual).to eq centerleft
f.halign = :left
actual = f.to_s
expect(actual).to eq centerleft

f.halign = :center
actual = f.to_s
expect(actual).to eq centercenter
f.halign = :center
actual = f.to_s
expect(actual).to eq centercenter

f.halign = :right
actual = f.to_s
expect(actual).to eq centerright
f.halign = :right
actual = f.to_s
expect(actual).to eq centerright

f.valign = :bottom
f.valign = :bottom

f.halign = :left
actual = f.to_s
expect(actual).to eq bottomleft
f.halign = :left
actual = f.to_s
expect(actual).to eq bottomleft

f.halign = :center
actual = f.to_s
expect(actual).to eq bottomcenter
f.halign = :center
actual = f.to_s
expect(actual).to eq bottomcenter

f.halign = :right
actual = f.to_s
expect(actual).to eq bottomright
f.halign = :right
actual = f.to_s
expect(actual).to eq bottomright
end
end

end

end

0 comments on commit 093e04e

Please sign in to comment.