Sha256: 778492034461e70abbcfe6348f2260232d9f743bd92d43c24e90dde0889da1e5

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require 'example_helper'
require 'chatterbox/exception_notification'

describe Chatterbox::ExceptionNotification::Extracter do

  describe "notice" do
    it "merges ruby info" do
      hsh = {}
      data = Chatterbox::ExceptionNotification::Extracter.new(hsh).notice
      data[:ruby_info][:ruby_version].should == RUBY_VERSION
      data[:ruby_info][:ruby_platform].should == RUBY_PLATFORM
    end
    
    it "merges environment hash" do
      hsh = {}
      data = Chatterbox::ExceptionNotification::Extracter.new(hsh).notice
      data[:environment].should == ENV.to_hash
    end

    it "should extract exception info from an exception in a hash" do
      exception = RuntimeError.new("Your zing bats got mixed up with the snosh frazzles.")
      data = Chatterbox::ExceptionNotification::Extracter.new(:exception => exception, :other_info => "yo dawg").notice
      data[:summary].should == "RuntimeError: Your zing bats got mixed up with the snosh frazzles."
      data[:error_class].should == "RuntimeError"
      data[:error_message].should == "Your zing bats got mixed up with the snosh frazzles."
      data[:backtrace].should == exception.backtrace
      data[:other_info].should == "yo dawg"
    end

    it "should let extra data win over auto extracted exception data" do
      data = Chatterbox::ExceptionNotification::Extracter.new(:exception => Exception.new, :summary => "I know what I'm doing, and we got an error").notice
      data[:summary].should == "I know what I'm doing, and we got an error"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chatterbox-0.6.2 examples/lib/chatterbox/exception_notification/extracter_example.rb
chatterbox-0.6.1 examples/lib/chatterbox/exception_notification/extracter_example.rb
chatterbox-0.6.0 examples/lib/chatterbox/exception_notification/extracter_example.rb