@@ -10,6 +10,7 @@ module Alchemy
1010 subject { definition . attributes }
1111
1212 it { is_expected . to have_key ( :name ) }
13+ it { is_expected . to have_key ( :icon ) }
1314 it { is_expected . to have_key ( :unique ) }
1415 it { is_expected . to have_key ( :amount ) }
1516 it { is_expected . to have_key ( :taggable ) }
@@ -28,6 +29,14 @@ module Alchemy
2829 it { is_expected . to validate_presence_of ( :name ) }
2930 it { is_expected . to allow_value ( "article" ) . for ( :name ) }
3031 it { is_expected . to_not allow_value ( "Article Element" ) . for ( :name ) }
32+
33+ it { is_expected . to allow_value ( true ) . for ( :icon ) }
34+ it { is_expected . to allow_value ( "article" ) . for ( :icon ) }
35+ it { is_expected . to allow_value ( "Article_2" ) . for ( :icon ) }
36+ it { is_expected . to allow_value ( "article2-line" ) . for ( :icon ) }
37+ it { is_expected . to_not allow_value ( "Article Icon" ) . for ( :icon ) }
38+ it { is_expected . to_not allow_value ( "article.svg" ) . for ( :icon ) }
39+ it { is_expected . to_not allow_value ( "Article.png" ) . for ( :icon ) }
3140 end
3241
3342 it_behaves_like "having a hint" do
@@ -90,6 +99,26 @@ module Alchemy
9099 end
91100 end
92101
102+ describe "#icon_name" do
103+ subject ( :icon_name ) { definition . icon_name }
104+
105+ context "with icon attribute being true" do
106+ let ( :definition ) { described_class . new ( name : "article" , icon : true ) }
107+
108+ it "returns the name attribute" do
109+ expect ( icon_name ) . to eq ( "article" )
110+ end
111+ end
112+
113+ context "with icon attribute being a string" do
114+ let ( :definition ) { described_class . new ( icon : "article-line" ) }
115+
116+ it "returns the icon attribute" do
117+ expect ( icon_name ) . to eq ( "article-line" )
118+ end
119+ end
120+ end
121+
93122 describe "#ingredients" do
94123 let ( :definition ) { described_class . new }
95124
0 commit comments