-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add alignment and ansi check to top level
- Loading branch information
1 parent
9e24f2b
commit b847363
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Strings, '#align' do | ||
it "aligns text" do | ||
text = "the madness of men" | ||
expect(Strings.align(text, 22, direction: :center)).to eq(" the madness of men ") | ||
end | ||
|
||
it "aligns text to left" do | ||
text = "the madness of men" | ||
expect(Strings.align_left(text, 22)).to eq("the madness of men ") | ||
end | ||
|
||
it "aligns text to right" do | ||
text = "the madness of men" | ||
expect(Strings.align_right(text, 22)).to eq(" the madness of men") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Strings, '#ansi?' do | ||
it "removes ansi codes" do | ||
expect(Strings.ansi?("\e[33mfoo\e[0m")).to eq(true) | ||
end | ||
end |