honeybadger 1.8.1 → 1.9.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +61 -19
- data/Guardfile +4 -4
- data/MIT-LICENSE +1 -0
- data/README.md +2 -2
- data/Rakefile +4 -14
- data/features/rails.feature +1 -1
- data/gemfiles/rack.gemfile.lock +62 -27
- data/gemfiles/rails2.3.gemfile.lock +73 -36
- data/gemfiles/rails3.0.gemfile.lock +59 -26
- data/gemfiles/rails3.1.gemfile.lock +59 -26
- data/gemfiles/rails3.2.gemfile.lock +63 -30
- data/gemfiles/rails4.gemfile.lock +69 -36
- data/gemfiles/rake.gemfile.lock +62 -27
- data/gemfiles/sinatra.gemfile.lock +62 -27
- data/honeybadger.gemspec +31 -17
- data/lib/honeybadger.rb +2 -3
- data/lib/honeybadger/array.rb +53 -0
- data/lib/honeybadger/configuration.rb +19 -2
- data/lib/honeybadger/monitor.rb +16 -0
- data/lib/honeybadger/monitor/railtie.rb +52 -0
- data/lib/honeybadger/monitor/sender.rb +33 -0
- data/lib/honeybadger/monitor/worker.rb +71 -0
- data/lib/honeybadger/railtie.rb +10 -0
- data/lib/honeybadger/sender.rb +60 -41
- data/{test/unit/backtrace_test.rb → spec/honeybadger/backtrace_spec.rb} +69 -71
- data/{test/unit/capistrano_test.rb → spec/honeybadger/capistrano_spec.rb} +8 -9
- data/{test/unit/configuration_test.rb → spec/honeybadger/configuration_spec.rb} +85 -59
- data/spec/honeybadger/logger_spec.rb +65 -0
- data/spec/honeybadger/monitor/worker_spec.rb +189 -0
- data/{test/unit/notice_test.rb → spec/honeybadger/notice_spec.rb} +169 -185
- data/spec/honeybadger/notifier_spec.rb +252 -0
- data/spec/honeybadger/rack_spec.rb +84 -0
- data/{test/unit/rails/action_controller_catcher_test.rb → spec/honeybadger/rails/action_controller_spec.rb} +65 -57
- data/{test/unit/rails_test.rb → spec/honeybadger/rails_spec.rb} +8 -8
- data/spec/honeybadger/sender_spec.rb +249 -0
- data/spec/honeybadger_tasks_spec.rb +165 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/array_including.rb +31 -0
- data/spec/support/backtraced_exception.rb +9 -0
- data/spec/support/collected_sender.rb +12 -0
- data/spec/support/defines_constants.rb +18 -0
- data/{test/test_helper.rb → spec/support/helpers.rb} +8 -61
- metadata +93 -45
- data/test/unit/honeybadger_tasks_test.rb +0 -167
- data/test/unit/logger_test.rb +0 -74
- data/test/unit/notifier_test.rb +0 -265
- data/test/unit/rack_test.rb +0 -88
- data/test/unit/sender_test.rb +0 -290
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'stringio'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
describe Honeybadger::Backtrace do
|
5
|
+
it "parses a backtrace into lines" do
|
6
6
|
array = [
|
7
7
|
"app/models/user.rb:13:in `magic'",
|
8
8
|
"app/controllers/users_controller.rb:8:in `index'"
|
@@ -11,17 +11,17 @@ class BacktraceTest < Test::Unit::TestCase
|
|
11
11
|
backtrace = Honeybadger::Backtrace.parse(array)
|
12
12
|
|
13
13
|
line = backtrace.lines.first
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
expect(line.number).to eq '13'
|
15
|
+
expect(line.file).to eq 'app/models/user.rb'
|
16
|
+
expect(line.method).to eq 'magic'
|
17
17
|
|
18
18
|
line = backtrace.lines.last
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
expect(line.number).to eq '8'
|
20
|
+
expect(line.file).to eq 'app/controllers/users_controller.rb'
|
21
|
+
expect(line.method).to eq 'index'
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
it "parses a windows backtrace into lines" do
|
25
25
|
array = [
|
26
26
|
"C:/Program Files/Server/app/models/user.rb:13:in `magic'",
|
27
27
|
"C:/Program Files/Server/app/controllers/users_controller.rb:8:in `index'"
|
@@ -30,34 +30,34 @@ class BacktraceTest < Test::Unit::TestCase
|
|
30
30
|
backtrace = Honeybadger::Backtrace.parse(array)
|
31
31
|
|
32
32
|
line = backtrace.lines.first
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
expect(line.number).to eq '13'
|
34
|
+
expect(line.file).to eq 'C:/Program Files/Server/app/models/user.rb'
|
35
|
+
expect(line.method).to eq 'magic'
|
36
36
|
|
37
37
|
line = backtrace.lines.last
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
expect(line.number).to eq '8'
|
39
|
+
expect(line.file).to eq 'C:/Program Files/Server/app/controllers/users_controller.rb'
|
40
|
+
expect(line.method).to eq 'index'
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
it "is equal with equal lines" do
|
44
44
|
one = build_backtrace_array
|
45
45
|
two = one.dup
|
46
46
|
|
47
|
-
|
47
|
+
expect(Honeybadger::Backtrace.parse(one)).to eq Honeybadger::Backtrace.parse(two)
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
it "parses massive one-line exceptions into multiple lines" do
|
51
51
|
original_backtrace = Honeybadger::Backtrace.
|
52
52
|
parse(["one:1:in `one'\n two:2:in `two'\n three:3:in `three`"])
|
53
53
|
expected_backtrace = Honeybadger::Backtrace.
|
54
54
|
parse(["one:1:in `one'", "two:2:in `two'", "three:3:in `three`"])
|
55
55
|
|
56
|
-
|
56
|
+
expect(expected_backtrace).to eq original_backtrace
|
57
57
|
end
|
58
58
|
|
59
59
|
context "when source file exists" do
|
60
|
-
|
60
|
+
before(:each) do
|
61
61
|
source = <<-RUBY
|
62
62
|
$:<<'lib'
|
63
63
|
require 'honeybadger'
|
@@ -76,35 +76,35 @@ class BacktraceTest < Test::Unit::TestCase
|
|
76
76
|
]
|
77
77
|
|
78
78
|
['app/models/user.rb', 'app/concerns/authenticated_controller.rb', 'app/controllers/users_controller.rb'].each do |file|
|
79
|
-
File.
|
80
|
-
File.
|
79
|
+
File.should_receive(:exists?).with(file).and_return true
|
80
|
+
File.should_receive(:open).with(file).and_yield StringIO.new(source)
|
81
81
|
end
|
82
82
|
|
83
83
|
@backtrace = Honeybadger::Backtrace.parse(array)
|
84
84
|
end
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
86
|
+
it "includes a snippet from the source file for each line of the backtrace" do
|
87
|
+
expect(@backtrace.lines[0].source.keys.size).to eq(4)
|
88
|
+
expect(@backtrace.lines[0].source[1]).to match(/\$:<</)
|
89
|
+
expect(@backtrace.lines[0].source[2]).to match(/require/)
|
90
|
+
expect(@backtrace.lines[0].source[3]).to match(/\n/)
|
91
|
+
expect(@backtrace.lines[0].source[4]).to match(/begin/)
|
92
|
+
|
93
|
+
expect(@backtrace.lines[1].source.keys.size).to eq(5)
|
94
|
+
expect(@backtrace.lines[1].source[2]).to match(/require/)
|
95
|
+
expect(@backtrace.lines[1].source[3]).to match(/\n/)
|
96
|
+
expect(@backtrace.lines[1].source[4]).to match(/begin/)
|
97
|
+
expect(@backtrace.lines[1].source[5]).to match(/StandardError/)
|
98
|
+
expect(@backtrace.lines[1].source[6]).to match(/rescue/)
|
99
|
+
|
100
|
+
expect(@backtrace.lines[2].source.keys.size).to eq(3)
|
101
|
+
expect(@backtrace.lines[2].source[6]).to match(/rescue/)
|
102
|
+
expect(@backtrace.lines[2].source[7]).to match(/Honeybadger/)
|
103
|
+
expect(@backtrace.lines[2].source[8]).to match(/end/)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
|
107
|
+
it "fails gracefully when looking up snippet and file doesn't exist" do
|
108
108
|
array = [
|
109
109
|
"app/models/user.rb:13:in `magic'",
|
110
110
|
"app/controllers/users_controller.rb:8:in `index'"
|
@@ -112,17 +112,17 @@ class BacktraceTest < Test::Unit::TestCase
|
|
112
112
|
|
113
113
|
backtrace = Honeybadger::Backtrace.parse(array)
|
114
114
|
|
115
|
-
|
116
|
-
|
115
|
+
expect(backtrace.lines[0].source).to be_empty
|
116
|
+
expect(backtrace.lines[1].source).to be_empty
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
it "has an empty application trace by default" do
|
120
120
|
backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
|
121
|
-
|
121
|
+
expect(backtrace.application_lines).to be_empty
|
122
122
|
end
|
123
123
|
|
124
124
|
context "with a project root" do
|
125
|
-
|
125
|
+
before(:each) do
|
126
126
|
@project_root = '/some/path'
|
127
127
|
Honeybadger.configure {|config| config.project_root = @project_root }
|
128
128
|
|
@@ -139,27 +139,27 @@ class BacktraceTest < Test::Unit::TestCase
|
|
139
139
|
"/lib/something.rb:41:in `open'"])
|
140
140
|
end
|
141
141
|
|
142
|
-
|
143
|
-
|
142
|
+
it "filters out the project root" do
|
143
|
+
expect(@backtrace_without_root).to eq @backtrace_with_root
|
144
144
|
end
|
145
145
|
|
146
|
-
|
147
|
-
|
146
|
+
it "has an application trace" do
|
147
|
+
expect(@backtrace_without_root.application_lines).to eq @backtrace_without_root.lines[0..1]
|
148
148
|
end
|
149
149
|
|
150
|
-
|
151
|
-
|
150
|
+
it "filters ./vendor from application trace" do
|
151
|
+
expect(@backtrace_without_root.application_lines).not_to include(@backtrace_without_root.lines[2])
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
context "with a project root equals to a part of file name" do
|
156
|
-
|
156
|
+
before(:each) do
|
157
157
|
# Heroku-like
|
158
158
|
@project_root = '/app'
|
159
159
|
Honeybadger.configure {|config| config.project_root = @project_root }
|
160
160
|
end
|
161
161
|
|
162
|
-
|
162
|
+
it "filters out the project root" do
|
163
163
|
backtrace_with_root = Honeybadger::Backtrace.parse(
|
164
164
|
["#{@project_root}/app/models/user.rb:7:in `latest'",
|
165
165
|
"#{@project_root}/app/controllers/users_controller.rb:13:in `index'",
|
@@ -170,16 +170,16 @@ class BacktraceTest < Test::Unit::TestCase
|
|
170
170
|
"[PROJECT_ROOT]/app/controllers/users_controller.rb:13:in `index'",
|
171
171
|
"/lib/something.rb:41:in `open'"])
|
172
172
|
|
173
|
-
|
173
|
+
expect(backtrace_without_root).to eq backtrace_with_root
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
177
|
context "with a blank project root" do
|
178
|
-
|
178
|
+
before(:each) do
|
179
179
|
Honeybadger.configure {|config| config.project_root = '' }
|
180
180
|
end
|
181
181
|
|
182
|
-
|
182
|
+
it "does not filter line numbers with respect to any project root" do
|
183
183
|
backtrace = ["/app/models/user.rb:7:in `latest'",
|
184
184
|
"/app/controllers/users_controller.rb:13:in `index'",
|
185
185
|
"/lib/something.rb:41:in `open'"]
|
@@ -190,11 +190,11 @@ class BacktraceTest < Test::Unit::TestCase
|
|
190
190
|
backtrace_without_root =
|
191
191
|
Honeybadger::Backtrace.parse(backtrace)
|
192
192
|
|
193
|
-
|
193
|
+
expect(backtrace_without_root).to eq backtrace_with_root
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
|
197
|
+
it "removes notifier trace" do
|
198
198
|
inside_notifier = ['lib/honeybadger.rb:13:in `voodoo`']
|
199
199
|
outside_notifier = ['users_controller:8:in `index`']
|
200
200
|
|
@@ -202,35 +202,33 @@ class BacktraceTest < Test::Unit::TestCase
|
|
202
202
|
with_inside = Honeybadger::Backtrace.parse(inside_notifier + outside_notifier,
|
203
203
|
:filters => default_filters)
|
204
204
|
|
205
|
-
|
205
|
+
expect(without_inside).to eq with_inside
|
206
206
|
end
|
207
207
|
|
208
|
-
|
208
|
+
it "runs filters on the backtrace" do
|
209
209
|
filters = [lambda { |line| line.sub('foo', 'bar') }]
|
210
210
|
input = Honeybadger::Backtrace.parse(["foo:13:in `one'", "baz:14:in `two'"],
|
211
211
|
:filters => filters)
|
212
212
|
expected = Honeybadger::Backtrace.parse(["bar:13:in `one'", "baz:14:in `two'"])
|
213
|
-
|
213
|
+
expect(expected).to eq input
|
214
214
|
end
|
215
215
|
|
216
|
-
|
216
|
+
it "aliases #to_ary as #to_a" do
|
217
217
|
backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
|
218
218
|
|
219
|
-
|
219
|
+
expect(backtrace.to_a).to eq backtrace.to_ary
|
220
220
|
end
|
221
221
|
|
222
|
-
|
222
|
+
it "generates json from to_array template" do
|
223
223
|
backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
|
224
224
|
array = [{'foo' => 'bar'}]
|
225
|
-
backtrace.
|
225
|
+
backtrace.should_receive(:to_ary).once.and_return(array)
|
226
226
|
json = backtrace.to_json
|
227
227
|
|
228
228
|
payload = nil
|
229
|
-
|
230
|
-
payload = JSON.parse(json)
|
231
|
-
end
|
229
|
+
expect { payload = JSON.parse(json) }.not_to raise_error
|
232
230
|
|
233
|
-
|
231
|
+
expect(payload).to eq array
|
234
232
|
end
|
235
233
|
|
236
234
|
def build_backtrace_array
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'capistrano/configuration'
|
4
4
|
require 'honeybadger/capistrano'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
super
|
6
|
+
describe Honeybadger::Capistrano do
|
7
|
+
before(:each) do
|
9
8
|
reset_config
|
10
9
|
|
11
10
|
@configuration = Capistrano::Configuration.new
|
@@ -13,11 +12,11 @@ class CapistranoTest < Test::Unit::TestCase
|
|
13
12
|
@configuration.dry_run = true
|
14
13
|
end
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
it "defines honeybadger:deploy task" do
|
16
|
+
expect(@configuration.find_task('honeybadger:deploy')).not_to be_nil
|
18
17
|
end
|
19
18
|
|
20
|
-
|
19
|
+
it "logs when calling honeybadger:deploy task" do
|
21
20
|
@configuration.set(:current_revision, '084505b1c0e0bcf1526e673bb6ac99fbcb18aecc')
|
22
21
|
@configuration.set(:repository, 'repository')
|
23
22
|
@configuration.set(:current_release, '/home/deploy/rails_app/honeybadger')
|
@@ -28,7 +27,7 @@ class CapistranoTest < Test::Unit::TestCase
|
|
28
27
|
@configuration.logger = logger
|
29
28
|
@configuration.find_and_execute_task('honeybadger:deploy')
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
expect(io.string).to include '** Notifying Honeybadger of Deploy'
|
31
|
+
expect(io.string).to include '** Honeybadger Notification Complete'
|
33
32
|
end
|
34
33
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'socket'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
describe Honeybadger::Configuration do
|
5
|
+
it "provides default values" do
|
5
6
|
assert_config_default :proxy_host, nil
|
6
7
|
assert_config_default :proxy_port, nil
|
7
8
|
assert_config_default :proxy_user, nil
|
@@ -30,67 +31,67 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
30
31
|
assert_config_default :send_request_session, true
|
31
32
|
assert_config_default :debug, false
|
32
33
|
assert_config_default :fingerprint, nil
|
33
|
-
assert_config_default :hostname,
|
34
|
+
assert_config_default :hostname, Socket.gethostname
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
+
it "configures async as Proc" do
|
37
38
|
config = Honeybadger::Configuration.new
|
38
39
|
async_handler = Proc.new { |n| n.deliver }
|
39
|
-
|
40
|
+
expect(config.async?).to be_false
|
40
41
|
config.async = async_handler
|
41
|
-
|
42
|
-
|
42
|
+
expect(config.async?).to be_true
|
43
|
+
expect(config.async).to be async_handler
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
+
it "configures async with block" do
|
46
47
|
config = Honeybadger::Configuration.new
|
47
|
-
|
48
|
+
expect(config.async?).to be_false
|
48
49
|
config.async { |n| n }
|
49
|
-
|
50
|
-
|
50
|
+
expect(config.async?).to be_true
|
51
|
+
expect(config.async.call('foo')).to eq 'foo'
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
+
it "configures fingerprint as Proc" do
|
54
55
|
config = Honeybadger::Configuration.new
|
55
56
|
fingerprint_generator = Proc.new { |n| n[:error_class] }
|
56
57
|
config.fingerprint = fingerprint_generator
|
57
|
-
|
58
|
+
expect(config.fingerprint.call({ :error_class => 'foo' })).to eq 'foo'
|
58
59
|
end
|
59
60
|
|
60
|
-
|
61
|
+
it "configures fingerprint with block" do
|
61
62
|
config = Honeybadger::Configuration.new
|
62
63
|
config.fingerprint { |n| n[:error_class] }
|
63
|
-
|
64
|
+
expect(config.fingerprint.call({ :error_class => 'foo' })).to eq 'foo'
|
64
65
|
end
|
65
66
|
|
66
|
-
|
67
|
+
it "stubs current_user_method" do
|
67
68
|
config = Honeybadger::Configuration.new
|
68
|
-
|
69
|
+
expect { config.current_user_method = :foo }.not_to raise_error
|
69
70
|
end
|
70
71
|
|
71
|
-
|
72
|
+
it "provides default values for secure connections" do
|
72
73
|
config = Honeybadger::Configuration.new
|
73
74
|
config.secure = true
|
74
|
-
|
75
|
-
|
75
|
+
expect(config.port).to eq 443
|
76
|
+
expect(config.protocol).to eq 'https'
|
76
77
|
end
|
77
78
|
|
78
|
-
|
79
|
+
it "provides default values for insecure connections" do
|
79
80
|
config = Honeybadger::Configuration.new
|
80
81
|
config.secure = false
|
81
|
-
|
82
|
-
|
82
|
+
expect(config.port).to eq 80
|
83
|
+
expect(config.protocol).to eq 'http'
|
83
84
|
end
|
84
85
|
|
85
|
-
|
86
|
+
it "does not cache inferred ports" do
|
86
87
|
config = Honeybadger::Configuration.new
|
87
88
|
config.secure = false
|
88
89
|
config.port
|
89
90
|
config.secure = true
|
90
|
-
|
91
|
+
expect(config.port).to eq 443
|
91
92
|
end
|
92
93
|
|
93
|
-
|
94
|
+
it "allows values to be overwritten" do
|
94
95
|
assert_config_overridable :proxy_host
|
95
96
|
assert_config_overridable :proxy_port
|
96
97
|
assert_config_overridable :proxy_user
|
@@ -114,11 +115,11 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
114
115
|
assert_config_overridable :hostname
|
115
116
|
end
|
116
117
|
|
117
|
-
|
118
|
+
it "has an api key" do
|
118
119
|
assert_config_overridable :api_key
|
119
120
|
end
|
120
121
|
|
121
|
-
|
122
|
+
it "acts like a hash" do
|
122
123
|
config = Honeybadger::Configuration.new
|
123
124
|
hash = config.to_hash
|
124
125
|
[:api_key, :backtrace_filters, :development_environments,
|
@@ -128,25 +129,25 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
128
129
|
:proxy_host, :proxy_pass, :proxy_port, :proxy_user, :secure,
|
129
130
|
:source_extract_radius, :async, :send_request_session, :debug,
|
130
131
|
:fingerprint, :hostname].each do |option|
|
131
|
-
|
132
|
+
expect(hash[option]).to eq config[option]
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
|
-
|
136
|
+
it "is mergable" do
|
136
137
|
config = Honeybadger::Configuration.new
|
137
138
|
hash = config.to_hash
|
138
|
-
|
139
|
+
expect(hash.merge(:key => 'value')).to eq config.merge(:key => 'value')
|
139
140
|
end
|
140
141
|
|
141
|
-
|
142
|
+
it "allows param filters to be appended" do
|
142
143
|
assert_appends_value :params_filters
|
143
144
|
end
|
144
145
|
|
145
|
-
|
146
|
+
it "allows ignored user agents to be appended" do
|
146
147
|
assert_appends_value :ignore_user_agent
|
147
148
|
end
|
148
149
|
|
149
|
-
|
150
|
+
it "allows backtrace filters to be appended" do
|
150
151
|
assert_appends_value(:backtrace_filters) do |config|
|
151
152
|
new_filter = lambda {}
|
152
153
|
config.filter_backtrace(&new_filter)
|
@@ -154,7 +155,7 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
154
155
|
end
|
155
156
|
end
|
156
157
|
|
157
|
-
|
158
|
+
it "allows ignore by filters to be appended" do
|
158
159
|
assert_appends_value(:ignore_by_filters) do |config|
|
159
160
|
new_filter = lambda {}
|
160
161
|
config.ignore_by_filter(&new_filter)
|
@@ -162,86 +163,111 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
162
163
|
end
|
163
164
|
end
|
164
165
|
|
165
|
-
|
166
|
+
it "allows ignored exceptions to be appended" do
|
166
167
|
config = Honeybadger::Configuration.new
|
167
168
|
original_filters = config.ignore.dup
|
168
169
|
new_filter = 'hello'
|
169
170
|
config.ignore << new_filter
|
170
|
-
|
171
|
+
expect(original_filters + [new_filter]).to eq config.ignore
|
171
172
|
end
|
172
173
|
|
173
|
-
|
174
|
+
it "allows ignored exceptions to be replaced" do
|
174
175
|
assert_replaces(:ignore, :ignore_only=)
|
175
176
|
end
|
176
177
|
|
177
|
-
|
178
|
+
it "allows ignored user agents to be replaced" do
|
178
179
|
assert_replaces(:ignore_user_agent, :ignore_user_agent_only=)
|
179
180
|
end
|
180
181
|
|
181
|
-
|
182
|
+
it "uses development and test as development environments by default" do
|
182
183
|
config = Honeybadger::Configuration.new
|
183
|
-
|
184
|
+
expect(config.development_environments).to eq %w(development test cucumber)
|
184
185
|
end
|
185
186
|
|
186
|
-
|
187
|
+
it "is public in a public environment" do
|
187
188
|
config = Honeybadger::Configuration.new
|
188
189
|
config.development_environments = %w(development)
|
189
190
|
config.environment_name = 'production'
|
190
|
-
|
191
|
+
expect(config.public?).to be_true
|
191
192
|
end
|
192
193
|
|
193
|
-
|
194
|
+
it "is not public in a development environment" do
|
194
195
|
config = Honeybadger::Configuration.new
|
195
196
|
config.development_environments = %w(staging)
|
196
197
|
config.environment_name = 'staging'
|
197
|
-
|
198
|
+
expect(config.public?).to be_false
|
198
199
|
end
|
199
200
|
|
200
|
-
|
201
|
+
it "is public without an environment name" do
|
201
202
|
config = Honeybadger::Configuration.new
|
202
|
-
|
203
|
+
expect(config.public?).to be_true
|
203
204
|
end
|
204
205
|
|
205
|
-
|
206
|
+
it "is not be public if the notices feature is missing" do
|
207
|
+
config = Honeybadger::Configuration.new
|
208
|
+
config.features = {}
|
209
|
+
expect(config.public?).to be_false
|
210
|
+
end
|
211
|
+
|
212
|
+
it "sends metrics by default in a public environment" do
|
213
|
+
config = Honeybadger::Configuration.new
|
214
|
+
config.environment_name = 'production'
|
215
|
+
expect(config.metrics?).to be_true
|
216
|
+
end
|
217
|
+
|
218
|
+
it "sends not send metrics when disabled" do
|
219
|
+
config = Honeybadger::Configuration.new
|
220
|
+
config.environment_name = 'production'
|
221
|
+
config.metrics = false
|
222
|
+
expect(config.metrics?).to be_false
|
223
|
+
end
|
224
|
+
|
225
|
+
it "sends not send metrics in a development environment" do
|
226
|
+
config = Honeybadger::Configuration.new
|
227
|
+
config.environment_name = 'development'
|
228
|
+
expect(config.metrics?).to be_false
|
229
|
+
end
|
230
|
+
|
231
|
+
it "uses the assigned logger if set" do
|
206
232
|
config = Honeybadger::Configuration.new
|
207
233
|
config.logger = "CUSTOM LOGGER"
|
208
|
-
|
234
|
+
expect(config.logger).to eq "CUSTOM LOGGER"
|
209
235
|
end
|
210
236
|
|
211
|
-
|
237
|
+
it 'gives a new instance if non defined' do
|
212
238
|
Honeybadger.configuration = nil
|
213
|
-
|
239
|
+
expect(Honeybadger.configuration).to be_a Honeybadger::Configuration
|
214
240
|
end
|
215
241
|
|
216
242
|
def assert_config_default(option, default_value, config = nil)
|
217
243
|
config ||= Honeybadger::Configuration.new
|
218
|
-
|
244
|
+
expect(config.send(option)).to eq default_value
|
219
245
|
end
|
220
246
|
|
221
247
|
def assert_config_overridable(option, value = 'a value')
|
222
248
|
config = Honeybadger::Configuration.new
|
223
249
|
config.send(:"#{option}=", value)
|
224
|
-
|
250
|
+
expect(config.send(option)).to eq value
|
225
251
|
end
|
226
252
|
|
227
253
|
def assert_appends_value(option, &block)
|
228
254
|
config = Honeybadger::Configuration.new
|
229
255
|
original_values = config.send(option).dup
|
230
|
-
block ||= lambda do |
|
256
|
+
block ||= lambda do |c|
|
231
257
|
new_value = 'hello'
|
232
|
-
|
258
|
+
c.send(option) << new_value
|
233
259
|
new_value
|
234
260
|
end
|
235
261
|
new_value = block.call(config)
|
236
|
-
|
262
|
+
expect(original_values + [new_value]).to eq config.send(option)
|
237
263
|
end
|
238
264
|
|
239
265
|
def assert_replaces(option, setter)
|
240
266
|
config = Honeybadger::Configuration.new
|
241
267
|
new_value = 'hello'
|
242
268
|
config.send(setter, [new_value])
|
243
|
-
|
269
|
+
expect(config.send(option)).to eq [new_value]
|
244
270
|
config.send(setter, new_value)
|
245
|
-
|
271
|
+
expect(config.send(option)).to eq [new_value]
|
246
272
|
end
|
247
273
|
end
|