Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
Include Chatterbox version at the bottom of exception notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
rsanheim committed Dec 7, 2009
1 parent fae3200 commit 152197c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
31 changes: 31 additions & 0 deletions features/exception_notification.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Feature: Exception Notification

As a Chatterbox user
I want to use Chatterbox for exception notifications
So that I can deliver notifications over email

Scenario: Exceptions include the Chatterbox version string
Given a file named "exceptions.rb" with:
"""
require "chatterbox"
require "chatterbox/exception_notification"
require "chatterbox/services/email"
ActionMailer::Base.delivery_method = :test
Chatterbox::Publishers.register do |notice|
Chatterbox::Services::Email.deliver(notice)
end
begin
1 / 0
rescue => exception
Chatterbox::ExceptionNotification.handle(:exception => exception,
:config => { :to => "to@example.com", :from => "from@example.com" })
end
puts ActionMailer::Base.deliveries.last.encoded
"""
When I run "exceptions.rb"
Then the exit code should be 0
And the stdout should contain the Chatterbox version string message

4 changes: 4 additions & 0 deletions features/step_definitions/exception_notification_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Then /^the stdout should contain the Chatterbox version string message$/ do
version = Chatterbox::Version::STRING
Then %{the stdout should match "Chatterbox Version #{version}"}
end
2 changes: 2 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. lib])))
require 'chatterbox'
require 'tempfile'
require 'pathname'
require 'spec'
Expand Down
3 changes: 2 additions & 1 deletion lib/chatterbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ def clear!
end
end

require "chatterbox/services"
require "chatterbox/services"
require "chatterbox/version"
3 changes: 2 additions & 1 deletion lib/chatterbox/exception_notification/extracter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def notice

def extract_default_info(hash)
hsh = { :summary => "N/A",
:environment => ENV.to_hash
:environment => ENV.to_hash,
:chatterbox_info => "Chatterbox Version #{Chatterbox::Version::STRING}"
}.merge(hash)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/chatterbox/exception_notification/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def to_message
end

def error_details
[:error_message, :request, :backtrace, :environment, :ruby_info, :rails_info]
[:error_message, :request, :backtrace, :environment, :ruby_info, :rails_info, :chatterbox_info]
end

def render_body
Expand Down

0 comments on commit 152197c

Please sign in to comment.