Hacker News new | past | comments | ask | show | jobs | submit login
Testing Ruby Code Like a Pro: The Power of RSpec Mocks and Doubles (rubystacknews.com)
3 points by gsgermanok 10 days ago | hide | past | favorite | 2 comments





Personally I preffer to use minitest and use dependency injection rather than the magic "allow to_receive and_return" parts of rspec. This makes my code more reusable.

But don't get me wrong, I won't refuse using rspec if it's already set up for a project, just wish it wasn't the go to default. I do believe the ruby + rails code people write would be better architected and more reusable with minitest + D.I. rather than rspec.


I could never warm to MiniTest, even though I want to as it's in the standard lib and I dislike unnecessary dependencies.

I've not checked recently but last time I used it didn't provide colour output without plugins and didn't include verifying doubles or spies out of the box.

There were a lot of other decisions required to make Minitest plesant in non-rails projects.

You can still use dependency injection with Rspec, it's just a nicer experience IMHO.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: