From d0da584f5ed1bcab7b625bdf1cee5b120cb11182 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 14 Mar 2019 19:42:30 -0600 Subject: [PATCH] Add tests for Color formatting module --- spec/fomatting/color_spec.cr | 93 ++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 spec/fomatting/color_spec.cr diff --git a/spec/fomatting/color_spec.cr b/spec/fomatting/color_spec.cr new file mode 100644 index 0000000..406b5db --- /dev/null +++ b/spec/fomatting/color_spec.cr @@ -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