Skip to content

Instantly share code, notes, and snippets.

@scherztc
Created October 30, 2015 13:19
Show Gist options
  • Save scherztc/3618d45859e9b6fc1da7 to your computer and use it in GitHub Desktop.
Save scherztc/3618d45859e9b6fc1da7 to your computer and use it in GitHub Desktop.
require 'spec_helper'
def render_error
@email_notifier = ExceptionNotifier.registered_exception_notifier(:email)
begin
raise ActiveRecord::RecordNotFound
rescue => e
@exception = e
end
end
describe ExceptionNotifier do
it "should send notification if an exception is raised" do
render_error
ExceptionNotifier.should receive(:notify).with(["scholar_error@uc.edu"],["ERROR"],30)
end
it "should Activate Action Mailer if an exception is raised" do
ActionMailer::Base.delivery_method = 'test'
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
@size_before = ActionMailer::Base.deliveries.count
lambda { render_error }.should raise_error(ActiveRecord::RecordNotFound)
ActionMailer::Base.deliveries.count.should eql(@size_before + 1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment