Sha256: 0811542f0c87bd723571a2078f201156801092c7f5b49f07fc98e97707a2659a

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

require 'example_helper'
require 'chatterbox/exception_notification'

describe Chatterbox::ExceptionNotification::Extracter do

  describe "notice" do
    it "merges default summary if none provided" do
      data = Chatterbox::ExceptionNotification::Extracter.new({}).notice
      data[:summary].should == "N/A"
    end
    
    it "merges environment hash" do
      hsh = {}
      data = Chatterbox::ExceptionNotification::Extracter.new(hsh).notice
      data[:environment].should == ENV.to_hash
    end

    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 "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

5 entries across 5 versions & 1 rubygems

Version Path
chatterbox-0.8.5 examples/lib/chatterbox/exception_notification/extracter_example.rb
chatterbox-0.8.4 examples/lib/chatterbox/exception_notification/extracter_example.rb
chatterbox-0.8.3 examples/lib/chatterbox/exception_notification/extracter_example.rb
chatterbox-0.8.2 examples/lib/chatterbox/exception_notification/extracter_example.rb
chatterbox-0.8.1 examples/lib/chatterbox/exception_notification/extracter_example.rb