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.
Former Java engineer turned Ruby engineer who is trying to understand Ruby and Rails, MacOS and a lot of other things. Worked at Flywheel, FNBO, ACI Worldwide.
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.
Awesome use-case, I might give that a try out too.