I'm using observers in my Rails app for notifications, activity feeds, etc. They keep my models and controllers clean, work great on the app side, and in any non-integration test (I've unit tested them extensively/successfully). But I can't for the life of me get them working in integration tests. I have the following in spec/support/observers.rb (as a sanity check. I'd ideally only enable them for feature tests if I can get them to work at all):
RSpec.configure do |config|
config.before do
ActiveRecord::Base.observers.enable :all
end
end
No matter what I do, I can't get my observers to fire off during my integration tests (which is exactly what I really want to use to ensure that everything is truly working).
Does anyone have any insight on this or have any clue as to why I could be experiencing this? I'm using Rails 5.0.0beta3, and the latest versions of rails-observers, rspec-rails and capybara (from github master branches).
config.active_record.observers = :model_observer
– Thomas Walpole