DEV Community

Discussion on: Introduction to OpenStruct

Collapse
 
derekjhopper profile image
Derek Hopper

Great post. I'll sometimes use OpenStruct in tests if I need a more complex mock. I think it reads better than some of the other mechanisms and you can do a lot with it. Recently, we needed to mock an API response which comes back as an object, so I used OpenStruct to create just the parts that were needed.

I know it's easy to reach for gems and libraries to help us, but sometimes you can get by just fine with PORO and Ruby standard library.

Collapse
 
cseeman profile image
christine

Awesome use-case, I might give that a try out too.