File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -20,5 +20,17 @@ def configure(&block)
20
20
def build ( ...)
21
21
Instance . new ( ...)
22
22
end
23
+
24
+ def definitions
25
+ @definitions ||= { }
26
+ end
27
+
28
+ def define ( name , ...)
29
+ definitions [ name . to_sym ] = Instance . new ( ...)
30
+ end
31
+
32
+ def for ( name )
33
+ definitions [ name . to_sym ]
34
+ end
23
35
end
24
36
end
Original file line number Diff line number Diff line change
1
+ require "test_helper"
2
+
3
+ class DefinitionsTest < Minitest ::Test
4
+ def setup
5
+ ClassVariants . define :button do
6
+ variant color : :primary , class : "bg-orange-500"
7
+ end
8
+
9
+ ClassVariants . define :link do
10
+ variant color : :primary , class : "bg-blue-500"
11
+ end
12
+ end
13
+
14
+ def teardown
15
+ ClassVariants . instance_variable_set ( :@definitions , nil )
16
+ end
17
+
18
+ def test_definitions
19
+ assert_equal "bg-orange-500" , ClassVariants . for ( :button ) . render ( color : :primary )
20
+ assert_equal "bg-blue-500" , ClassVariants . for ( :link ) . render ( color : :primary )
21
+ end
22
+ end
You can’t perform that action at this time.
0 commit comments