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.
- checksums.yaml +4 -4
- data/LICENSE +19 -0
- data/README.md +37 -16
- data/bin/honeybadger +5 -0
- data/lib/honeybadger.rb +167 -191
- data/lib/honeybadger/agent.rb +136 -0
- data/lib/honeybadger/backend.rb +26 -0
- data/lib/honeybadger/backend/base.rb +66 -0
- data/lib/honeybadger/backend/debug.rb +12 -0
- data/lib/honeybadger/backend/null.rb +16 -0
- data/lib/honeybadger/backend/server.rb +51 -0
- data/lib/honeybadger/backend/test.rb +24 -0
- data/lib/honeybadger/backtrace.rb +29 -24
- data/lib/honeybadger/cli.rb +367 -0
- data/lib/honeybadger/config.rb +333 -0
- data/lib/honeybadger/config/callbacks.rb +70 -0
- data/lib/honeybadger/config/defaults.rb +175 -0
- data/lib/honeybadger/config/env.rb +40 -0
- data/lib/honeybadger/config/yaml.rb +43 -0
- data/lib/honeybadger/const.rb +28 -0
- data/lib/honeybadger/init/rails.rb +84 -0
- data/lib/honeybadger/init/sinatra.rb +27 -0
- data/lib/honeybadger/logging.rb +133 -0
- data/lib/honeybadger/notice.rb +243 -280
- data/lib/honeybadger/plugin.rb +110 -0
- data/lib/honeybadger/plugins/delayed_job.rb +22 -0
- data/lib/honeybadger/{integrations → plugins}/delayed_job/plugin.rb +6 -7
- data/lib/honeybadger/{integrations → plugins}/local_variables.rb +7 -8
- data/lib/honeybadger/{integrations → plugins}/net_http.rb +10 -8
- data/lib/honeybadger/plugins/passenger.rb +24 -0
- data/lib/honeybadger/plugins/rails.rb +61 -0
- data/lib/honeybadger/plugins/sidekiq.rb +35 -0
- data/lib/honeybadger/{integrations → plugins}/thor.rb +9 -8
- data/lib/honeybadger/{integrations → plugins}/unicorn.rb +10 -9
- data/lib/honeybadger/rack/error_notifier.rb +44 -27
- data/lib/honeybadger/rack/metrics_reporter.rb +41 -0
- data/lib/honeybadger/rack/request_hash.rb +50 -0
- data/lib/honeybadger/rack/user_feedback.rb +15 -10
- data/lib/honeybadger/rack/user_informer.rb +14 -3
- data/lib/honeybadger/trace.rb +185 -0
- data/lib/honeybadger/util/http.rb +79 -0
- data/lib/honeybadger/util/request_sanitizer.rb +35 -0
- data/lib/honeybadger/util/sanitizer.rb +71 -0
- data/lib/honeybadger/util/stats.rb +31 -0
- data/lib/honeybadger/version.rb +4 -0
- data/lib/honeybadger/worker.rb +224 -0
- data/lib/honeybadger/worker/batch.rb +50 -0
- data/lib/honeybadger/worker/metered_queue.rb +80 -0
- data/lib/honeybadger/worker/metrics_collection.rb +61 -0
- data/lib/honeybadger/worker/metrics_collector.rb +96 -0
- data/{lib/honeybadger/capistrano.rb → vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb} +1 -3
- data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +76 -0
- data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -0
- data/{lib → vendor/capistrano-honeybadger/lib}/honeybadger/capistrano/legacy.rb +16 -15
- data/vendor/thor/lib/thor.rb +484 -0
- data/vendor/thor/lib/thor/actions.rb +319 -0
- data/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
- data/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
- data/vendor/thor/lib/thor/base.rb +656 -0
- data/vendor/thor/lib/thor/command.rb +133 -0
- data/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
- data/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
- data/vendor/thor/lib/thor/error.rb +32 -0
- data/vendor/thor/lib/thor/group.rb +281 -0
- data/vendor/thor/lib/thor/invocation.rb +178 -0
- data/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
- data/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/vendor/thor/lib/thor/parser.rb +4 -0
- data/vendor/thor/lib/thor/parser/argument.rb +73 -0
- data/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/vendor/thor/lib/thor/parser/option.rb +125 -0
- data/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/vendor/thor/lib/thor/runner.rb +322 -0
- data/vendor/thor/lib/thor/shell.rb +81 -0
- data/vendor/thor/lib/thor/shell/basic.rb +421 -0
- data/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/vendor/thor/lib/thor/util.rb +267 -0
- data/vendor/thor/lib/thor/version.rb +3 -0
- metadata +97 -305
- data/Appraisals +0 -95
- data/CHANGELOG.md +0 -422
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -136
- data/Guardfile +0 -5
- data/MIT-LICENSE +0 -32
- data/Rakefile +0 -159
- data/features/metal.feature +0 -20
- data/features/rack.feature +0 -55
- data/features/rails.feature +0 -343
- data/features/rails3.x.feature +0 -26
- data/features/rake.feature +0 -25
- data/features/sinatra.feature +0 -27
- data/features/standalone.feature +0 -73
- data/features/step_definitions/metal_steps.rb +0 -24
- data/features/step_definitions/rack_steps.rb +0 -18
- data/features/step_definitions/rails_steps.rb +0 -270
- data/features/step_definitions/rake_steps.rb +0 -17
- data/features/step_definitions/standalone_steps.rb +0 -12
- data/features/step_definitions/thor_steps.rb +0 -4
- data/features/support/env.rb +0 -22
- data/features/support/honeybadger_failure_shim.rb.template +0 -5
- data/features/support/honeybadger_shim.rb.template +0 -6
- data/features/support/rails.rb +0 -202
- data/features/support/rake/Rakefile +0 -68
- data/features/support/test.thor +0 -22
- data/features/thor.feature +0 -5
- data/gemfiles/binding_of_caller.gemfile +0 -13
- data/gemfiles/delayed_job.gemfile +0 -13
- data/gemfiles/rack.gemfile +0 -13
- data/gemfiles/rails.gemfile +0 -16
- data/gemfiles/rails2.3.gemfile +0 -15
- data/gemfiles/rails3.0.gemfile +0 -16
- data/gemfiles/rails3.1.gemfile +0 -16
- data/gemfiles/rails3.2.gemfile +0 -16
- data/gemfiles/rails4.0.gemfile +0 -16
- data/gemfiles/rails4.1.gemfile +0 -16
- data/gemfiles/rake.gemfile +0 -13
- data/gemfiles/sinatra.gemfile +0 -13
- data/gemfiles/standalone.gemfile +0 -12
- data/gemfiles/thor.gemfile +0 -13
- data/generators/honeybadger/honeybadger_generator.rb +0 -95
- data/generators/honeybadger/lib/insert_commands.rb +0 -34
- data/generators/honeybadger/lib/rake_commands.rb +0 -24
- data/generators/honeybadger/templates/capistrano_hook.rb +0 -6
- data/generators/honeybadger/templates/honeybadger_tasks.rake +0 -25
- data/generators/honeybadger/templates/initializer.rb +0 -6
- data/honeybadger.gemspec +0 -174
- data/lib/honeybadger/array.rb +0 -53
- data/lib/honeybadger/capistrano/tasks.rake +0 -73
- data/lib/honeybadger/configuration.rb +0 -397
- data/lib/honeybadger/dependency.rb +0 -65
- data/lib/honeybadger/integrations.rb +0 -9
- data/lib/honeybadger/integrations/delayed_job.rb +0 -20
- data/lib/honeybadger/integrations/passenger.rb +0 -18
- data/lib/honeybadger/integrations/sidekiq.rb +0 -37
- data/lib/honeybadger/monitor.rb +0 -17
- data/lib/honeybadger/monitor/railtie.rb +0 -53
- data/lib/honeybadger/monitor/sender.rb +0 -44
- data/lib/honeybadger/monitor/trace.rb +0 -187
- data/lib/honeybadger/monitor/worker.rb +0 -169
- data/lib/honeybadger/payload.rb +0 -101
- data/lib/honeybadger/rack.rb +0 -12
- data/lib/honeybadger/rails.rb +0 -45
- data/lib/honeybadger/rails/action_controller_catcher.rb +0 -30
- data/lib/honeybadger/rails/controller_methods.rb +0 -78
- data/lib/honeybadger/rails/middleware/exceptions_catcher.rb +0 -29
- data/lib/honeybadger/rails3_tasks.rb +0 -94
- data/lib/honeybadger/railtie.rb +0 -52
- data/lib/honeybadger/rake_handler.rb +0 -66
- data/lib/honeybadger/sender.rb +0 -185
- data/lib/honeybadger/shared_tasks.rb +0 -56
- data/lib/honeybadger/stats.rb +0 -29
- data/lib/honeybadger/tasks.rb +0 -95
- data/lib/honeybadger/user_feedback.rb +0 -8
- data/lib/honeybadger/user_informer.rb +0 -8
- data/lib/honeybadger_tasks.rb +0 -69
- data/lib/rails/generators/honeybadger/honeybadger_generator.rb +0 -99
- data/rails/init.rb +0 -1
- data/resources/README.md +0 -34
- data/script/integration_test.rb +0 -38
- data/spec/allocation_stats.rb +0 -32
- data/spec/honeybadger/backtrace_spec.rb +0 -242
- data/spec/honeybadger/capistrano_spec.rb +0 -36
- data/spec/honeybadger/configuration_spec.rb +0 -328
- data/spec/honeybadger/dependency_spec.rb +0 -134
- data/spec/honeybadger/integrations/delayed_job_spec.rb +0 -82
- data/spec/honeybadger/integrations/local_variables_spec.rb +0 -60
- data/spec/honeybadger/integrations/net_http_spec.rb +0 -29
- data/spec/honeybadger/integrations/passenger_spec.rb +0 -29
- data/spec/honeybadger/integrations/sidekiq_spec.rb +0 -60
- data/spec/honeybadger/integrations/thor_spec.rb +0 -32
- data/spec/honeybadger/integrations/unicorn_spec.rb +0 -40
- data/spec/honeybadger/logger_spec.rb +0 -79
- data/spec/honeybadger/monitor/trace_spec.rb +0 -65
- data/spec/honeybadger/monitor/worker_spec.rb +0 -274
- data/spec/honeybadger/notice_spec.rb +0 -669
- data/spec/honeybadger/notifier_spec.rb +0 -328
- data/spec/honeybadger/payload_spec.rb +0 -162
- data/spec/honeybadger/rack_spec.rb +0 -85
- data/spec/honeybadger/rails/action_controller_spec.rb +0 -328
- data/spec/honeybadger/rails_spec.rb +0 -37
- data/spec/honeybadger/sender_spec.rb +0 -317
- data/spec/honeybadger/stats_spec.rb +0 -57
- data/spec/honeybadger/user_feedback_spec.rb +0 -80
- data/spec/honeybadger/user_informer_spec.rb +0 -30
- data/spec/honeybadger_tasks_spec.rb +0 -171
- data/spec/spec_helper.rb +0 -24
- data/spec/support/array_including.rb +0 -31
- data/spec/support/backtraced_exception.rb +0 -9
- data/spec/support/collected_sender.rb +0 -12
- data/spec/support/defines_constants.rb +0 -18
- data/spec/support/helpers.rb +0 -101
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'sham_rack'
|
3
|
-
|
4
|
-
describe Honeybadger::Rack::UserInformer do
|
5
|
-
it 'modifies output if there is a honeybadger id' do
|
6
|
-
main_app = lambda do |env|
|
7
|
-
env['honeybadger.error_id'] = 1
|
8
|
-
[200, {}, ["<!-- HONEYBADGER ERROR -->"]]
|
9
|
-
end
|
10
|
-
informer_app = Honeybadger::Rack::UserInformer.new(main_app)
|
11
|
-
|
12
|
-
ShamRack.mount(informer_app, "example.com")
|
13
|
-
|
14
|
-
response = Net::HTTP.get_response(URI.parse("http://example.com/"))
|
15
|
-
expect(response.body).to eq 'Honeybadger Error 1'
|
16
|
-
expect(response["Content-Length"].to_i).to eq 19
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'does not modify output if there is no honeybadger id' do
|
20
|
-
main_app = lambda do |env|
|
21
|
-
[200, {}, ["<!-- HONEYBADGER ERROR -->"]]
|
22
|
-
end
|
23
|
-
informer_app = Honeybadger::Rack::UserInformer.new(main_app)
|
24
|
-
|
25
|
-
ShamRack.mount(informer_app, "example.com")
|
26
|
-
|
27
|
-
response = Net::HTTP.get_response(URI.parse("http://example.com/"))
|
28
|
-
expect(response.body).to eq '<!-- HONEYBADGER ERROR -->'
|
29
|
-
end
|
30
|
-
end
|
@@ -1,171 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
require File.expand_path('../../lib/honeybadger_tasks', __FILE__)
|
5
|
-
|
6
|
-
describe HoneybadgerTasks do
|
7
|
-
def successful_response(body = "")
|
8
|
-
response = Net::HTTPSuccess.new('1.2', '200', 'OK')
|
9
|
-
response.stub(:body).and_return(body)
|
10
|
-
response
|
11
|
-
end
|
12
|
-
|
13
|
-
def unsuccessful_response(body = "")
|
14
|
-
response = Net::HTTPClientError.new('1.2', '200', 'OK')
|
15
|
-
response.stub(:body).and_return(body)
|
16
|
-
response
|
17
|
-
end
|
18
|
-
|
19
|
-
context "being quiet" do
|
20
|
-
before do
|
21
|
-
HoneybadgerTasks.stub(:puts)
|
22
|
-
$stderr.stub(:puts)
|
23
|
-
end
|
24
|
-
|
25
|
-
context "in a configured project" do
|
26
|
-
before(:each) { Honeybadger.configure { |config| config.api_key = "1234123412341234" } }
|
27
|
-
|
28
|
-
context "on deploy({})" do
|
29
|
-
it "complains about missing rails env" do
|
30
|
-
$stderr.should_receive(:puts).with(/which environment/i)
|
31
|
-
HoneybadgerTasks.deploy({})
|
32
|
-
end
|
33
|
-
|
34
|
-
it "return false" do
|
35
|
-
expect(HoneybadgerTasks.deploy({})).to be_false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "given an optional HTTP proxy and valid options" do
|
40
|
-
before(:each) do
|
41
|
-
@response = double("response", :body => "stub body")
|
42
|
-
@http_proxy = double("proxy", :request => @response,
|
43
|
-
:use_ssl= => nil,
|
44
|
-
:ca_file= => nil,
|
45
|
-
:verify_mode= => nil)
|
46
|
-
@http_proxy_class = double("proxy_class", :new => @http_proxy)
|
47
|
-
@post = double("post", :set_form_data => nil)
|
48
|
-
|
49
|
-
@post.stub(:[]=).with('X-API-Key', '1234123412341234').and_return(true)
|
50
|
-
|
51
|
-
Net::HTTP.should_receive(:Proxy).
|
52
|
-
with(Honeybadger.configuration.proxy_host,
|
53
|
-
Honeybadger.configuration.proxy_port,
|
54
|
-
Honeybadger.configuration.proxy_user,
|
55
|
-
Honeybadger.configuration.proxy_pass).
|
56
|
-
and_return(@http_proxy_class)
|
57
|
-
Net::HTTP::Post.should_receive(:new).with("/v1/deploys").and_return(@post)
|
58
|
-
|
59
|
-
@options = { :environment => "staging", :dry_run => false }
|
60
|
-
end
|
61
|
-
|
62
|
-
context "performing a dry run" do
|
63
|
-
before(:each) { @output = HoneybadgerTasks.deploy(@options.merge(:dry_run => true)) }
|
64
|
-
|
65
|
-
it "return true without performing any actual request" do
|
66
|
-
@http_proxy.should_receive(:request).never
|
67
|
-
@output.should be_true
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "on deploy(options)" do
|
72
|
-
it "posts to https://api.honeybadger.io:443/v1/deploys" do
|
73
|
-
@http_proxy_class.should_receive(:new).with("api.honeybadger.io", 443).and_return(@http_proxy)
|
74
|
-
@post.should_receive(:set_form_data).with(kind_of(Hash))
|
75
|
-
@http_proxy.should_receive(:request).with(anything).and_return(successful_response)
|
76
|
-
HoneybadgerTasks.deploy(@options)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "uses send the environment param" do
|
80
|
-
@post.should_receive(:set_form_data).
|
81
|
-
with(hash_including("deploy[environment]" => "staging"))
|
82
|
-
HoneybadgerTasks.deploy(@options)
|
83
|
-
end
|
84
|
-
|
85
|
-
[:local_username, :repository, :revision].each do |key|
|
86
|
-
it "uses send the #{key} param if it's passed in." do
|
87
|
-
@options[key] = "value"
|
88
|
-
@post.should_receive(:set_form_data).
|
89
|
-
with(hash_including("deploy[#{key}]" => "value"))
|
90
|
-
HoneybadgerTasks.deploy(@options)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
it "puts the response body on success" do
|
95
|
-
HoneybadgerTasks.should_receive(:puts).with("Successfully recorded deployment")
|
96
|
-
@http_proxy.should_receive(:request).with(anything).and_return(successful_response('body'))
|
97
|
-
HoneybadgerTasks.deploy(@options)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "puts the response body on failure" do
|
101
|
-
$stderr.should_receive(:puts).with(/body/)
|
102
|
-
@http_proxy.should_receive(:request).with(anything).and_return(unsuccessful_response('body'))
|
103
|
-
HoneybadgerTasks.deploy(@options)
|
104
|
-
end
|
105
|
-
|
106
|
-
it "puts the response class on failure" do
|
107
|
-
$stderr.should_receive(:puts).with(/Net::HTTPClientError/)
|
108
|
-
@http_proxy.should_receive(:request).with(anything).and_return(unsuccessful_response)
|
109
|
-
HoneybadgerTasks.deploy(@options)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns false on failure" do
|
113
|
-
@http_proxy.should_receive(:request).with(anything).and_return(unsuccessful_response('body'))
|
114
|
-
output = HoneybadgerTasks.deploy(@options)
|
115
|
-
expect(output).to be_false
|
116
|
-
end
|
117
|
-
|
118
|
-
it "return true on success" do
|
119
|
-
@http_proxy.should_receive(:request).with(anything).and_return(successful_response('body'))
|
120
|
-
output = HoneybadgerTasks.deploy(@options)
|
121
|
-
expect(output).to be_true
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
context "in a configured project with custom host" do
|
128
|
-
before(:each) do
|
129
|
-
Honeybadger.configure do |config|
|
130
|
-
config.api_key = "1234123412341234"
|
131
|
-
config.host = "custom.host"
|
132
|
-
config.secure = false
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
context "on deploy(:environment => 'staging')" do
|
137
|
-
it "posts to the custom host" do
|
138
|
-
@post = double("post", :set_form_data => nil)
|
139
|
-
@http_proxy = double("proxy", :request => @response)
|
140
|
-
|
141
|
-
@post.stub(:[]=).with('X-API-Key', '1234123412341234').and_return(true)
|
142
|
-
|
143
|
-
@http_proxy_class = double("proxy_class", :new => @http_proxy)
|
144
|
-
@http_proxy_class.should_receive(:new).with("custom.host", 80).and_return(@http_proxy)
|
145
|
-
Net::HTTP.should_receive(:Proxy).with(any_args).and_return(@http_proxy_class)
|
146
|
-
Net::HTTP::Post.should_receive(:new).with("/v1/deploys").and_return(@post)
|
147
|
-
@post.should_receive(:set_form_data).with(kind_of(Hash))
|
148
|
-
@http_proxy.should_receive(:request).with(any_args).and_return(successful_response)
|
149
|
-
|
150
|
-
HoneybadgerTasks.deploy(:environment => "staging")
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "when not configured" do
|
156
|
-
before(:each) { Honeybadger.configure { |config| config.api_key = "" } }
|
157
|
-
|
158
|
-
context "on deploy(:environment => 'staging')" do
|
159
|
-
it "complains about missing api key" do
|
160
|
-
$stderr.should_receive(:puts).with(/api key/i)
|
161
|
-
HoneybadgerTasks.deploy(:environment => "staging")
|
162
|
-
end
|
163
|
-
|
164
|
-
it "return false" do
|
165
|
-
@output = HoneybadgerTasks.deploy(:environment => "staging")
|
166
|
-
@output.should be_false
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'honeybadger'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'binding_of_caller'
|
6
|
-
rescue LoadError
|
7
|
-
nil
|
8
|
-
end
|
9
|
-
|
10
|
-
# Require files in spec/support/ and its subdirectories.
|
11
|
-
Dir[File.expand_path('../../spec/support/**/*.rb', __FILE__)].each {|f| require f}
|
12
|
-
|
13
|
-
RSpec.configure do |c|
|
14
|
-
c.mock_with :rspec
|
15
|
-
c.color_enabled = true
|
16
|
-
c.tty = true
|
17
|
-
|
18
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
19
|
-
c.filter_run :focus => true
|
20
|
-
c.run_all_when_everything_filtered = true
|
21
|
-
|
22
|
-
c.include Helpers
|
23
|
-
c.after(:each) { Honeybadger.context.clear! }
|
24
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Mocks
|
3
|
-
module ArgumentMatchers
|
4
|
-
class ArrayIncludingMatcher
|
5
|
-
def initialize(expected)
|
6
|
-
@expected = expected
|
7
|
-
end
|
8
|
-
|
9
|
-
def ==(actual)
|
10
|
-
@expected.all? do |value|
|
11
|
-
if Regexp === value
|
12
|
-
actual.any? {|v| value =~ v }
|
13
|
-
else
|
14
|
-
actual.include?(value)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
rescue NoMethodError
|
18
|
-
false
|
19
|
-
end
|
20
|
-
|
21
|
-
def description
|
22
|
-
"array_including(#{@expected.inspect})"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def array_including(*args)
|
27
|
-
ArrayIncludingMatcher.new(args.flatten)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module DefinesConstants
|
2
|
-
def self.included(base)
|
3
|
-
base.before(:each) do
|
4
|
-
@defined_constants = []
|
5
|
-
end
|
6
|
-
|
7
|
-
base.after(:each) do
|
8
|
-
@defined_constants.each do |constant|
|
9
|
-
Object.__send__(:remove_const, constant)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def define_constant(name, value)
|
15
|
-
Object.const_set(name, value)
|
16
|
-
@defined_constants << name
|
17
|
-
end
|
18
|
-
end
|
data/spec/support/helpers.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
module Helpers
|
2
|
-
def assert_no_difference(expression, message = nil, &block)
|
3
|
-
assert_difference expression, 0, message, &block
|
4
|
-
end
|
5
|
-
|
6
|
-
def stub_sender
|
7
|
-
double('sender', :send_to_honeybadger => nil)
|
8
|
-
end
|
9
|
-
|
10
|
-
def stub_sender!
|
11
|
-
Honeybadger.sender = stub_sender
|
12
|
-
end
|
13
|
-
|
14
|
-
def stub_notice
|
15
|
-
Honeybadger::Notice.new({}).tap do |notice|
|
16
|
-
notice.stub(:ignored? => false, :to_json => '{"foo":"bar"}')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def stub_notice!
|
21
|
-
stub_notice.tap do |notice|
|
22
|
-
Honeybadger::Notice.stub(:new => notice)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def stub_http(options = {})
|
27
|
-
response = options[:response] || Net::HTTPSuccess.new('1.2', '200', 'OK')
|
28
|
-
response.stub(:body => options[:body] || '{"id":"1234"}')
|
29
|
-
http = double(:post => response,
|
30
|
-
:read_timeout= => nil,
|
31
|
-
:open_timeout= => nil,
|
32
|
-
:ca_file= => nil,
|
33
|
-
:verify_mode= => nil,
|
34
|
-
:use_ssl= => nil)
|
35
|
-
Net::HTTP.stub(:new).and_return(http)
|
36
|
-
http
|
37
|
-
end
|
38
|
-
|
39
|
-
def reset_config
|
40
|
-
Honeybadger.configuration = nil
|
41
|
-
Honeybadger.configure do |config|
|
42
|
-
config.api_key = 'abc123'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def build_notice_data(exception = nil)
|
47
|
-
exception ||= build_exception
|
48
|
-
{
|
49
|
-
:api_key => nil,
|
50
|
-
:error_class => exception.class.name,
|
51
|
-
:error_message => "#{exception.class.name}: #{exception.message}",
|
52
|
-
:backtrace => exception.backtrace,
|
53
|
-
:environment => { 'PATH' => '/bin', 'REQUEST_URI' => '/users/1' },
|
54
|
-
:request => {
|
55
|
-
:params => { 'controller' => 'users', 'action' => 'show', 'id' => '1' },
|
56
|
-
:rails_root => '/path/to/application',
|
57
|
-
:url => "http://test.host/users/1"
|
58
|
-
},
|
59
|
-
:session => {
|
60
|
-
:key => '123abc',
|
61
|
-
:data => { 'user_id' => '5', 'flash' => { 'notice' => 'Logged in successfully' } }
|
62
|
-
}
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
def build_exception(opts = {})
|
67
|
-
backtrace = ["test/honeybadger/rack_test.rb:15:in `build_exception'",
|
68
|
-
"test/honeybadger/rack_test.rb:52:in `test_delivers_exception_from_rack'",
|
69
|
-
"/Users/josh/Developer/.rvm/gems/ruby-1.9.3-p0/gems/mocha-0.10.5/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'"]
|
70
|
-
opts = { :backtrace => backtrace }.merge(opts)
|
71
|
-
BacktracedException.new(opts)
|
72
|
-
end
|
73
|
-
|
74
|
-
def assert_array_starts_with(expected, actual)
|
75
|
-
expect(actual).to respond_to :to_ary
|
76
|
-
array = actual.to_ary.reverse
|
77
|
-
expected.reverse.each_with_index do |value, i|
|
78
|
-
expect(array[i]).to eq value
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def assert_logged(expected)
|
83
|
-
assert_received(Honeybadger, :write_verbose_log) do |expect|
|
84
|
-
expect.with {|actual, level| actual =~ expected }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def assert_not_logged(expected)
|
89
|
-
assert_received(Honeybadger, :write_verbose_log) do |expect|
|
90
|
-
expect.with {|actual, level| actual =~ expected }.never
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def assert_caught_and_sent
|
95
|
-
expect(Honeybadger.sender.collected).not_to be_empty
|
96
|
-
end
|
97
|
-
|
98
|
-
def assert_caught_and_not_sent
|
99
|
-
expect(Honeybadger.sender.collected).to be_empty
|
100
|
-
end
|
101
|
-
end
|