@@ -177,6 +177,51 @@ def render
177177 end
178178 expect_evaluate_ruby ( 'Foo.instance == Foo.instance.force_update!' ) . to be_truthy
179179 end
180+
181+ it 'has a class components method' do
182+ mount 'Foo' do
183+ class Bar < HyperComponent
184+ param :id
185+ render { inspect }
186+ end
187+ class Baz < HyperComponent
188+ param :id
189+ render { inspect }
190+ end
191+ class BarChild < Bar
192+ end
193+ class Foo
194+ include Hyperstack ::Component
195+ def render
196+ DIV do
197+ Bar ( id : 1 )
198+ Bar ( id : 2 )
199+ Baz ( id : 3 )
200+ Baz ( id : 4 )
201+ BarChild ( id : 5 )
202+ BarChild ( id : 6 )
203+ end
204+ end
205+ end
206+ module Hyperstack ::Component
207+ def to_s
208+ "#{ self . class . name } #{ ':' + @Id . to_s if @Id } "
209+ end
210+ end
211+ end
212+ expect_evaluate_ruby ( "Hyperstack::Component.mounted_components" )
213+ . to contain_exactly ( "Hyperstack::Internal::Component::TopLevelRailsComponent" , "Foo" , "Bar:1" , "Bar:2" , "Baz:3" , "Baz:4" , "BarChild:5" , "BarChild:6" )
214+ expect_evaluate_ruby ( "HyperComponent.mounted_components" )
215+ . to contain_exactly ( "Bar:1" , "Bar:2" , "Baz:3" , "Baz:4" , "BarChild:5" , "BarChild:6" )
216+ expect_evaluate_ruby ( "Bar.mounted_components" )
217+ . to contain_exactly ( "Bar:1" , "Bar:2" , "BarChild:5" , "BarChild:6" )
218+ expect_evaluate_ruby ( "Baz.mounted_components" )
219+ . to contain_exactly ( "Baz:3" , "Baz:4" )
220+ expect_evaluate_ruby ( "BarChild.mounted_components" )
221+ . to contain_exactly ( "BarChild:5" , "BarChild:6" )
222+ expect_evaluate_ruby ( "Foo.mounted_components" )
223+ . to contain_exactly ( "Foo" )
224+ end
180225 end
181226
182227 describe 'state management' do
0 commit comments