Rails Model Testing - Mocking vs. Factories
问题 What's the best practice for Rails testing for mocking objects vs. using factory objects. Should mocking only be used when a model might go to an external source? Or do you only use factories when you're testing the actual model and using mocking for everything else. For example if we have a sales system with customers and orders when we test the customer models do we mock the order or do we just use a factory order? Does it even make a difference? 回答1: We've had this debate often at our web