Month: December 2012
-
Silencing noise in the Rails development log
The standard Rails development log contains a lot of noise that is rarely meaningful for debugging. The Quiet Assets gem is a mandatory part of my Rails development process as it removes the logging noise of the asset pipeline. Also, if WEBrick is used as a development server, the following entry is logged for each…
-
Mocking instances created via ActiveRecord’s find
Most Ruby mocking frameworks have the ability to mock a new object created via a constructor. However, when an object is created via ActiveRecord’s find or find_by_* methods, the .new method isn’t invoked. Instead, the .instantiate method is called. For example, to specify :instantiate as the object creation method using FlexMock: