From 36fd93832579d31814222bfe7dad9284497957e1 Mon Sep 17 00:00:00 2001 From: Glenn Date: Mon, 15 Jan 2024 02:06:28 +0100 Subject: [PATCH] feat: add basic support for spec --- spec/spec_helper.cr | 1 + spec/utils/breadcrumbs_spec.cr | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 spec/spec_helper.cr create mode 100644 spec/utils/breadcrumbs_spec.cr diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr new file mode 100644 index 0000000..e2f4f80 --- /dev/null +++ b/spec/spec_helper.cr @@ -0,0 +1 @@ +require "spec" diff --git a/spec/utils/breadcrumbs_spec.cr b/spec/utils/breadcrumbs_spec.cr new file mode 100644 index 0000000..deec943 --- /dev/null +++ b/spec/utils/breadcrumbs_spec.cr @@ -0,0 +1,46 @@ +require "../spec_helper" +require "../../src/utils/breadcrumbs" + +describe GX::Utils::BreadCrumbs do + context "Initialization" do + it "can initialize from array" do + # empty string + b1 = GX::Utils::BreadCrumbs.new([] of String) + b1.to_a.should be_empty + + # simple string + b2 = GX::Utils::BreadCrumbs.new(["test1"]) + b2.to_a.should eq(["test1"]) + + # array + b3 = GX::Utils::BreadCrumbs.new(["test1", "test2"]) + b3.to_a.should eq(["test1", "test2"]) + end + end + + context "Functioning" do + it "can add values" do + # empty string + b1 = GX::Utils::BreadCrumbs.new([] of String) + b1.to_a.should be_empty + + # simple string + b2 = b1 + "test1" + b2.to_a.should eq(["test1"]) + + b3 = b2 + "test2" + b3.to_a.should eq(["test1", "test2"]) + end + + it "can become a string" do + b1 = GX::Utils::BreadCrumbs.new([] of String) + b1.to_s.should eq("") + + b2 = b1 + "test1" + b2.to_a.should eq("test1") + + b3 = b2 + "test2" + b3.to_a.should eq("test1 test2") + end + end +end