bugsnag 6.13.1 → 6.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,7 @@ end
10
10
 
11
11
  require 'bugsnag'
12
12
 
13
+ require 'tmpdir'
13
14
  require 'webmock/rspec'
14
15
  require 'rspec/expectations'
15
16
  require 'rspec/mocks'
@@ -43,12 +44,16 @@ end
43
44
 
44
45
  RSpec.configure do |config|
45
46
  config.order = "random"
47
+ config.example_status_persistence_file_path = "#{Dir.tmpdir}/rspec_status"
46
48
 
47
49
  config.before(:each) do
48
50
  WebMock.stub_request(:post, "https://notify.bugsnag.com/")
49
51
  WebMock.stub_request(:post, "https://sessions.bugsnag.com/")
50
52
 
51
53
  Bugsnag.instance_variable_set(:@configuration, Bugsnag::Configuration.new)
54
+ Bugsnag.instance_variable_set(:@session_tracker, Bugsnag::SessionTracker.new)
55
+ Bugsnag.instance_variable_set(:@cleaner, Bugsnag::Cleaner.new(Bugsnag.configuration))
56
+
52
57
  Bugsnag.configure do |bugsnag|
53
58
  bugsnag.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
54
59
  bugsnag.release_stage = "production"
@@ -83,4 +88,4 @@ def have_sent_notification(&matcher)
83
88
  raise "no matcher provided to have_sent_notification (did you use { })"
84
89
  end
85
90
  end
86
- end
91
+ end
@@ -1,91 +1,159 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bugsnag::Stacktrace do
4
- it "includes code in the stack trace" do
5
- begin
6
- _a = 1
7
- _b = 2
8
- _c = 3
9
- "Test".prepnd "T"
10
- _d = 4
11
- _e = 5
12
- _f = 6
13
- rescue Exception => e
14
- Bugsnag.notify(e)
4
+ context "sending code" do
5
+ it "includes code in the stack trace" do
6
+ begin
7
+ _a = 1
8
+ _b = 2
9
+ _c = 3
10
+ "Test".prepnd "T"
11
+ _d = 4
12
+ _e = 5
13
+ _f = 6
14
+ rescue Exception => e
15
+ Bugsnag.notify(e)
16
+ end
17
+
18
+ expect(Bugsnag).to have_sent_notification{ |payload, headers|
19
+ exception = get_exception_from_payload(payload)
20
+ starting_line = __LINE__ - 13
21
+ expect(exception["stacktrace"][0]["code"]).to eq({
22
+ (starting_line + 0).to_s => ' _a = 1',
23
+ (starting_line + 1).to_s => ' _b = 2',
24
+ (starting_line + 2).to_s => ' _c = 3',
25
+ (starting_line + 3).to_s => ' "Test".prepnd "T"',
26
+ (starting_line + 4).to_s => ' _d = 4',
27
+ (starting_line + 5).to_s => ' _e = 5',
28
+ (starting_line + 6).to_s => ' _f = 6'
29
+ })
30
+ }
15
31
  end
16
32
 
17
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
18
- exception = get_exception_from_payload(payload)
19
- starting_line = __LINE__ - 13
20
- expect(exception["stacktrace"][0]["code"]).to eq({
21
- (starting_line + 0).to_s => ' _a = 1',
22
- (starting_line + 1).to_s => ' _b = 2',
23
- (starting_line + 2).to_s => ' _c = 3',
24
- (starting_line + 3).to_s => ' "Test".prepnd "T"',
25
- (starting_line + 4).to_s => ' _d = 4',
26
- (starting_line + 5).to_s => ' _e = 5',
27
- (starting_line + 6).to_s => ' _f = 6'
33
+ it "allows you to disable sending code" do
34
+ Bugsnag.configuration.send_code = false
35
+
36
+ notify_test_exception
37
+
38
+ expect(Bugsnag).to have_sent_notification{ |payload, headers|
39
+ exception = get_exception_from_payload(payload)
40
+ expect(exception["stacktrace"][1]["code"]).to eq(nil)
41
+ }
42
+ end
43
+
44
+ it 'should send the first 7 lines of the file for exceptions near the top' do
45
+ load 'spec/fixtures/crashes/start_of_file.rb' rescue Bugsnag.notify $!
46
+
47
+ expect(Bugsnag).to have_sent_notification{ |payload, headers|
48
+ exception = get_exception_from_payload(payload)
49
+
50
+ expect(exception["stacktrace"][0]["code"]).to eq({
51
+ "1" => "#",
52
+ "2" => "raise 'hell'",
53
+ "3" => "#",
54
+ "4" => "#",
55
+ "5" => "#",
56
+ "6" => "#",
57
+ "7" => "#"
28
58
  })
29
- }
30
- end
59
+ }
60
+ end
31
61
 
32
- it "allows you to disable sending code" do
33
- Bugsnag.configuration.send_code = false
62
+ it 'should send the last 7 lines of the file for exceptions near the bottom' do
63
+ load 'spec/fixtures/crashes/end_of_file.rb' rescue Bugsnag.notify $!
34
64
 
35
- notify_test_exception
65
+ expect(Bugsnag).to have_sent_notification{ |payload, headers|
66
+ exception = get_exception_from_payload(payload)
36
67
 
37
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
38
- exception = get_exception_from_payload(payload)
39
- expect(exception["stacktrace"][1]["code"]).to eq(nil)
40
- }
41
- end
68
+ expect(exception["stacktrace"][0]["code"]).to eq({
69
+ "3" => "#",
70
+ "4" => "#",
71
+ "5" => "#",
72
+ "6" => "#",
73
+ "7" => "#",
74
+ "8" => "raise 'hell'",
75
+ "9" => "#"
76
+ })
77
+ }
78
+ end
42
79
 
43
- it 'should send the first 7 lines of the file for exceptions near the top' do
44
- load 'spec/fixtures/crashes/start_of_file.rb' rescue Bugsnag.notify $!
45
-
46
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
47
- exception = get_exception_from_payload(payload)
48
-
49
- expect(exception["stacktrace"][0]["code"]).to eq({
50
- "1" => "#",
51
- "2" => "raise 'hell'",
52
- "3" => "#",
53
- "4" => "#",
54
- "5" => "#",
55
- "6" => "#",
56
- "7" => "#"
57
- })
58
- }
59
- end
80
+ it 'should send the last 7 lines of the file for exceptions near the bottom' do
81
+ load 'spec/fixtures/crashes/short_file.rb' rescue Bugsnag.notify $!
82
+
83
+ expect(Bugsnag).to have_sent_notification{ |payload, headers|
84
+ exception = get_exception_from_payload(payload)
60
85
 
61
- it 'should send the last 7 lines of the file for exceptions near the bottom' do
62
- load 'spec/fixtures/crashes/end_of_file.rb' rescue Bugsnag.notify $!
63
-
64
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
65
- exception = get_exception_from_payload(payload)
66
-
67
- expect(exception["stacktrace"][0]["code"]).to eq({
68
- "3" => "#",
69
- "4" => "#",
70
- "5" => "#",
71
- "6" => "#",
72
- "7" => "#",
73
- "8" => "raise 'hell'",
74
- "9" => "#"
75
- })
76
- }
86
+ expect(exception["stacktrace"][0]["code"]).to eq({
87
+ "1" => "raise 'hell'"
88
+ })
89
+ }
90
+ end
77
91
  end
78
92
 
79
- it 'should send the last 7 lines of the file for exceptions near the bottom' do
80
- load 'spec/fixtures/crashes/short_file.rb' rescue Bugsnag.notify $!
93
+ context "file paths" do
94
+ it "leaves absolute paths alone" do
95
+ configuration = Bugsnag::Configuration.new
96
+ configuration.send_code = false
97
+
98
+ backtrace = [
99
+ "/foo/bar/app/models/user.rb:1:in `something'",
100
+ "/foo/bar/other_vendor/lib/dont.rb:2:in `to_s'",
101
+ "/foo/bar/vendor/lib/ignore_me.rb:3:in `to_s'",
102
+ "/foo/bar/.bundle/lib/ignore_me.rb:4:in `to_s'",
103
+ ]
104
+
105
+ stacktrace = Bugsnag::Stacktrace.new(backtrace, configuration).to_a
106
+
107
+ expect(stacktrace).to eq([
108
+ { file: "/foo/bar/app/models/user.rb", lineNumber: 1, method: "something" },
109
+ { file: "/foo/bar/other_vendor/lib/dont.rb", lineNumber: 2, method: "to_s" },
110
+ { file: "/foo/bar/vendor/lib/ignore_me.rb", lineNumber: 3, method: "to_s" },
111
+ { file: "/foo/bar/.bundle/lib/ignore_me.rb", lineNumber: 4, method: "to_s" },
112
+ ])
113
+ end
114
+
115
+ it "does not modify relative paths if they can't be resolved" do
116
+ configuration = Bugsnag::Configuration.new
117
+
118
+ backtrace = [
119
+ "./foo/bar/baz.rb:1:in `something'",
120
+ "../foo.rb:1:in `to_s'",
121
+ "../xyz.rb:1:in `to_s'",
122
+ "abc.rb:1:in `defg'",
123
+ ]
81
124
 
82
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
83
- exception = get_exception_from_payload(payload)
125
+ stacktrace = Bugsnag::Stacktrace.new(backtrace, configuration).to_a
84
126
 
85
- expect(exception["stacktrace"][0]["code"]).to eq({
86
- "1" => "raise 'hell'"
87
- })
88
- }
127
+ expect(stacktrace).to eq([
128
+ { code: nil, file: "./foo/bar/baz.rb", lineNumber: 1, method: "something" },
129
+ { code: nil, file: "../foo.rb", lineNumber: 1, method: "to_s" },
130
+ { code: nil, file: "../xyz.rb", lineNumber: 1, method: "to_s" },
131
+ { code: nil, file: "abc.rb", lineNumber: 1, method: "defg" },
132
+ ])
133
+ end
134
+
135
+ it "resolves relative paths when the files exist" do
136
+ configuration = Bugsnag::Configuration.new
137
+ configuration.send_code = false
138
+
139
+ dir = File.dirname(__FILE__)
140
+
141
+ backtrace = [
142
+ "./spec/spec_helper.rb:1:in `something'",
143
+ "./lib/bugsnag/breadcrumbs/../configuration.rb:100:in `to_s'",
144
+ "lib/bugsnag.rb:20:in `notify'",
145
+ "#{dir}/../spec/stacktrace_spec.rb:5:in `something_else'",
146
+ ]
147
+
148
+ stacktrace = Bugsnag::Stacktrace.new(backtrace, configuration).to_a
149
+
150
+ expect(stacktrace).to eq([
151
+ { file: "#{dir}/spec_helper.rb", lineNumber: 1, method: "something" },
152
+ { file: "#{File.dirname(dir)}/lib/bugsnag/configuration.rb", lineNumber: 100, method: "to_s" },
153
+ { file: "#{File.dirname(dir)}/lib/bugsnag.rb", lineNumber: 20, method: "notify" },
154
+ { file: "#{dir}/stacktrace_spec.rb", lineNumber: 5, method: "something_else" },
155
+ ])
156
+ end
89
157
  end
90
158
 
91
159
  context "with configurable vendor_path" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.13.1
4
+ version: 6.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -639,6 +639,7 @@ files:
639
639
  - lib/bugsnag/middleware/classify_error.rb
640
640
  - lib/bugsnag/middleware/clearance_user.rb
641
641
  - lib/bugsnag/middleware/delayed_job.rb
642
+ - lib/bugsnag/middleware/discard_error_class.rb
642
643
  - lib/bugsnag/middleware/exception_meta_data.rb
643
644
  - lib/bugsnag/middleware/ignore_error_class.rb
644
645
  - lib/bugsnag/middleware/mailman.rb