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,26 +0,0 @@
1
- Feature: Install the Gem in a Rails 3.x application
2
-
3
- Background:
4
- Given I generate a new Rails application
5
- And I configure the Honeybadger shim
6
-
7
- Scenario: Rails is missing `config.secret_token`
8
- When I configure my application to require Honeybadger
9
- And I configure Honeybadger with:
10
- """
11
- config.api_key = "myapikey"
12
- config.logger = Logger.new(STDOUT)
13
- config.debug = true
14
- """
15
- And I define a response for "TestController#index":
16
- """
17
- session["secret"] = "blue42"
18
- render :nothing => true
19
- """
20
- And I route "/test/index" to "test#index"
21
- And I successfully run `rm config/initializers/secret_token.rb`
22
- And I perform a request to "http://example.com:123/test/index"
23
- Then I should receive a Honeybadger notification
24
- And the request should not contain "blue42"
25
- And the request session should contain "config.secret_token"
26
-
@@ -1,25 +0,0 @@
1
- Feature: Use the Gem to catch errors in a Rake application
2
-
3
- Scenario: Catching exceptions in Rake
4
- When I run rake with honeybadger
5
- Then Honeybadger should catch the exception
6
-
7
- Scenario: Falling back to default handler before Honeybadger is configured
8
- When I run rake with honeybadger not yet configured
9
- Then Honeybadger should not catch the exception
10
-
11
- Scenario: Disabling Rake exception catcher
12
- When I run rake with honeybadger disabled
13
- Then Honeybadger should not catch the exception
14
-
15
- Scenario: Autodetect, running from terminal
16
- When I run rake with honeybadger autodetect from terminal
17
- Then Honeybadger should not catch the exception
18
-
19
- Scenario: Autodetect, not running from terminal
20
- When I run rake with honeybadger autodetect not from terminal
21
- Then Honeybadger should catch the exception
22
-
23
- Scenario: Sending the correct component name
24
- When I run rake with honeybadger
25
- Then Honeybadger should send the rake command line as the component name
@@ -1,27 +0,0 @@
1
- Feature: Use the notifier in a Sinatra app
2
-
3
- Scenario: Rescue an exception in a Sinatra app
4
- Given the following Rack app:
5
- """
6
- require 'sinatra/base'
7
- require 'honeybadger'
8
-
9
- Honeybadger.configure do |config|
10
- config.api_key = 'my_api_key'
11
- config.logger = Logger.new(STDOUT)
12
- end
13
-
14
- class FontaneApp < Sinatra::Base
15
- use Honeybadger::Rack
16
- enable :raise_errors
17
-
18
- get "/test/index" do
19
- raise "Sinatra has left the building"
20
- end
21
- end
22
-
23
- app = FontaneApp
24
- """
25
- When I perform a Rack request to "http://example.com:123/test/index?param=value"
26
- Then I should receive a Honeybadger notification
27
-
@@ -1,73 +0,0 @@
1
- Feature: Use the notifier in a plain Ruby app
2
- Scenario: Rescue and exception in a Rack app
3
- Given the following Ruby app:
4
- """
5
- require 'honeybadger'
6
-
7
- Honeybadger.configure do |config|
8
- config.api_key = 'my_api_key'
9
- config.logger = Logger.new STDOUT
10
- end
11
-
12
- begin
13
- fail 'oops!'
14
- rescue => e
15
- Honeybadger.notify(e)
16
- end
17
- """
18
- When I execute the file
19
- Then I should receive a Honeybadger notification
20
-
21
- Scenario: Dependency injection
22
- Given the following Ruby app:
23
- """
24
- require 'honeybadger/dependency'
25
-
26
- Honeybadger::Dependency.register do
27
- injection { puts 'injected' }
28
- end
29
-
30
- require 'honeybadger'
31
-
32
- Honeybadger.configure do |config|
33
- config.api_key = 'my_api_key'
34
- config.logger = Logger.new STDOUT
35
- end
36
-
37
- begin
38
- fail 'oops!'
39
- rescue => e
40
- Honeybadger.notify(e)
41
- end
42
- """
43
- When I execute the file
44
- Then the output should contain "injected"
45
- And I should receive a Honeybadger notification
46
-
47
- # TODO: also test 'Then the output should contain "injection failure"' after default
48
- # logging is added.
49
- Scenario: Dependency injection exception
50
- Given the following Ruby app:
51
- """
52
- require 'honeybadger/dependency'
53
-
54
- Honeybadger::Dependency.register do
55
- injection { fail 'injection failure' }
56
- end
57
-
58
- require 'honeybadger'
59
-
60
- Honeybadger.configure do |config|
61
- config.api_key = 'my_api_key'
62
- config.logger = Logger.new STDOUT
63
- end
64
-
65
- begin
66
- fail 'oops!'
67
- rescue => e
68
- Honeybadger.notify(e)
69
- end
70
- """
71
- When I execute the file
72
- Then the output should not contain "injected"
73
- And I should receive a Honeybadger notification
@@ -1,24 +0,0 @@
1
- When /^I define a Metal endpoint called "([^\"]*)":$/ do |class_name, definition|
2
- FileUtils.mkdir_p(File.join(rails_root, 'app', 'metal'))
3
- file_name = File.join(rails_root, 'app', 'metal', "#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}.rb")
4
- File.open(file_name, "w") do |file|
5
- file.puts "class #{class_name}"
6
- file.puts definition
7
- file.puts "end"
8
- end
9
- step %(the metal endpoint "#{class_name}" is mounted in the Rails 3 routes.rb) unless rails2?
10
- end
11
-
12
- When /^the metal endpoint "([^\"]*)" is mounted in the Rails 3 routes.rb$/ do |class_name|
13
- routesrb = File.join(rails_root, "config", "routes.rb")
14
- routes = IO.readlines(routesrb)
15
- rack_route = "get '/metal(/*other)' => #{class_name}"
16
- routes = routes[0..-2] + [rack_route, routes[-1]]
17
- File.open(routesrb, "w") do |f|
18
- f.puts "$:<< '#{LOCAL_RAILS_ROOT}'"
19
- f.puts "require 'app/metal/#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}'"
20
- routes.each do |route_line|
21
- f.puts route_line
22
- end
23
- end
24
- end
@@ -1,18 +0,0 @@
1
- Given /^the following Rack app:$/ do |definition|
2
- File.open(RACK_FILE, 'w') { |file| file.write(definition) }
3
- end
4
-
5
- When /^I perform a Rack request to "([^\"]*)"$/ do |url|
6
- request_file = File.join(TEMP_DIR, 'rack_request.rb')
7
- File.open(request_file, 'w') do |file|
8
- file.puts "require 'rubygems'"
9
- file.puts IO.read(SHIM_FILE)
10
- file.puts IO.read(RACK_FILE)
11
- file.puts "env = Rack::MockRequest.env_for(#{url.inspect})"
12
- file.puts "status, headers, body = app.call(env)"
13
- file.puts %{puts "HTTP \#{status}"}
14
- file.puts %{headers.each { |key, value| puts "\#{key}: \#{value}"}}
15
- file.puts "body.each { |part| print part }"
16
- end
17
- step %(I run `ruby #{request_file}`)
18
- end
@@ -1,270 +0,0 @@
1
- require 'uri'
2
-
3
- When /^I generate a new Rails application$/ do
4
- rails_create_command = rails2? ? 'rails rails_root' :
5
- 'rails new rails_root -O -S -G -J -T --skip-gemfile --skip-bundle'
6
-
7
- step %(I successfully run `bundle exec #{rails_create_command}`)
8
- step %(I cd to "rails_root")
9
-
10
- require_thread
11
-
12
- monkeypatch_old_version if rails_version == "2.3.14"
13
-
14
- if rails2?
15
- config_gem_dependencies
16
- disable_activerecord
17
- end
18
- end
19
-
20
- When /^I configure the Honeybadger (failure )?shim$/ do |failure|
21
- shim_file = File.join(PROJECT_ROOT, 'features', 'support', "honeybadger#{failure ? '_failure' : nil}_shim.rb.template")
22
- if rails_supports_initializers?
23
- target = File.join(rails_root, 'config', 'initializers', 'honeybadger_shim.rb')
24
- FileUtils.cp(shim_file, target)
25
- else
26
- File.open(environment_path, 'a') do |file|
27
- file.puts
28
- file.write IO.read(shim_file)
29
- end
30
- end
31
- end
32
-
33
- When /^I configure my application to require Honeybadger$/ do
34
- if rails_uses_bundler?
35
- # Do nothing - bundler's on it
36
- elsif rails_manages_gems?
37
- config_gem('honeybadger')
38
- else
39
- File.open(environment_path, 'a') do |file|
40
- file.puts
41
- file.puts("require 'honeybadger'")
42
- file.puts("require 'honeybadger/rails'")
43
- end
44
-
45
- unless rails_finds_generators_in_gems?
46
- FileUtils.cp_r(File.join(PROJECT_ROOT, 'generators'), File.join(rails_root, 'lib'))
47
- end
48
- end
49
- end
50
-
51
- When /^I configure Honeybadger with:$/ do |config|
52
- requires = if rails_uses_bundler? || rails_manages_gems?
53
- ''
54
- else
55
- %(require 'honeybadger')
56
- end
57
-
58
- initializer_code = <<-EOF
59
- #{requires}
60
- Honeybadger.configure do |config|
61
- #{config}
62
- end
63
- EOF
64
-
65
- if rails_supports_initializers?
66
- File.open(rails_initializer_file, 'w') { |file| file.write(initializer_code) }
67
- else
68
- File.open(environment_path, 'a') do |file|
69
- file.puts
70
- file.puts initializer_code
71
- end
72
- end
73
- end
74
-
75
- When /^I run the honeybadger generator with "([^\"]*)"$/ do |generator_args|
76
- if rails2?
77
- step %(I successfully run `./script/generate honeybadger #{generator_args}`)
78
- else
79
- step %(I successfully run `rails generate honeybadger #{generator_args}`)
80
- end
81
- end
82
-
83
- Then /^I should receive (.+) Honeybadger notifications?$/ do |number|
84
- number = case number
85
- when /^(one|a)$/ then 1
86
- when 'two' then 2
87
- else number end
88
-
89
- all_output.scan(/\[Honeybadger\] Success: Net::HTTPOK/).size.should == number
90
- step %(the output should contain "123456789")
91
- end
92
-
93
- Then /^the request\s?(url|component|action|params|session|cgi_data|context)? should( not)? contain "([^\"]*)"$/ do |key, negate, expected|
94
- notice = all_output.match(/Notice: (\{.+\})/) ? JSON.parse(Regexp.last_match(1)) : {}
95
- hash = key ? notice['request'][key.strip] : notice['request']
96
- hash.to_s.send(negate ? :should_not : :should, match(/#{Regexp.escape(expected)}/))
97
- end
98
-
99
- Then /^I should see the Rails version$/ do
100
- step %(the output should contain "[Rails: #{rails_version}]")
101
- end
102
-
103
- When /^I define a( metal)? response for "([^\"]*)":$/ do |metal, controller_and_action, definition|
104
- controller_class_name, action = controller_and_action.split('#')
105
- controller_name = controller_class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase
106
- controller_file_name = File.join(rails_root, 'app', 'controllers', "#{controller_name}.rb")
107
- File.open(controller_file_name, "w") do |file|
108
- file.puts "class #{controller_class_name} < #{ (metal && !rails2?) ? 'ActionController::Metal' : 'ApplicationController'}"
109
- file.puts "def consider_all_requests_local; false; end"
110
- file.puts "def local_request?; false; end"
111
- file.puts "def #{action}"
112
- file.puts definition
113
- file.puts "end"
114
- file.puts "end"
115
- end
116
- end
117
-
118
- When /^I perform a request to "([^\"]*)"$/ do |uri|
119
- perform_request(uri)
120
- end
121
-
122
- When /^I configure the user informer/ do
123
- error_page = File.join(rails_root, 'public', '500.html')
124
- File.open(error_page, "r+") do |file|
125
- content = file.read
126
- content.gsub!('</body>', '<!-- HONEYBADGER ERROR --></body>')
127
- file.rewind
128
- file.write(content)
129
- end
130
- end
131
-
132
- When /^I configure the user feedback form/ do
133
- error_page = File.join(rails_root, 'public', '500.html')
134
- File.open(error_page, "r+") do |file|
135
- content = file.read
136
- content.gsub!('</body>', '<!-- HONEYBADGER FEEDBACK --></body>')
137
- file.rewind
138
- file.write(content)
139
- end
140
- end
141
-
142
- When /^I route "([^\"]*)" to "([^\"]*)"$/ do |path, controller_action_pair|
143
- route = if rails2?
144
- controller, action = controller_action_pair.split('#')
145
- %(map.connect "#{path}", :controller => "#{controller}", :action => "#{action}")
146
- else
147
- %(get "#{path}" => "#{controller_action_pair}")
148
- end
149
- routes_file = File.join(rails_root, "config", "routes.rb")
150
- File.open(routes_file, "r+") do |file|
151
- content = file.read
152
- content.gsub!(/^end$/, " #{route}\nend")
153
- file.rewind
154
- file.write(content)
155
- end
156
- end
157
-
158
- When /^I configure the Heroku gem shim with "([^\"]*)"( and multiple app support)?$/ do |api_key, multi_app|
159
- heroku_script_bin = File.join(TEMP_DIR, "bin")
160
- FileUtils.mkdir_p(heroku_script_bin)
161
- heroku_script = File.join(heroku_script_bin, "heroku")
162
- single_app_script = <<-SINGLE
163
- #!/bin/bash
164
- if [[ $1 == 'config:get' && $2 == 'HONEYBADGER_API_KEY' ]]
165
- then
166
- echo "#{api_key}"
167
- fi
168
- SINGLE
169
-
170
- multi_app_script = <<-MULTI
171
- #!/bin/bash
172
- if [[ $1 == 'config:get' && $2 == 'HONEYBADGER_API_KEY' && $3 == '--app' ]]
173
- then
174
- echo "#{api_key}"
175
- fi
176
- MULTI
177
-
178
- File.open(heroku_script, "w") do |f|
179
- if multi_app
180
- f.puts multi_app_script
181
- else
182
- f.puts single_app_script
183
- end
184
- end
185
- FileUtils.chmod(0755, heroku_script)
186
-
187
- ENV['PATH'] = "#{heroku_script_bin}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
188
- end
189
-
190
- Then /^my Honeybadger configuration should contain the following line:$/ do |line|
191
- configuration_file = if rails_supports_initializers?
192
- rails_initializer_file
193
- else
194
- rails_non_initializer_honeybadger_config_file
195
- end
196
-
197
- configuration = File.read(configuration_file)
198
- if ! configuration.include?(line.strip)
199
- raise "Expected text:\n#{configuration}\nTo include:\n#{line}\nBut it didn't."
200
- end
201
- end
202
-
203
- When /^I configure the application to filter parameter "([^\"]*)"$/ do |parameter|
204
- if rails2?
205
- controller_filename = application_controller_filename
206
- controller_lines = File.open(controller_filename).readlines
207
-
208
- controller_definition_line = controller_lines.detect { |line| line =~ /ApplicationController/ }
209
- controller_definition_line_index = controller_lines.index(controller_definition_line)
210
-
211
- controller_lines.insert(controller_definition_line_index + 1,
212
- " filter_parameter_logging #{parameter.inspect}")
213
-
214
- File.open(controller_filename, "w") do |file|
215
- file.puts controller_lines.join("\n")
216
- end
217
- else
218
- application_filename = File.join(rails_root, 'config', 'application.rb')
219
- application_lines = File.open(application_filename).readlines
220
-
221
- application_definition_line = application_lines.detect { |line| line =~ /Application/ }
222
- application_definition_line_index = application_lines.index(application_definition_line)
223
-
224
- application_lines.insert(application_definition_line_index + 1,
225
- " config.filter_parameters += [#{parameter.inspect}]")
226
-
227
- File.open(application_filename, "w") do |file|
228
- file.puts application_lines.join("\n")
229
- end
230
- end
231
- end
232
-
233
- When /^I install the "([^\"]*)" plugin$/ do |plugin_name|
234
- FileUtils.mkdir_p("#{rails_root}/vendor/plugins/#{plugin_name}")
235
- end
236
-
237
- When /^I configure the notifier to use "([^\"]*)" as an API key$/ do |api_key|
238
- steps %{
239
- When I configure Honeybadger with:
240
- """
241
- config.api_key = #{api_key.inspect}
242
- """
243
- }
244
- end
245
-
246
- When /^I configure Rails with:$/ do |config|
247
- if rails2?
248
- fail 'This step definition requires Rails 3+. Please add support for Rails 2 if you need it.'
249
- else
250
- application_filename = File.join(rails_root, 'config', 'application.rb')
251
- application_lines = File.open(application_filename).readlines
252
-
253
- application_definition_line = application_lines.detect { |line| line =~ /Application/ }
254
- application_definition_line_index = application_lines.index(application_definition_line)
255
-
256
- application_lines.insert(application_definition_line_index + 1, config)
257
-
258
- File.open(application_filename, "w") do |file|
259
- file.puts application_lines.join("\n")
260
- end
261
- end
262
- end
263
-
264
- When /^I install capistrano$/ do
265
- if capify?
266
- step %(I successfully run `capify .`)
267
- else
268
- step %(I successfully run `cap install`)
269
- end
270
- end