honeybadger 1.8.1 → 1.9.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/CHANGELOG.md +14 -0
  2. data/Gemfile.lock +61 -19
  3. data/Guardfile +4 -4
  4. data/MIT-LICENSE +1 -0
  5. data/README.md +2 -2
  6. data/Rakefile +4 -14
  7. data/features/rails.feature +1 -1
  8. data/gemfiles/rack.gemfile.lock +62 -27
  9. data/gemfiles/rails2.3.gemfile.lock +73 -36
  10. data/gemfiles/rails3.0.gemfile.lock +59 -26
  11. data/gemfiles/rails3.1.gemfile.lock +59 -26
  12. data/gemfiles/rails3.2.gemfile.lock +63 -30
  13. data/gemfiles/rails4.gemfile.lock +69 -36
  14. data/gemfiles/rake.gemfile.lock +62 -27
  15. data/gemfiles/sinatra.gemfile.lock +62 -27
  16. data/honeybadger.gemspec +31 -17
  17. data/lib/honeybadger.rb +2 -3
  18. data/lib/honeybadger/array.rb +53 -0
  19. data/lib/honeybadger/configuration.rb +19 -2
  20. data/lib/honeybadger/monitor.rb +16 -0
  21. data/lib/honeybadger/monitor/railtie.rb +52 -0
  22. data/lib/honeybadger/monitor/sender.rb +33 -0
  23. data/lib/honeybadger/monitor/worker.rb +71 -0
  24. data/lib/honeybadger/railtie.rb +10 -0
  25. data/lib/honeybadger/sender.rb +60 -41
  26. data/{test/unit/backtrace_test.rb → spec/honeybadger/backtrace_spec.rb} +69 -71
  27. data/{test/unit/capistrano_test.rb → spec/honeybadger/capistrano_spec.rb} +8 -9
  28. data/{test/unit/configuration_test.rb → spec/honeybadger/configuration_spec.rb} +85 -59
  29. data/spec/honeybadger/logger_spec.rb +65 -0
  30. data/spec/honeybadger/monitor/worker_spec.rb +189 -0
  31. data/{test/unit/notice_test.rb → spec/honeybadger/notice_spec.rb} +169 -185
  32. data/spec/honeybadger/notifier_spec.rb +252 -0
  33. data/spec/honeybadger/rack_spec.rb +84 -0
  34. data/{test/unit/rails/action_controller_catcher_test.rb → spec/honeybadger/rails/action_controller_spec.rb} +65 -57
  35. data/{test/unit/rails_test.rb → spec/honeybadger/rails_spec.rb} +8 -8
  36. data/spec/honeybadger/sender_spec.rb +249 -0
  37. data/spec/honeybadger_tasks_spec.rb +165 -0
  38. data/spec/spec_helper.rb +18 -0
  39. data/spec/support/array_including.rb +31 -0
  40. data/spec/support/backtraced_exception.rb +9 -0
  41. data/spec/support/collected_sender.rb +12 -0
  42. data/spec/support/defines_constants.rb +18 -0
  43. data/{test/test_helper.rb → spec/support/helpers.rb} +8 -61
  44. metadata +93 -45
  45. data/test/unit/honeybadger_tasks_test.rb +0 -167
  46. data/test/unit/logger_test.rb +0 -74
  47. data/test/unit/notifier_test.rb +0 -265
  48. data/test/unit/rack_test.rb +0 -88
  49. data/test/unit/sender_test.rb +0 -290
@@ -1,8 +1,8 @@
1
- require 'test_helper'
1
+ require 'spec_helper'
2
2
  require 'stringio'
3
3
 
4
- class BacktraceTest < Test::Unit::TestCase
5
- should "parse a backtrace into lines" do
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
- assert_equal '13', line.number
15
- assert_equal 'app/models/user.rb', line.file
16
- assert_equal 'magic', line.method
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
- assert_equal '8', line.number
20
- assert_equal 'app/controllers/users_controller.rb', line.file
21
- assert_equal 'index', line.method
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
- should "parse a windows backtrace into lines" do
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
- assert_equal '13', line.number
34
- assert_equal 'C:/Program Files/Server/app/models/user.rb', line.file
35
- assert_equal 'magic', line.method
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
- assert_equal '8', line.number
39
- assert_equal 'C:/Program Files/Server/app/controllers/users_controller.rb', line.file
40
- assert_equal 'index', line.method
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
- should "be equal with equal lines" do
43
+ it "is equal with equal lines" do
44
44
  one = build_backtrace_array
45
45
  two = one.dup
46
46
 
47
- assert_equal Honeybadger::Backtrace.parse(one), Honeybadger::Backtrace.parse(two)
47
+ expect(Honeybadger::Backtrace.parse(one)).to eq Honeybadger::Backtrace.parse(two)
48
48
  end
49
49
 
50
- should "parse massive one-line exceptions into multiple lines" do
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
- assert_equal expected_backtrace, original_backtrace
56
+ expect(expected_backtrace).to eq original_backtrace
57
57
  end
58
58
 
59
59
  context "when source file exists" do
60
- setup do
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.expects(:exists?).with(file).returns true
80
- File.expects(:open).with(file).yields StringIO.new(source)
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
- should "include a snippet from the source file for each line of the backtrace" do
87
- assert_equal 4, @backtrace.lines[0].source.keys.size
88
- assert_match /\$:<</, @backtrace.lines[0].source[1]
89
- assert_match /require/, @backtrace.lines[0].source[2]
90
- assert_match /\n/, @backtrace.lines[0].source[3]
91
- assert_match /begin/, @backtrace.lines[0].source[4]
92
-
93
- assert_equal 5, @backtrace.lines[1].source.keys.size
94
- assert_match /require/, @backtrace.lines[1].source[2]
95
- assert_match /\n/, @backtrace.lines[1].source[3]
96
- assert_match /begin/, @backtrace.lines[1].source[4]
97
- assert_match /StandardError/, @backtrace.lines[1].source[5]
98
- assert_match /rescue/, @backtrace.lines[1].source[6]
99
-
100
- assert_equal 3, @backtrace.lines[2].source.keys.size
101
- assert_match /rescue/, @backtrace.lines[2].source[6]
102
- assert_match /Honeybadger/, @backtrace.lines[2].source[7]
103
- assert_match /end/, @backtrace.lines[2].source[8]
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
- should "fail gracefully when looking up snippet and file doesn't exist" do
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
- assert_equal backtrace.lines[0].source, {}
116
- assert_equal backtrace.lines[1].source, {}
115
+ expect(backtrace.lines[0].source).to be_empty
116
+ expect(backtrace.lines[1].source).to be_empty
117
117
  end
118
118
 
119
- should "have an empty application trace by default" do
119
+ it "has an empty application trace by default" do
120
120
  backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
121
- assert_equal backtrace.application_lines, []
121
+ expect(backtrace.application_lines).to be_empty
122
122
  end
123
123
 
124
124
  context "with a project root" do
125
- setup do
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
- should "filter out the project root" do
143
- assert_equal @backtrace_without_root, @backtrace_with_root
142
+ it "filters out the project root" do
143
+ expect(@backtrace_without_root).to eq @backtrace_with_root
144
144
  end
145
145
 
146
- should "have an application trace" do
147
- assert_equal @backtrace_without_root.application_lines, @backtrace_without_root.lines[0..1]
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
- should "filter ./vendor from application trace" do
151
- assert_does_not_contain @backtrace_without_root.application_lines, @backtrace_without_root.lines[2]
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
- setup do
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
- should "filter out the project root" do
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
- assert_equal backtrace_without_root, backtrace_with_root
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
- setup do
178
+ before(:each) do
179
179
  Honeybadger.configure {|config| config.project_root = '' }
180
180
  end
181
181
 
182
- should "not filter line numbers with respect to any project root" do
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
- assert_equal backtrace_without_root, backtrace_with_root
193
+ expect(backtrace_without_root).to eq backtrace_with_root
194
194
  end
195
195
  end
196
196
 
197
- should "remove notifier trace" do
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
- assert_equal without_inside, with_inside
205
+ expect(without_inside).to eq with_inside
206
206
  end
207
207
 
208
- should "run filters on the backtrace" do
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
- assert_equal expected, input
213
+ expect(expected).to eq input
214
214
  end
215
215
 
216
- should "alias #to_ary as #to_a" do
216
+ it "aliases #to_ary as #to_a" do
217
217
  backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
218
218
 
219
- assert_equal backtrace.to_a, backtrace.to_ary
219
+ expect(backtrace.to_a).to eq backtrace.to_ary
220
220
  end
221
221
 
222
- should "generate json from to_array template" do
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.expects(:to_ary).once.returns(array)
225
+ backtrace.should_receive(:to_ary).once.and_return(array)
226
226
  json = backtrace.to_json
227
227
 
228
228
  payload = nil
229
- assert_nothing_raised do
230
- payload = JSON.parse(json)
231
- end
229
+ expect { payload = JSON.parse(json) }.not_to raise_error
232
230
 
233
- assert_equal payload, array
231
+ expect(payload).to eq array
234
232
  end
235
233
 
236
234
  def build_backtrace_array
@@ -1,11 +1,10 @@
1
- require 'test_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  require 'capistrano/configuration'
4
4
  require 'honeybadger/capistrano'
5
5
 
6
- class CapistranoTest < Test::Unit::TestCase
7
- def setup
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
- should "define honeybadger:deploy task" do
17
- assert_not_nil @configuration.find_task('honeybadger:deploy')
15
+ it "defines honeybadger:deploy task" do
16
+ expect(@configuration.find_task('honeybadger:deploy')).not_to be_nil
18
17
  end
19
18
 
20
- should "log when calling honeybadger:deploy task" do
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
- assert io.string.include?('** Notifying Honeybadger of Deploy')
32
- assert io.string.include?('** Honeybadger Notification Complete')
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 'test_helper'
1
+ require 'spec_helper'
2
+ require 'socket'
2
3
 
3
- class ConfigurationTest < Test::Unit::TestCase
4
- should "provide default values" do
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, nil
34
+ assert_config_default :hostname, Socket.gethostname
34
35
  end
35
36
 
36
- should "configure async as Proc" do
37
+ it "configures async as Proc" do
37
38
  config = Honeybadger::Configuration.new
38
39
  async_handler = Proc.new { |n| n.deliver }
39
- assert !config.async?, 'Configuration#async? should be falsey'
40
+ expect(config.async?).to be_false
40
41
  config.async = async_handler
41
- assert config.async?, 'Configuration#async? should be truthy'
42
- assert_equal config.async, async_handler
42
+ expect(config.async?).to be_true
43
+ expect(config.async).to be async_handler
43
44
  end
44
45
 
45
- should "configure async with block" do
46
+ it "configures async with block" do
46
47
  config = Honeybadger::Configuration.new
47
- assert !config.async?, 'Configuration#async? should be falsey'
48
+ expect(config.async?).to be_false
48
49
  config.async { |n| n }
49
- assert config.async?, 'Configuration#async? should be truthy'
50
- assert_equal config.async.call('foo'), 'foo'
50
+ expect(config.async?).to be_true
51
+ expect(config.async.call('foo')).to eq 'foo'
51
52
  end
52
53
 
53
- should "configure fingerprint as Proc" do
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
- assert_equal config.fingerprint.call({ :error_class => 'foo' }), 'foo'
58
+ expect(config.fingerprint.call({ :error_class => 'foo' })).to eq 'foo'
58
59
  end
59
60
 
60
- should "configure fingerprint with block" do
61
+ it "configures fingerprint with block" do
61
62
  config = Honeybadger::Configuration.new
62
63
  config.fingerprint { |n| n[:error_class] }
63
- assert_equal config.fingerprint.call({ :error_class => 'foo' }), 'foo'
64
+ expect(config.fingerprint.call({ :error_class => 'foo' })).to eq 'foo'
64
65
  end
65
66
 
66
- should "stub current_user_method" do
67
+ it "stubs current_user_method" do
67
68
  config = Honeybadger::Configuration.new
68
- assert_nothing_raised { config.current_user_method = :foo }
69
+ expect { config.current_user_method = :foo }.not_to raise_error
69
70
  end
70
71
 
71
- should "provide default values for secure connections" do
72
+ it "provides default values for secure connections" do
72
73
  config = Honeybadger::Configuration.new
73
74
  config.secure = true
74
- assert_equal 443, config.port
75
- assert_equal 'https', config.protocol
75
+ expect(config.port).to eq 443
76
+ expect(config.protocol).to eq 'https'
76
77
  end
77
78
 
78
- should "provide default values for insecure connections" do
79
+ it "provides default values for insecure connections" do
79
80
  config = Honeybadger::Configuration.new
80
81
  config.secure = false
81
- assert_equal 80, config.port
82
- assert_equal 'http', config.protocol
82
+ expect(config.port).to eq 80
83
+ expect(config.protocol).to eq 'http'
83
84
  end
84
85
 
85
- should "not cache inferred ports" do
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
- assert_equal 443, config.port
91
+ expect(config.port).to eq 443
91
92
  end
92
93
 
93
- should "allow values to be overwritten" do
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
- should "have an api key" do
118
+ it "has an api key" do
118
119
  assert_config_overridable :api_key
119
120
  end
120
121
 
121
- should "act like a hash" do
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
- assert_equal config[option], hash[option], "Wrong value for #{option}"
132
+ expect(hash[option]).to eq config[option]
132
133
  end
133
134
  end
134
135
 
135
- should "be mergable" do
136
+ it "is mergable" do
136
137
  config = Honeybadger::Configuration.new
137
138
  hash = config.to_hash
138
- assert_equal hash.merge(:key => 'value'), config.merge(:key => 'value')
139
+ expect(hash.merge(:key => 'value')).to eq config.merge(:key => 'value')
139
140
  end
140
141
 
141
- should "allow param filters to be appended" do
142
+ it "allows param filters to be appended" do
142
143
  assert_appends_value :params_filters
143
144
  end
144
145
 
145
- should "allow ignored user agents to be appended" do
146
+ it "allows ignored user agents to be appended" do
146
147
  assert_appends_value :ignore_user_agent
147
148
  end
148
149
 
149
- should "allow backtrace filters to be appended" do
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
- should "allow ignore by filters to be appended" do
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
- should "allow ignored exceptions to be appended" do
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
- assert_same_elements original_filters + [new_filter], config.ignore
171
+ expect(original_filters + [new_filter]).to eq config.ignore
171
172
  end
172
173
 
173
- should "allow ignored exceptions to be replaced" do
174
+ it "allows ignored exceptions to be replaced" do
174
175
  assert_replaces(:ignore, :ignore_only=)
175
176
  end
176
177
 
177
- should "allow ignored user agents to be replaced" do
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
- should "use development and test as development environments by default" do
182
+ it "uses development and test as development environments by default" do
182
183
  config = Honeybadger::Configuration.new
183
- assert_same_elements %w(development test cucumber), config.development_environments
184
+ expect(config.development_environments).to eq %w(development test cucumber)
184
185
  end
185
186
 
186
- should "be public in a public environment" do
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
- assert config.public?
191
+ expect(config.public?).to be_true
191
192
  end
192
193
 
193
- should "not be public in a development environment" do
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
- assert !config.public?
198
+ expect(config.public?).to be_false
198
199
  end
199
200
 
200
- should "be public without an environment name" do
201
+ it "is public without an environment name" do
201
202
  config = Honeybadger::Configuration.new
202
- assert config.public?
203
+ expect(config.public?).to be_true
203
204
  end
204
205
 
205
- should "use the assigned logger if set" do
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
- assert_equal "CUSTOM LOGGER", config.logger
234
+ expect(config.logger).to eq "CUSTOM LOGGER"
209
235
  end
210
236
 
211
- should 'give a new instance if non defined' do
237
+ it 'gives a new instance if non defined' do
212
238
  Honeybadger.configuration = nil
213
- assert_kind_of Honeybadger::Configuration, Honeybadger.configuration
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
- assert_equal default_value, config.send(option)
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
- assert_equal value, config.send(option)
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 |config|
256
+ block ||= lambda do |c|
231
257
  new_value = 'hello'
232
- config.send(option) << new_value
258
+ c.send(option) << new_value
233
259
  new_value
234
260
  end
235
261
  new_value = block.call(config)
236
- assert_same_elements original_values + [new_value], config.send(option)
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
- assert_equal [new_value], config.send(option)
269
+ expect(config.send(option)).to eq [new_value]
244
270
  config.send(setter, new_value)
245
- assert_equal [new_value], config.send(option)
271
+ expect(config.send(option)).to eq [new_value]
246
272
  end
247
273
  end