Fixtures, mock objects or in-memory ActiveRecord objects?

Wilson Bilkovich has posted an article about mocking ActiveRecord objects.

A new method mock_model is defined that builds a mock object which will respond the same way as a real ActiveRecord object. As I understand it, this means he can replace…

@campaign = mock("campaign")


mock_model :campaign

Although I agree with him that using fixtures is not a good idea, why not use a real ActiveRecord object…

@campaign =

Sometimes due to the way ActiveRecord couples your models to the database, it becomes essential to have a model in the database and not just in memory. In which case why not just do this…

@campaign = Campaign.create!

I’ve written up a couple more thoughts here and here.