avram icon indicating copy to clipboard operation
avram copied to clipboard

Be able to get attributes from Factory as named tuple

Open confact opened this issue 4 years ago • 2 comments

I want to test methods and classes with params from my boxes.

It would be amazing to be able to get generated attributes from boxes as NamedTuple for passing to methods or something else.

confact avatar May 23 '20 14:05 confact

A Box is just a custom SaveOperation. You should be able to do something like:

box = UserBox.create
box.attributes

jwoertink avatar May 23 '20 15:05 jwoertink

The problem with that is you need to create the record. If you want to use this to test Api:Users::Create for example this would not work quite right.

I think what this needs is #34 for building an unsaved model with a fake id. Then we can use that for something like UserBox.attributes or UserBox.attributes &.name("whatever"). This would be super awesome for testing APIs

paulcsmith avatar May 28 '20 14:05 paulcsmith