Factory_girl or machinist? [closed]
Are you using factory_girl or machinist for stubbing/mocking in Rails tests?
No. Those libraries are not stubbing/mocking libraries*.
Both Machinist and Factory Girl are libraries that help you instantiate objects in your tests without the fuss of fixtures. After you've instantiated an object using one of these libraries, you might then mock or stub methods on that object, but Factory Girl and Machinist wouldn't have anything to do with that.
Check out Mocha for stubbing/mocking.
*Factory Girl has a stubbing feature that's specifically for stubbing models, but nothing for general stubbing/mocking.
I'm using factory_girl. I haven't tried machinist so I can't compare the two, but I'm quite happy with factory_girl.
精彩评论