rubymonolith / superform

Build highly customizable forms in Rails
MIT License
263 stars 14 forks source link

Adds specs for core classes #30

Closed nolantait closed 2 months ago

nolantait commented 3 months ago

I was wanting to experiment with the library more and needed a test harness around the classes. Feel free to take what you want from here.

One spec is failing for the Superform::NamespaceCollection#assign. Not sure if this is the intended behavior or not but the namespace enumerator is altering the namespaces of objects that don't stick around between invocations of the enumerator. Could use some guidance here.

This PR also separates the classes out into files and formats for line length. I tried to leave the core code alone except for some small formatting changes. But you can always just use the spec folder.

I also added a development dependency for debug.

UPDATE: I figured out the namespace collection thing and pushed a fix to my spec. Turns out it was because of using doubles instead of an OpenStruct. I guess the collection namespace can't depend on the internal values of the fields for the reason I outlined above.

bradgessler commented 2 months ago

Yay tests! Thanks again for making these commits.