spec/rollbar_spec.rb in rollbar-0.10.7 vs spec/rollbar_spec.rb in rollbar-0.10.8
- old
+ new
@@ -152,10 +152,29 @@
Rollbar.stub(:schedule_payload) do |*args| end
exception_data = Rollbar.report_exception(StandardError.new("oops"))
exception_data[:uuid].should_not be_nil
end
end
+
+ it 'should report exception objects with nonstandard backtraces' do
+ payload = nil
+ Rollbar.stub(:schedule_payload) do |*args|
+ payload = MultiJson.load(args[0])
+ end
+
+ class CustomException < StandardError
+ def backtrace
+ ["custom backtrace line"]
+ end
+ end
+
+ exception = CustomException.new("oops")
+
+ Rollbar.report_exception(exception)
+
+ payload["data"]["body"]["trace"]["frames"][0]["method"].should == "custom backtrace line"
+ end
end
context 'report_message' do
before(:each) do
configure
@@ -196,11 +215,12 @@
a = { :foo => "bar" }
b = { :a => a }
c = { :b => b }
a[:c] = c
- logger_mock.should_receive(:error).with(/\[Rollbar\] Error reporting message to Rollbar: (nesting of \d+ is too deep|object references itself)/)
+ logger_mock.should_receive(:error).with(/\[Rollbar\] Reporting internal error encountered while sending data to Rollbar./)
+
Rollbar.report_message("Test message with circular extra data", 'debug', a)
end
it 'should be able to report form validation errors when they are present' do
logger_mock.should_receive(:info).with('[Rollbar] Success')
@@ -573,9 +593,33 @@
data[:project_package_paths].length.should == gem_paths.length
data[:project_package_paths].each_with_index{|path, index|
path.should == gem_paths[index]
}
+ end
+ end
+
+ context "report_internal_error" do
+ it "should not crash when given an exception object" do
+ begin
+ 1 / 0
+ rescue => e
+ Rollbar.send(:report_internal_error, e)
+ end
+ end
+ end
+
+ context "send_failsafe" do
+ it "should not crash when given a message and exception" do
+ begin
+ 1 / 0
+ rescue => e
+ Rollbar.send(:send_failsafe, "test failsafe", e)
+ end
+ end
+
+ it "should not crash when given all nils" do
+ Rollbar.send(:send_failsafe, nil, nil)
end
end
# configure with some basic params
def configure