Sha256: 489ba3a581251246effa2ac07edb78699f4118d56df5ed7aa8fd4cb8a5d91302

Contents?: true

Size: 1.25 KB

Versions: 21

Compression:

Stored size: 1.25 KB

Contents

require "spec_helper"

describe Timber::Events::Error, :rails_23 => true do
  describe ".initialize" do
    it "should clean the backtrace" do
      backtrace = [
        "/path/to/file1.rb:26:in `function1'",
        "path/to/file2.rb:86:in `function2'"
      ]

      exception_event = described_class.new(name: "RuntimeError", error_message: "Boom", backtrace: backtrace)
      expect(exception_event.backtrace).to eq([{:file=>"/path/to/file1.rb", :line=>26, :function=>"function1"}, {:file=>"path/to/file2.rb", :line=>86, :function=>"function2"}])
    end

    it "parses valid lines" do
      backtrace = [
        "/path/to/file1.rb:26:in `function1'",
        "path/to/file2.rb:86" # function names are optional
      ]

      exception_event = described_class.new(name: "RuntimeError", error_message: "Boom", backtrace: backtrace)
      expect(exception_event.backtrace).to eq([{:file=>"/path/to/file1.rb", :line=>26, :function=>"function1"}, {:file=>"path/to/file2.rb", :line=>86}])
    end

    it "handles malformed lines" do
      backtrace = [
        "malformed"
      ]

      exception_event = described_class.new(name: "RuntimeError", error_message: "Boom", backtrace: backtrace)
      expect(exception_event.backtrace).to eq([{:file=>"malformed"}])
   end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
timber-2.5.1 spec/timber/events/error_spec.rb
timber-2.5.0 spec/timber/events/error_spec.rb
timber-2.4.0 spec/timber/events/error_spec.rb
timber-2.3.4 spec/timber/events/error_spec.rb
timber-2.3.3 spec/timber/events/error_spec.rb
timber-2.3.2 spec/timber/events/error_spec.rb
timber-2.3.1 spec/timber/events/error_spec.rb
timber-2.3.0 spec/timber/events/error_spec.rb
timber-2.2.3 spec/timber/events/error_spec.rb
timber-2.2.2 spec/timber/events/error_spec.rb
timber-2.2.1 spec/timber/events/error_spec.rb
timber-2.2.0 spec/timber/events/error_spec.rb
timber-2.1.10 spec/timber/events/error_spec.rb
timber-2.1.9 spec/timber/events/error_spec.rb
timber-2.1.8 spec/timber/events/error_spec.rb
timber-2.1.7 spec/timber/events/error_spec.rb
timber-2.1.6 spec/timber/events/error_spec.rb
timber-2.1.5 spec/timber/events/error_spec.rb
timber-2.1.4 spec/timber/events/error_spec.rb
timber-2.1.3 spec/timber/events/error_spec.rb