Rspec test callbacks error

I am trying to test that a callback is run in an AR model (Rails 3) and am getting an error. As far as I can see I am following the api.doc example closely so am a bit confused as to the error. class SystemError < ActiveRecord::Base after_save :notify_administrator_of def notify_administrator_of sysadmin_user = User.find_by_role_id(Role.find_by_name(‘sysadmin’).id) SystemMailer.generic_email(sysadmin_user.email, “Wavelineup Error: #{Rails.env} - #{self.error}”, “#{self.incidentals}”).deliver end end I am following the following instructions which look like are just an excerpt from the api.dock: http://gem-session.com/2010/03/how-to-test-callback-methods-in-rails I get the following failure:

  1. SystemError after_save should send an email to the admin after save Failure/Error: system_error.run_callbacks(:after_save) undefined method `_run_after_save_callbacks’ for #SystemError:0x21a1a60

    ./spec/models/system_error_spec.rb:8:in `block (2 levels) in <top (required)>’

My spec is:

describe “SystemError after_save” do

it “should send an email to the admin after save” do system_error = SystemError.new system_error.should_receive(:notify_administrator_of) system_error.run_callbacks(:after_save) end

end

I'm running into the same issue - did you resolve this or open up a ticket for it?

I dug into this a bit more and found the following thread useful: https://rails.lighthouseapp.com/projects/8994/tickets/5472-unable-to-manually-run-activerecord-object-callbacks