airbrake-ruby 2.5.0.rc.3 → 2.5.0.rc.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 313672bde1f31342c0fce790b1f6285c9b125b4e
4
- data.tar.gz: 505361aa89c2f456b91ae53c76a73b61cb180838
3
+ metadata.gz: 723a69b477b7427cce788252556a5787cdfb0e3f
4
+ data.tar.gz: ebcde2029d361259bc27fdbd1573b5617f550352
5
5
  SHA512:
6
- metadata.gz: 65b85420d818a1ab8a4149ca642710c316626d7b283a24a2bb78712f8aa731dfd5946f88da6ab674d69037c50390b726fcc183007156189b3d9bb26c3143b2fb
7
- data.tar.gz: 8fcbf41b9f55a93ec262525d39d282f08a8dd2b73a4d96f87e084b440d349b8cf4347e3a48181419906af93ee2bda6b3ff34997af5aa62f8065aed4e90777da9
6
+ metadata.gz: c81879d7a36df9412c75292314117f0ae46b555a6fe995e52a0d4d661b4ab8d812d38a5e8f658fe512b07762171a8e64c3019b1838e9b1a19e6696e56c4d9700
7
+ data.tar.gz: 81e6a8137d913c6f68007647b22178f3f1001eaffb325004ac8b1eefbb8b1e1fca47d3326c8a1498805fa9a212a0d4086f32389de9eaa8c177283743dad3e56b
@@ -182,6 +182,7 @@ module Airbrake
182
182
 
183
183
  def parse_backtrace(config, exception)
184
184
  regexp = best_regexp_for(exception)
185
+ root_directory = config.root_directory.to_s
185
186
 
186
187
  exception.backtrace.map.with_index do |stackframe, i|
187
188
  unless (match = match_frame(regexp, stackframe))
@@ -195,8 +196,8 @@ module Airbrake
195
196
  frame = stack_frame(match)
196
197
  next(frame) unless config.code_hunks
197
198
 
198
- if config.root_directory
199
- if frame[:file].start_with?(config.root_directory)
199
+ if !root_directory.empty?
200
+ if frame[:file].start_with?(root_directory)
200
201
  populate_code(config, frame)
201
202
  end
202
203
  elsif i < CODE_FRAME_LIMIT
@@ -4,5 +4,5 @@
4
4
  module Airbrake
5
5
  ##
6
6
  # @return [String] the library version
7
- AIRBRAKE_RUBY_VERSION = '2.5.0.rc.3'.freeze
7
+ AIRBRAKE_RUBY_VERSION = '2.5.0.rc.4'.freeze
8
8
  end
@@ -335,6 +335,35 @@ RSpec.describe Airbrake::Backtrace do
335
335
  end
336
336
  end
337
337
 
338
+ context "and when root_directory is a Pathname" do
339
+ before { config.root_directory = Pathname.new(project_root_path('')) }
340
+
341
+ let(:parsed_backtrace) do
342
+ [
343
+ {
344
+ file: project_root_path('code.rb'),
345
+ line: 94,
346
+ function: 'to_json',
347
+ code: {
348
+ 92 => ' loop do',
349
+ 93 => ' begin',
350
+ 94 => ' json = @payload.to_json',
351
+ 95 => ' rescue *JSON_EXCEPTIONS => ex',
352
+ # rubocop:disable Metrics/LineLength,Lint/InterpolationCheck
353
+ 96 => ' @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
354
+ # rubocop:enable Metrics/LineLength,Lint/InterpolationCheck
355
+ }
356
+ }
357
+ ]
358
+ end
359
+
360
+ it "attaches code to those frames files of which match root_directory" do
361
+ ex = RuntimeError.new
362
+ ex.set_backtrace([project_root_path('code.rb') + ":94:in `to_json'"])
363
+ expect(described_class.parse(config, ex)).to eq(parsed_backtrace)
364
+ end
365
+ end
366
+
338
367
  context "and when root_directory isn't configured" do
339
368
  before do
340
369
  config.root_directory = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0.rc.3
4
+ version: 2.5.0.rc.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.