@@ -2,28 +2,33 @@ require "spec"
22require " ../src/gradientty"
33
44describe " Gradientty" do
5- it " prints predefined gradients correctly" do
6- custom = Gradientty .gradient([" #ff5f6d" , " #ffc371" ])
5+ it " generates ANSI-colored strings for predefined gradients" do
6+ test_str = " Gradient Test"
7+
8+ gradients = {
9+ " rainbow" => Gradientty .rainbow(test_str),
10+ " crystal" => Gradientty .crystal(test_str),
11+ " pastel" => Gradientty .pastel(test_str),
12+ " vice" => Gradientty .vice(test_str),
13+ }
714
8- output_0 = Gradientty .rainbow(" A test for testing string with gradient." )
9- output_1 = Gradientty .crystal(" A test for testing string with gradient." )
10- output_2 = Gradientty .pastel(" A test for testing string with gradient." )
11- output_3 = Gradientty .vice(" A test for testing string with gradient." )
12- output_4 = custom.call(" CUSTOM" )
13- output_5 = custom.multiline(" LINE1\n LINE2" )
15+ gradients.each do |name , output |
16+ output.should_not eq " "
17+ # Check that ANSI escape codes exist
18+ output.should match(/\e\[ 38;2;\d +;\d +;\d +m/ )
19+ end
20+ end
21+
22+ it " generates ANSI-colored strings for custom gradients" do
23+ custom = Gradientty .gradient([" #ff5f6d" , " #ffc371" ])
24+ output_1 = custom.call(" CUSTOM" )
25+ output_2 = custom.multiline(" LINE1\n LINE2" , true )
1426
15- output_0.should_not eq " "
1627 output_1.should_not eq " "
1728 output_2.should_not eq " "
18- output_3.should_not eq " "
19- output_4.should_not eq " "
20- output_5.should_not eq " "
2129
22- puts output_0
23- puts output_1
24- puts output_2
25- puts output_3
26- puts output_4
27- puts output_5
30+ # Check that ANSI escape codes exist
31+ output_1.should match(/\e\[ 38;2;\d +;\d +;\d +m/ )
32+ output_2.should match(/\e\[ 38;2;\d +;\d +;\d +m/ )
2833 end
2934end
0 commit comments