honeybadger 1.16.7 → 2.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +19 -0
  3. data/README.md +37 -16
  4. data/bin/honeybadger +5 -0
  5. data/lib/honeybadger.rb +167 -191
  6. data/lib/honeybadger/agent.rb +136 -0
  7. data/lib/honeybadger/backend.rb +26 -0
  8. data/lib/honeybadger/backend/base.rb +66 -0
  9. data/lib/honeybadger/backend/debug.rb +12 -0
  10. data/lib/honeybadger/backend/null.rb +16 -0
  11. data/lib/honeybadger/backend/server.rb +51 -0
  12. data/lib/honeybadger/backend/test.rb +24 -0
  13. data/lib/honeybadger/backtrace.rb +29 -24
  14. data/lib/honeybadger/cli.rb +367 -0
  15. data/lib/honeybadger/config.rb +333 -0
  16. data/lib/honeybadger/config/callbacks.rb +70 -0
  17. data/lib/honeybadger/config/defaults.rb +175 -0
  18. data/lib/honeybadger/config/env.rb +40 -0
  19. data/lib/honeybadger/config/yaml.rb +43 -0
  20. data/lib/honeybadger/const.rb +28 -0
  21. data/lib/honeybadger/init/rails.rb +84 -0
  22. data/lib/honeybadger/init/sinatra.rb +27 -0
  23. data/lib/honeybadger/logging.rb +133 -0
  24. data/lib/honeybadger/notice.rb +243 -280
  25. data/lib/honeybadger/plugin.rb +110 -0
  26. data/lib/honeybadger/plugins/delayed_job.rb +22 -0
  27. data/lib/honeybadger/{integrations → plugins}/delayed_job/plugin.rb +6 -7
  28. data/lib/honeybadger/{integrations → plugins}/local_variables.rb +7 -8
  29. data/lib/honeybadger/{integrations → plugins}/net_http.rb +10 -8
  30. data/lib/honeybadger/plugins/passenger.rb +24 -0
  31. data/lib/honeybadger/plugins/rails.rb +61 -0
  32. data/lib/honeybadger/plugins/sidekiq.rb +35 -0
  33. data/lib/honeybadger/{integrations → plugins}/thor.rb +9 -8
  34. data/lib/honeybadger/{integrations → plugins}/unicorn.rb +10 -9
  35. data/lib/honeybadger/rack/error_notifier.rb +44 -27
  36. data/lib/honeybadger/rack/metrics_reporter.rb +41 -0
  37. data/lib/honeybadger/rack/request_hash.rb +50 -0
  38. data/lib/honeybadger/rack/user_feedback.rb +15 -10
  39. data/lib/honeybadger/rack/user_informer.rb +14 -3
  40. data/lib/honeybadger/trace.rb +185 -0
  41. data/lib/honeybadger/util/http.rb +79 -0
  42. data/lib/honeybadger/util/request_sanitizer.rb +35 -0
  43. data/lib/honeybadger/util/sanitizer.rb +71 -0
  44. data/lib/honeybadger/util/stats.rb +31 -0
  45. data/lib/honeybadger/version.rb +4 -0
  46. data/lib/honeybadger/worker.rb +224 -0
  47. data/lib/honeybadger/worker/batch.rb +50 -0
  48. data/lib/honeybadger/worker/metered_queue.rb +80 -0
  49. data/lib/honeybadger/worker/metrics_collection.rb +61 -0
  50. data/lib/honeybadger/worker/metrics_collector.rb +96 -0
  51. data/{lib/honeybadger/capistrano.rb → vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb} +1 -3
  52. data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +76 -0
  53. data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -0
  54. data/{lib → vendor/capistrano-honeybadger/lib}/honeybadger/capistrano/legacy.rb +16 -15
  55. data/vendor/thor/lib/thor.rb +484 -0
  56. data/vendor/thor/lib/thor/actions.rb +319 -0
  57. data/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  58. data/vendor/thor/lib/thor/actions/create_link.rb +59 -0
  59. data/vendor/thor/lib/thor/actions/directory.rb +118 -0
  60. data/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
  61. data/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
  62. data/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
  63. data/vendor/thor/lib/thor/base.rb +656 -0
  64. data/vendor/thor/lib/thor/command.rb +133 -0
  65. data/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  66. data/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
  67. data/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
  68. data/vendor/thor/lib/thor/error.rb +32 -0
  69. data/vendor/thor/lib/thor/group.rb +281 -0
  70. data/vendor/thor/lib/thor/invocation.rb +178 -0
  71. data/vendor/thor/lib/thor/line_editor.rb +17 -0
  72. data/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
  73. data/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  74. data/vendor/thor/lib/thor/parser.rb +4 -0
  75. data/vendor/thor/lib/thor/parser/argument.rb +73 -0
  76. data/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  77. data/vendor/thor/lib/thor/parser/option.rb +125 -0
  78. data/vendor/thor/lib/thor/parser/options.rb +218 -0
  79. data/vendor/thor/lib/thor/rake_compat.rb +71 -0
  80. data/vendor/thor/lib/thor/runner.rb +322 -0
  81. data/vendor/thor/lib/thor/shell.rb +81 -0
  82. data/vendor/thor/lib/thor/shell/basic.rb +421 -0
  83. data/vendor/thor/lib/thor/shell/color.rb +149 -0
  84. data/vendor/thor/lib/thor/shell/html.rb +126 -0
  85. data/vendor/thor/lib/thor/util.rb +267 -0
  86. data/vendor/thor/lib/thor/version.rb +3 -0
  87. metadata +97 -305
  88. data/Appraisals +0 -95
  89. data/CHANGELOG.md +0 -422
  90. data/Gemfile +0 -8
  91. data/Gemfile.lock +0 -136
  92. data/Guardfile +0 -5
  93. data/MIT-LICENSE +0 -32
  94. data/Rakefile +0 -159
  95. data/features/metal.feature +0 -20
  96. data/features/rack.feature +0 -55
  97. data/features/rails.feature +0 -343
  98. data/features/rails3.x.feature +0 -26
  99. data/features/rake.feature +0 -25
  100. data/features/sinatra.feature +0 -27
  101. data/features/standalone.feature +0 -73
  102. data/features/step_definitions/metal_steps.rb +0 -24
  103. data/features/step_definitions/rack_steps.rb +0 -18
  104. data/features/step_definitions/rails_steps.rb +0 -270
  105. data/features/step_definitions/rake_steps.rb +0 -17
  106. data/features/step_definitions/standalone_steps.rb +0 -12
  107. data/features/step_definitions/thor_steps.rb +0 -4
  108. data/features/support/env.rb +0 -22
  109. data/features/support/honeybadger_failure_shim.rb.template +0 -5
  110. data/features/support/honeybadger_shim.rb.template +0 -6
  111. data/features/support/rails.rb +0 -202
  112. data/features/support/rake/Rakefile +0 -68
  113. data/features/support/test.thor +0 -22
  114. data/features/thor.feature +0 -5
  115. data/gemfiles/binding_of_caller.gemfile +0 -13
  116. data/gemfiles/delayed_job.gemfile +0 -13
  117. data/gemfiles/rack.gemfile +0 -13
  118. data/gemfiles/rails.gemfile +0 -16
  119. data/gemfiles/rails2.3.gemfile +0 -15
  120. data/gemfiles/rails3.0.gemfile +0 -16
  121. data/gemfiles/rails3.1.gemfile +0 -16
  122. data/gemfiles/rails3.2.gemfile +0 -16
  123. data/gemfiles/rails4.0.gemfile +0 -16
  124. data/gemfiles/rails4.1.gemfile +0 -16
  125. data/gemfiles/rake.gemfile +0 -13
  126. data/gemfiles/sinatra.gemfile +0 -13
  127. data/gemfiles/standalone.gemfile +0 -12
  128. data/gemfiles/thor.gemfile +0 -13
  129. data/generators/honeybadger/honeybadger_generator.rb +0 -95
  130. data/generators/honeybadger/lib/insert_commands.rb +0 -34
  131. data/generators/honeybadger/lib/rake_commands.rb +0 -24
  132. data/generators/honeybadger/templates/capistrano_hook.rb +0 -6
  133. data/generators/honeybadger/templates/honeybadger_tasks.rake +0 -25
  134. data/generators/honeybadger/templates/initializer.rb +0 -6
  135. data/honeybadger.gemspec +0 -174
  136. data/lib/honeybadger/array.rb +0 -53
  137. data/lib/honeybadger/capistrano/tasks.rake +0 -73
  138. data/lib/honeybadger/configuration.rb +0 -397
  139. data/lib/honeybadger/dependency.rb +0 -65
  140. data/lib/honeybadger/integrations.rb +0 -9
  141. data/lib/honeybadger/integrations/delayed_job.rb +0 -20
  142. data/lib/honeybadger/integrations/passenger.rb +0 -18
  143. data/lib/honeybadger/integrations/sidekiq.rb +0 -37
  144. data/lib/honeybadger/monitor.rb +0 -17
  145. data/lib/honeybadger/monitor/railtie.rb +0 -53
  146. data/lib/honeybadger/monitor/sender.rb +0 -44
  147. data/lib/honeybadger/monitor/trace.rb +0 -187
  148. data/lib/honeybadger/monitor/worker.rb +0 -169
  149. data/lib/honeybadger/payload.rb +0 -101
  150. data/lib/honeybadger/rack.rb +0 -12
  151. data/lib/honeybadger/rails.rb +0 -45
  152. data/lib/honeybadger/rails/action_controller_catcher.rb +0 -30
  153. data/lib/honeybadger/rails/controller_methods.rb +0 -78
  154. data/lib/honeybadger/rails/middleware/exceptions_catcher.rb +0 -29
  155. data/lib/honeybadger/rails3_tasks.rb +0 -94
  156. data/lib/honeybadger/railtie.rb +0 -52
  157. data/lib/honeybadger/rake_handler.rb +0 -66
  158. data/lib/honeybadger/sender.rb +0 -185
  159. data/lib/honeybadger/shared_tasks.rb +0 -56
  160. data/lib/honeybadger/stats.rb +0 -29
  161. data/lib/honeybadger/tasks.rb +0 -95
  162. data/lib/honeybadger/user_feedback.rb +0 -8
  163. data/lib/honeybadger/user_informer.rb +0 -8
  164. data/lib/honeybadger_tasks.rb +0 -69
  165. data/lib/rails/generators/honeybadger/honeybadger_generator.rb +0 -99
  166. data/rails/init.rb +0 -1
  167. data/resources/README.md +0 -34
  168. data/script/integration_test.rb +0 -38
  169. data/spec/allocation_stats.rb +0 -32
  170. data/spec/honeybadger/backtrace_spec.rb +0 -242
  171. data/spec/honeybadger/capistrano_spec.rb +0 -36
  172. data/spec/honeybadger/configuration_spec.rb +0 -328
  173. data/spec/honeybadger/dependency_spec.rb +0 -134
  174. data/spec/honeybadger/integrations/delayed_job_spec.rb +0 -82
  175. data/spec/honeybadger/integrations/local_variables_spec.rb +0 -60
  176. data/spec/honeybadger/integrations/net_http_spec.rb +0 -29
  177. data/spec/honeybadger/integrations/passenger_spec.rb +0 -29
  178. data/spec/honeybadger/integrations/sidekiq_spec.rb +0 -60
  179. data/spec/honeybadger/integrations/thor_spec.rb +0 -32
  180. data/spec/honeybadger/integrations/unicorn_spec.rb +0 -40
  181. data/spec/honeybadger/logger_spec.rb +0 -79
  182. data/spec/honeybadger/monitor/trace_spec.rb +0 -65
  183. data/spec/honeybadger/monitor/worker_spec.rb +0 -274
  184. data/spec/honeybadger/notice_spec.rb +0 -669
  185. data/spec/honeybadger/notifier_spec.rb +0 -328
  186. data/spec/honeybadger/payload_spec.rb +0 -162
  187. data/spec/honeybadger/rack_spec.rb +0 -85
  188. data/spec/honeybadger/rails/action_controller_spec.rb +0 -328
  189. data/spec/honeybadger/rails_spec.rb +0 -37
  190. data/spec/honeybadger/sender_spec.rb +0 -317
  191. data/spec/honeybadger/stats_spec.rb +0 -57
  192. data/spec/honeybadger/user_feedback_spec.rb +0 -80
  193. data/spec/honeybadger/user_informer_spec.rb +0 -30
  194. data/spec/honeybadger_tasks_spec.rb +0 -171
  195. data/spec/spec_helper.rb +0 -24
  196. data/spec/support/array_including.rb +0 -31
  197. data/spec/support/backtraced_exception.rb +0 -9
  198. data/spec/support/collected_sender.rb +0 -12
  199. data/spec/support/defines_constants.rb +0 -18
  200. data/spec/support/helpers.rb +0 -101
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
- require 'capistrano'
3
-
4
- if defined?(Capistrano::Configuration.instance)
5
- describe 'Honeybadger::Capistrano' do
6
- require 'capistrano/configuration'
7
- require 'honeybadger/capistrano'
8
-
9
- before { reset_config }
10
-
11
- before(:each) do
12
- @configuration = Capistrano::Configuration.new
13
- Honeybadger::Capistrano.load_into(@configuration)
14
- @configuration.dry_run = true
15
- end
16
-
17
- it "defines honeybadger:deploy task" do
18
- expect(@configuration.find_task('honeybadger:deploy')).not_to be_nil
19
- end
20
-
21
- it "logs when calling honeybadger:deploy task" do
22
- @configuration.set(:current_revision, '084505b1c0e0bcf1526e673bb6ac99fbcb18aecc')
23
- @configuration.set(:repository, 'repository')
24
- @configuration.set(:current_release, '/home/deploy/rails_app/honeybadger')
25
- io = StringIO.new
26
- logger = Capistrano::Logger.new(:output => io)
27
- logger.level = Capistrano::Logger::MAX_LEVEL
28
-
29
- @configuration.logger = logger
30
- @configuration.find_and_execute_task('honeybadger:deploy')
31
-
32
- expect(io.string).to include '** Notifying Honeybadger of Deploy'
33
- expect(io.string).to include '** Honeybadger Notification Complete'
34
- end
35
- end
36
- end
@@ -1,328 +0,0 @@
1
- require 'spec_helper'
2
- require 'socket'
3
-
4
- describe Honeybadger::Configuration do
5
- it "provides default values" do
6
- assert_config_default :api_key, nil
7
- assert_config_default :proxy_host, nil
8
- assert_config_default :proxy_port, nil
9
- assert_config_default :proxy_user, nil
10
- assert_config_default :proxy_pass, nil
11
- assert_config_default :project_root, nil
12
- assert_config_default :environment_name, nil
13
- assert_config_default :logger, nil
14
- assert_config_default :notifier_version, Honeybadger::VERSION
15
- assert_config_default :notifier_name, 'Honeybadger Notifier'
16
- assert_config_default :notifier_url, 'https://github.com/honeybadger-io/honeybadger-ruby'
17
- assert_config_default :secure, true
18
- assert_config_default :host, 'api.honeybadger.io'
19
- assert_config_default :http_open_timeout, 2
20
- assert_config_default :http_read_timeout, 5
21
- assert_config_default :ignore_by_filters, []
22
- assert_config_default :ignore_user_agent, []
23
- assert_config_default :params_filters,
24
- Honeybadger::Configuration::DEFAULT_PARAMS_FILTERS
25
- assert_config_default :backtrace_filters,
26
- Honeybadger::Configuration::DEFAULT_BACKTRACE_FILTERS
27
- assert_config_default :ignore,
28
- Honeybadger::Configuration::IGNORE_DEFAULT
29
- assert_config_default :framework, 'Standalone'
30
- assert_config_default :source_extract_radius, 2
31
- assert_config_default :async, nil
32
- assert_config_default :send_request_session, true
33
- assert_config_default :send_local_variables, false
34
- assert_config_default :unwrap_exceptions, true
35
- assert_config_default :debug, false
36
- assert_config_default :log_exception_on_send_failure, false
37
- assert_config_default :fingerprint, nil
38
- assert_config_default :hostname, Socket.gethostname
39
- assert_config_default :feedback, true
40
- assert_config_default :features, {'notices' => true, 'local_variables' => true}
41
- end
42
-
43
- it "configures async as Proc" do
44
- config = Honeybadger::Configuration.new
45
- async_handler = Proc.new { |n| n.deliver }
46
- expect(config.async?).to be_false
47
- config.async = async_handler
48
- expect(config.async?).to be_true
49
- expect(config.async).to be async_handler
50
- end
51
-
52
- it "configures async with block" do
53
- config = Honeybadger::Configuration.new
54
- expect(config.async?).to be_false
55
- config.async { |n| n }
56
- expect(config.async?).to be_true
57
- expect(config.async.call('foo')).to eq 'foo'
58
- end
59
-
60
- it "configures fingerprint as Proc" do
61
- config = Honeybadger::Configuration.new
62
- fingerprint_generator = Proc.new { |n| n[:error_class] }
63
- config.fingerprint = fingerprint_generator
64
- expect(config.fingerprint.call({ :error_class => 'foo' })).to eq 'foo'
65
- end
66
-
67
- it "configures fingerprint with block" do
68
- config = Honeybadger::Configuration.new
69
- config.fingerprint { |n| n[:error_class] }
70
- expect(config.fingerprint.call({ :error_class => 'foo' })).to eq 'foo'
71
- end
72
-
73
- it "stubs current_user_method" do
74
- config = Honeybadger::Configuration.new
75
- expect { config.current_user_method = :foo }.not_to raise_error
76
- end
77
-
78
- it "provides default values for secure connections" do
79
- config = Honeybadger::Configuration.new
80
- config.secure = true
81
- expect(config.port).to eq 443
82
- expect(config.protocol).to eq 'https'
83
- end
84
-
85
- it "provides default values for insecure connections" do
86
- config = Honeybadger::Configuration.new
87
- config.secure = false
88
- expect(config.port).to eq 80
89
- expect(config.protocol).to eq 'http'
90
- end
91
-
92
- it "does not cache inferred ports" do
93
- config = Honeybadger::Configuration.new
94
- config.secure = false
95
- config.port
96
- config.secure = true
97
- expect(config.port).to eq 443
98
- end
99
-
100
- it "allows values to be overwritten" do
101
- assert_config_overridable :proxy_host
102
- assert_config_overridable :proxy_port
103
- assert_config_overridable :proxy_user
104
- assert_config_overridable :proxy_pass
105
- assert_config_overridable :secure
106
- assert_config_overridable :host
107
- assert_config_overridable :port
108
- assert_config_overridable :http_open_timeout
109
- assert_config_overridable :http_read_timeout
110
- assert_config_overridable :project_root
111
- assert_config_overridable :notifier_version
112
- assert_config_overridable :notifier_name
113
- assert_config_overridable :notifier_url
114
- assert_config_overridable :environment_name
115
- assert_config_overridable :logger
116
- assert_config_overridable :source_extract_radius
117
- assert_config_overridable :async
118
- assert_config_overridable :fingerprint
119
- assert_config_overridable :send_request_session
120
- assert_config_overridable :debug
121
- assert_config_overridable :hostname
122
- assert_config_overridable :features
123
- assert_config_overridable :metrics
124
- assert_config_overridable :feedback
125
- assert_config_overridable :log_exception_on_send_failure
126
- end
127
-
128
- it "has an api key" do
129
- assert_config_overridable :api_key
130
- end
131
-
132
- it "acts like a hash" do
133
- config = Honeybadger::Configuration.new
134
- hash = config.to_hash
135
- [:api_key, :backtrace_filters, :development_environments,
136
- :environment_name, :host, :http_open_timeout, :http_read_timeout, :ignore,
137
- :ignore_by_filters, :ignore_user_agent, :notifier_name, :notifier_url,
138
- :notifier_version, :params_filters, :project_root, :port, :protocol,
139
- :proxy_host, :proxy_pass, :proxy_port, :proxy_user, :secure,
140
- :source_extract_radius, :async, :send_request_session, :debug,
141
- :fingerprint, :hostname, :features, :metrics, :feedback,
142
- :log_exception_on_send_failure, :unwrap_exceptions].each do |option|
143
- expect(hash[option]).to eq config[option]
144
- end
145
- end
146
-
147
- it "is mergable" do
148
- config = Honeybadger::Configuration.new
149
- hash = config.to_hash
150
- expect(hash.merge(:key => 'value')).to eq config.merge(:key => 'value')
151
- end
152
-
153
- it "allows param filters to be appended" do
154
- assert_appends_value :params_filters
155
- end
156
-
157
- it "allows ignored user agents to be appended" do
158
- assert_appends_value :ignore_user_agent
159
- end
160
-
161
- it "allows backtrace filters to be appended" do
162
- assert_appends_value(:backtrace_filters) do |config|
163
- new_filter = lambda {}
164
- config.filter_backtrace(&new_filter)
165
- new_filter
166
- end
167
- end
168
-
169
- it "allows ignore by filters to be appended" do
170
- assert_appends_value(:ignore_by_filters) do |config|
171
- new_filter = lambda {}
172
- config.ignore_by_filter(&new_filter)
173
- new_filter
174
- end
175
- end
176
-
177
- it "allows ignored exceptions to be appended" do
178
- config = Honeybadger::Configuration.new
179
- original_filters = config.ignore.dup
180
- new_filter = 'hello'
181
- config.ignore << new_filter
182
- expect(original_filters + [new_filter]).to eq config.ignore
183
- end
184
-
185
- it "allows ignored exceptions to be replaced" do
186
- assert_replaces(:ignore, :ignore_only=)
187
- end
188
-
189
- it "allows ignored user agents to be replaced" do
190
- assert_replaces(:ignore_user_agent, :ignore_user_agent_only=)
191
- end
192
-
193
- it "uses development and test as development environments by default" do
194
- config = Honeybadger::Configuration.new
195
- expect(config.development_environments).to eq %w(development test cucumber)
196
- end
197
-
198
- describe "#public?" do
199
- let(:config) { Honeybadger::Configuration.new }
200
-
201
- subject { config.public? }
202
-
203
- before do
204
- config.api_key = 'asdf'
205
- end
206
-
207
- context "when api_key is not configured" do
208
- before { config.api_key = nil }
209
-
210
- it { should be_false }
211
- end
212
-
213
- context "when api_key is configured" do
214
- it { should be_true }
215
- end
216
-
217
- context "without an environment name" do
218
- it { should be_true }
219
- end
220
-
221
- context "when environment is public" do
222
- before do
223
- config.development_environments = %w(development)
224
- config.environment_name = 'production'
225
- end
226
-
227
- it { should be_true }
228
- end
229
-
230
- context "when environment is development" do
231
- before do
232
- config.development_environments = %w(development)
233
- config.environment_name = 'development'
234
- end
235
-
236
- it { should be_false }
237
- end
238
- end
239
-
240
- describe "#metrics?" do
241
- let(:config) { Honeybadger::Configuration.new }
242
-
243
- context "when public" do
244
- before { config.stub(:public?).and_return(true) }
245
-
246
- it "sends metrics by default" do
247
- expect(config.metrics?).to be_true
248
- end
249
-
250
- context "when disabled" do
251
- before { config.metrics = false }
252
-
253
- it "does not send metrics" do
254
- expect(config.metrics?).to be_false
255
- end
256
- end
257
- end
258
-
259
- context "when not public" do
260
- before { config.stub(:public?).and_return(false) }
261
-
262
- it "does not send metrics" do
263
- expect(config.metrics?).to be_false
264
- end
265
- end
266
- end
267
-
268
- it "uses the assigned logger if set" do
269
- config = Honeybadger::Configuration.new
270
- config.logger = "CUSTOM LOGGER"
271
- expect(config.logger).to eq "CUSTOM LOGGER"
272
- end
273
-
274
- it "gives a new instance if non defined" do
275
- Honeybadger.configuration = nil
276
- expect(Honeybadger.configuration).to be_a Honeybadger::Configuration
277
- end
278
-
279
- describe '#trace_threshold=' do
280
- let(:config) { Honeybadger::Configuration.new }
281
-
282
- subject { config.trace_threshold = value; config.trace_threshold }
283
-
284
- context "value is above 1000" do
285
- let(:value) { 2000 }
286
-
287
- it { should eq 2000 }
288
- end
289
-
290
- context "value is below 1000" do
291
- let(:value) { 100 }
292
-
293
- it { should eq 1000 }
294
- end
295
- end
296
-
297
- def assert_config_default(option, default_value, config = nil)
298
- config ||= Honeybadger::Configuration.new
299
- expect(config.send(option)).to eq default_value
300
- end
301
-
302
- def assert_config_overridable(option, value = 'a value')
303
- config = Honeybadger::Configuration.new
304
- config.send(:"#{option}=", value)
305
- expect(config.send(option)).to eq value
306
- end
307
-
308
- def assert_appends_value(option, &block)
309
- config = Honeybadger::Configuration.new
310
- original_values = config.send(option).dup
311
- block ||= lambda do |c|
312
- new_value = 'hello'
313
- c.send(option) << new_value
314
- new_value
315
- end
316
- new_value = block.call(config)
317
- expect(original_values + [new_value]).to eq config.send(option)
318
- end
319
-
320
- def assert_replaces(option, setter)
321
- config = Honeybadger::Configuration.new
322
- new_value = 'hello'
323
- config.send(setter, [new_value])
324
- expect(config.send(option)).to eq [new_value]
325
- config.send(setter, new_value)
326
- expect(config.send(option)).to eq [new_value]
327
- end
328
- end
@@ -1,134 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Honeybadger::Dependency do
4
- let(:dependency) { Honeybadger::Dependency.new }
5
- subject { dependency }
6
-
7
- before { Honeybadger::Dependency.stub(:instances).and_return([]) }
8
-
9
- describe ".register" do
10
- it "returns a new dependency" do
11
- instance = double()
12
- Honeybadger::Dependency.stub(:new).and_return(instance)
13
- expect(Honeybadger::Dependency.register {}).to eq [instance]
14
- end
15
-
16
- it "registers a new dependency" do
17
- expect { Honeybadger::Dependency.register {} }.to change(described_class, :instances).from([]).to([kind_of(Honeybadger::Dependency)])
18
- end
19
- end
20
-
21
- describe ".inject!" do
22
- it "injects all satisfied instances" do
23
- Honeybadger::Dependency.instances.replace([mock_dependency, mock_dependency])
24
- Honeybadger::Dependency.inject!
25
- end
26
-
27
- it "skips all unsatisfied instances" do
28
- Honeybadger::Dependency.instances.replace([mock_dependency(false), mock_dependency(false)])
29
- Honeybadger::Dependency.inject!
30
- end
31
- end
32
-
33
- describe "#requirement" do
34
- let(:block) { Proc.new {} }
35
-
36
- it "returns and Array of requirements" do
37
- expect(subject.requirement(&block)).to eq [block]
38
- end
39
-
40
- it "registers a new requirement" do
41
- expect { subject.requirement(&block) }.to change(subject, :requirements).from([]).to([block])
42
- end
43
- end
44
-
45
- describe "#injection" do
46
- let(:block) { Proc.new {} }
47
-
48
- it "returns an Array of injections" do
49
- expect(subject.injection(&block)).to eq [block]
50
- end
51
-
52
- it "registers a new injection" do
53
- expect { subject.injection(&block) }.to change(subject, :injections).from([]).to([block])
54
- end
55
- end
56
-
57
- describe "#ok?" do
58
- subject { dependency.ok? }
59
-
60
- context "when not injected yet" do
61
- it { should be_true }
62
- end
63
-
64
- context "when already injected" do
65
- before { dependency.inject! }
66
-
67
- it { should be_false }
68
- end
69
-
70
- context "all requirements are met" do
71
- before do
72
- 3.times { dependency.requirement { true } }
73
- end
74
- end
75
-
76
- context "some requirements fail" do
77
- before do
78
- 3.times { dependency.requirement { true } }
79
- dependency.requirement { false }
80
- end
81
-
82
- it { should be_false }
83
- end
84
-
85
- context "some requirements error" do
86
- before do
87
- dependency.requirement { true }
88
- dependency.requirement { fail 'oops!' }
89
- end
90
-
91
- it { should be_false }
92
-
93
- it "logs the failure" do
94
- Honeybadger.should_receive(:write_verbose_log).with(/oops!/, :error).once
95
- dependency.ok?
96
- end
97
- end
98
- end
99
-
100
- describe "#inject!" do
101
- it "calls injections" do
102
- dependency.injections.replace([mock_injection, mock_injection])
103
- dependency.inject!
104
- end
105
-
106
- context "some injections fail" do
107
- before do
108
- failing_injection = Proc.new { fail 'oh noes!' }
109
- dependency.injections.replace([mock_injection, failing_injection, mock_injection(false)])
110
- end
111
-
112
- it "halts injection silently" do
113
- expect { dependency.inject! }.not_to raise_error
114
- end
115
-
116
- it "logs the failure" do
117
- Honeybadger.should_receive(:write_verbose_log).with(/oh noes!/, :error).once
118
- dependency.inject!
119
- end
120
-
121
- it "marks the dependency as injected" do
122
- expect { dependency.inject!}.to change(dependency, :injected?).from(false).to(true)
123
- end
124
- end
125
- end
126
-
127
- def mock_dependency(ok = true)
128
- double(:ok? => ok).tap { |d| d.send(ok ? :should_receive : :should_not_receive, :inject!) }
129
- end
130
-
131
- def mock_injection(positive = true)
132
- double().tap { |d| d.send(positive ? :should_receive : :should_not_receive, :call) }
133
- end
134
- end