Add tests for Color formatting module

This commit is contained in:
Michael Miller 2019-03-14 19:42:30 -06:00
parent 33e3b5a811
commit d0da584f5e

View file

@ -0,0 +1,93 @@
require "../spec_helper"
describe Spectator::Formatting::Color do
describe "#success" do
it "includes the input text" do
text = "foobar"
output = Spectator::Formatting::Color.success(text)
output.to_s.should contain(text)
end
it "prefixes with green markers" do
output = Spectator::Formatting::Color.success("foobar")
output.to_s.should start_with("\e[32m")
end
it "appends color reset markers" do
output = Spectator::Formatting::Color.success("foobar")
output.to_s.should end_with("\e[0m")
end
end
describe "#failure" do
it "includes the input text" do
text = "foobar"
output = Spectator::Formatting::Color.failure(text)
output.to_s.should contain(text)
end
it "prefixes with green markers" do
output = Spectator::Formatting::Color.failure("foobar")
output.to_s.should start_with("\e[31m")
end
it "appends color reset markers" do
output = Spectator::Formatting::Color.failure("foobar")
output.to_s.should end_with("\e[0m")
end
end
describe "#error" do
it "includes the input text" do
text = "foobar"
output = Spectator::Formatting::Color.error(text)
output.to_s.should contain(text)
end
it "prefixes with green markers" do
output = Spectator::Formatting::Color.error("foobar")
output.to_s.should start_with("\e[35m")
end
it "appends color reset markers" do
output = Spectator::Formatting::Color.error("foobar")
output.to_s.should end_with("\e[0m")
end
end
describe "#pending" do
it "includes the input text" do
text = "foobar"
output = Spectator::Formatting::Color.pending(text)
output.to_s.should contain(text)
end
it "prefixes with green markers" do
output = Spectator::Formatting::Color.pending("foobar")
output.to_s.should start_with("\e[33m")
end
it "appends color reset markers" do
output = Spectator::Formatting::Color.pending("foobar")
output.to_s.should end_with("\e[0m")
end
end
describe "#comment" do
it "includes the input text" do
text = "foobar"
output = Spectator::Formatting::Color.comment(text)
output.to_s.should contain(text)
end
it "prefixes with green markers" do
output = Spectator::Formatting::Color.comment("foobar")
output.to_s.should start_with("\e[36m")
end
it "appends color reset markers" do
output = Spectator::Formatting::Color.comment("foobar")
output.to_s.should end_with("\e[0m")
end
end
end