I've just started using Observers in a Rails application I'm creating and found out that in order to have them picked up by rails you have to manually register the Observers within your environment.rb file, like so:
config.active_record.observers = :my_observer
I like to have as much coverage for any code I write in Rails, such as associations I've created, validation rules etc. I'm not testing the validation itself (Rails' tests have that covered) what I'm testing is that I've actually applied the validation rule.
So I figured that I should do the same for the Observers which should be registered. I couldn't find any references to anyone else doing this so after a little bit of digging I've come up with the following approach for use with RSpec:
Continue reading this entry »