I have a before_save filter on my model class which sets a date field to a future date to guarantee the integrity of the data.
This works really well except with it comes to unit testing. I’d like to set up a test scenario which involves setting this date field to a date in the past. I can’t do this using ActiveRecord because the before_save filter is called and the date is updated to a future date. Is the best way to do this to execute raw SQL using ActiveRecord::Base::connection.update?
Maybe utilizing a mock object would be best. For a quick intro to mock objects read
http://erikonrails.wordpress.com/2008/05/07/how-to-use-mock-objects/