honeybadger 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/Appraisals +25 -1
  2. data/CHANGELOG.md +47 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +7 -8
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +117 -6
  7. data/Rakefile +15 -0
  8. data/features/rack.feature +2 -2
  9. data/features/rails.feature +79 -15
  10. data/features/step_definitions/metal_steps.rb +4 -4
  11. data/features/step_definitions/rack_steps.rb +0 -4
  12. data/features/step_definitions/rails_steps.rb +49 -32
  13. data/features/support/honeybadger_failure_shim.rb.template +5 -0
  14. data/features/support/rails.rb +17 -5
  15. data/gemfiles/rack.gemfile +8 -0
  16. data/gemfiles/rack.gemfile.lock +92 -0
  17. data/gemfiles/rails2.3.gemfile +1 -1
  18. data/gemfiles/rails2.3.gemfile.lock +6 -2
  19. data/gemfiles/rails3.0.gemfile +2 -1
  20. data/gemfiles/rails3.0.gemfile.lock +12 -3
  21. data/gemfiles/rails3.1.gemfile +2 -1
  22. data/gemfiles/rails3.1.gemfile.lock +12 -3
  23. data/gemfiles/rails3.2.gemfile +3 -2
  24. data/gemfiles/rails3.2.gemfile.lock +45 -36
  25. data/gemfiles/rails4.gemfile +9 -0
  26. data/gemfiles/rails4.gemfile.lock +174 -0
  27. data/gemfiles/rake.gemfile +8 -0
  28. data/gemfiles/rake.gemfile.lock +91 -0
  29. data/gemfiles/sinatra.gemfile +8 -0
  30. data/gemfiles/sinatra.gemfile.lock +91 -0
  31. data/generators/honeybadger/honeybadger_generator.rb +5 -5
  32. data/honeybadger.gemspec +12 -3
  33. data/lib/honeybadger.rb +7 -14
  34. data/lib/honeybadger/configuration.rb +10 -1
  35. data/lib/honeybadger/notice.rb +38 -20
  36. data/lib/honeybadger/rack.rb +0 -1
  37. data/lib/honeybadger/rails/controller_methods.rb +5 -4
  38. data/lib/honeybadger/rails3_tasks.rb +16 -4
  39. data/lib/honeybadger/sender.rb +10 -19
  40. data/lib/honeybadger/shared_tasks.rb +2 -3
  41. data/lib/honeybadger/tasks.rb +16 -9
  42. data/lib/honeybadger_tasks.rb +2 -3
  43. data/lib/rails/generators/honeybadger/honeybadger_generator.rb +5 -5
  44. data/test/test_helper.rb +2 -7
  45. data/test/unit/backtrace_test.rb +19 -19
  46. data/test/unit/configuration_test.rb +11 -5
  47. data/test/unit/notice_test.rb +21 -3
  48. data/test/unit/rails/action_controller_catcher_test.rb +250 -241
  49. data/test/unit/sender_test.rb +22 -2
  50. metadata +13 -19
@@ -1,22 +1,22 @@
1
1
  When /^I define a Metal endpoint called "([^\"]*)":$/ do |class_name, definition|
2
2
  FileUtils.mkdir_p(File.join(rails_root, 'app', 'metal'))
3
- file_name = File.join(rails_root, 'app', 'metal', "#{class_name.underscore}.rb")
3
+ file_name = File.join(rails_root, 'app', 'metal', "#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}.rb")
4
4
  File.open(file_name, "w") do |file|
5
5
  file.puts "class #{class_name}"
6
6
  file.puts definition
7
7
  file.puts "end"
8
8
  end
9
- step %(the metal endpoint "#{class_name}" is mounted in the Rails 3 routes.rb) if rails3?
9
+ step %(the metal endpoint "#{class_name}" is mounted in the Rails 3 routes.rb) unless rails2?
10
10
  end
11
11
 
12
12
  When /^the metal endpoint "([^\"]*)" is mounted in the Rails 3 routes.rb$/ do |class_name|
13
13
  routesrb = File.join(rails_root, "config", "routes.rb")
14
14
  routes = IO.readlines(routesrb)
15
- rack_route = "match '/metal(/*other)' => #{class_name}"
15
+ rack_route = "get '/metal(/*other)' => #{class_name}"
16
16
  routes = routes[0..-2] + [rack_route, routes[-1]]
17
17
  File.open(routesrb, "w") do |f|
18
18
  f.puts "$:<< '#{LOCAL_RAILS_ROOT}'"
19
- f.puts "require 'app/metal/#{class_name.underscore}'"
19
+ f.puts "require 'app/metal/#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}'"
20
20
  routes.each do |route_line|
21
21
  f.puts route_line
22
22
  end
@@ -17,7 +17,3 @@ When /^I perform a Rack request to "([^\"]*)"$/ do |url|
17
17
  end
18
18
  step %(I run `ruby #{request_file}`)
19
19
  end
20
-
21
- Then /^I should receive a Honeybadger notification for rack$/ do
22
- step %(The output should contain "You have accessed a deleted account.")
23
- end
@@ -1,8 +1,7 @@
1
1
  require 'uri'
2
- require 'active_support/core_ext'
3
2
 
4
3
  When /^I generate a new Rails application$/ do
5
- rails_create_command = !rails3? ? 'rails rails_root' :
4
+ rails_create_command = rails2? ? 'rails rails_root' :
6
5
  'rails new rails_root -O -S -G -J -T --skip-gemfile --skip-bundle'
7
6
 
8
7
  step %(I successfully run `bundle exec #{rails_create_command}`)
@@ -12,14 +11,14 @@ When /^I generate a new Rails application$/ do
12
11
 
13
12
  monkeypatch_old_version if rails_version == "2.3.14"
14
13
 
15
- unless rails3?
14
+ if rails2?
16
15
  config_gem_dependencies
17
16
  disable_activerecord
18
17
  end
19
18
  end
20
19
 
21
- When /^I configure the Honeybadger shim$/ do
22
- shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'honeybadger_shim.rb.template')
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")
23
22
  if rails_supports_initializers?
24
23
  target = File.join(rails_root, 'config', 'initializers', 'honeybadger_shim.rb')
25
24
  FileUtils.cp(shim_file, target)
@@ -32,7 +31,7 @@ When /^I configure the Honeybadger shim$/ do
32
31
  end
33
32
 
34
33
  When /^I configure my application to require Honeybadger$/ do
35
- if rails3?
34
+ if rails_uses_bundler?
36
35
  # Do nothing - bundler's on it
37
36
  elsif rails_manages_gems?
38
37
  config_gem('honeybadger')
@@ -50,10 +49,10 @@ When /^I configure my application to require Honeybadger$/ do
50
49
  end
51
50
 
52
51
  When /^I configure Honeybadger with:$/ do |config|
53
- if rails_manages_gems?
54
- requires = ''
52
+ requires = if rails_uses_bundler? || rails_manages_gems?
53
+ ''
55
54
  else
56
- requires = "require 'honeybadger'"
55
+ %(require 'honeybadger')
57
56
  end
58
57
 
59
58
  initializer_code = <<-EOF
@@ -74,10 +73,10 @@ When /^I configure Honeybadger with:$/ do |config|
74
73
  end
75
74
 
76
75
  When /^I run the honeybadger generator with "([^\"]*)"$/ do |generator_args|
77
- if rails3?
78
- step %(I successfully run `./script/rails generate honeybadger #{generator_args}`)
79
- else
76
+ if rails2?
80
77
  step %(I successfully run `./script/generate honeybadger #{generator_args}`)
78
+ else
79
+ step %(I successfully run `rails generate honeybadger #{generator_args}`)
81
80
  end
82
81
  end
83
82
 
@@ -92,7 +91,7 @@ Then /^I should receive (.+) Honeybadger notifications?$/ do |number|
92
91
  end
93
92
 
94
93
  Then /^the request\s?(url|component|action|params|session|cgi_data|context)? should( not)? contain "([^\"]*)"$/ do |key, negate, expected|
95
- notice = all_output.match(/Notice: ({.+})/) ? JSON.parse(Regexp.last_match(1)) : {}
94
+ notice = all_output.match(/Notice: (\{.+\})/) ? JSON.parse(Regexp.last_match(1)) : {}
96
95
  hash = key ? notice['request'][key.strip] : notice['request']
97
96
  hash.to_s.send(negate ? :should_not : :should, match(/#{Regexp.escape(expected)}/))
98
97
  end
@@ -103,10 +102,10 @@ end
103
102
 
104
103
  When /^I define a( metal)? response for "([^\"]*)":$/ do |metal, controller_and_action, definition|
105
104
  controller_class_name, action = controller_and_action.split('#')
106
- controller_name = controller_class_name.underscore
105
+ controller_name = controller_class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase
107
106
  controller_file_name = File.join(rails_root, 'app', 'controllers', "#{controller_name}.rb")
108
107
  File.open(controller_file_name, "w") do |file|
109
- file.puts "class #{controller_class_name} < #{ (metal && rails3?) ? 'ActionController::Metal' : 'ApplicationController'}"
108
+ file.puts "class #{controller_class_name} < #{ (metal && !rails2?) ? 'ActionController::Metal' : 'ApplicationController'}"
110
109
  file.puts "def consider_all_requests_local; false; end"
111
110
  file.puts "def local_request?; false; end"
112
111
  file.puts "def #{action}"
@@ -121,11 +120,11 @@ When /^I perform a request to "([^\"]*)"$/ do |uri|
121
120
  end
122
121
 
123
122
  When /^I route "([^\"]*)" to "([^\"]*)"$/ do |path, controller_action_pair|
124
- route = if rails3?
125
- %(match "#{path}", :to => "#{controller_action_pair}")
126
- else
123
+ route = if rails2?
127
124
  controller, action = controller_action_pair.split('#')
128
125
  %(map.connect "#{path}", :controller => "#{controller}", :action => "#{action}")
126
+ else
127
+ %(get "#{path}" => "#{controller_action_pair}")
129
128
  end
130
129
  routes_file = File.join(rails_root, "config", "routes.rb")
131
130
  File.open(routes_file, "r+") do |file|
@@ -182,20 +181,7 @@ Then /^my Honeybadger configuration should contain the following line:$/ do |lin
182
181
  end
183
182
 
184
183
  When /^I configure the application to filter parameter "([^\"]*)"$/ do |parameter|
185
- if rails3?
186
- application_filename = File.join(rails_root, 'config', 'application.rb')
187
- application_lines = File.open(application_filename).readlines
188
-
189
- application_definition_line = application_lines.detect { |line| line =~ /Application/ }
190
- application_definition_line_index = application_lines.index(application_definition_line)
191
-
192
- application_lines.insert(application_definition_line_index + 1,
193
- " config.filter_parameters += [#{parameter.inspect}]")
194
-
195
- File.open(application_filename, "w") do |file|
196
- file.puts application_lines.join("\n")
197
- end
198
- else
184
+ if rails2?
199
185
  controller_filename = application_controller_filename
200
186
  controller_lines = File.open(controller_filename).readlines
201
187
 
@@ -208,6 +194,19 @@ When /^I configure the application to filter parameter "([^\"]*)"$/ do |paramete
208
194
  File.open(controller_filename, "w") do |file|
209
195
  file.puts controller_lines.join("\n")
210
196
  end
197
+ else
198
+ application_filename = File.join(rails_root, 'config', 'application.rb')
199
+ application_lines = File.open(application_filename).readlines
200
+
201
+ application_definition_line = application_lines.detect { |line| line =~ /Application/ }
202
+ application_definition_line_index = application_lines.index(application_definition_line)
203
+
204
+ application_lines.insert(application_definition_line_index + 1,
205
+ " config.filter_parameters += [#{parameter.inspect}]")
206
+
207
+ File.open(application_filename, "w") do |file|
208
+ file.puts application_lines.join("\n")
209
+ end
211
210
  end
212
211
  end
213
212
 
@@ -223,3 +222,21 @@ When /^I configure the notifier to use "([^\"]*)" as an API key$/ do |api_key|
223
222
  """
224
223
  }
225
224
  end
225
+
226
+ When /^I configure Rails with:$/ do |config|
227
+ if rails2?
228
+ fail 'This step definition requires Rails 3+. Please add support for Rails 2 if you need it.'
229
+ else
230
+ application_filename = File.join(rails_root, 'config', 'application.rb')
231
+ application_lines = File.open(application_filename).readlines
232
+
233
+ application_definition_line = application_lines.detect { |line| line =~ /Application/ }
234
+ application_definition_line_index = application_lines.index(application_definition_line)
235
+
236
+ application_lines.insert(application_definition_line_index + 1, config)
237
+
238
+ File.open(application_filename, "w") do |file|
239
+ file.puts application_lines.join("\n")
240
+ end
241
+ end
242
+ end
@@ -0,0 +1,5 @@
1
+ require 'sham_rack'
2
+
3
+ ShamRack.at("api.honeybadger.io", 443) do |env|
4
+ ["500 Internal Error", { "Content-type" => "text/html" }, ['']]
5
+ end
@@ -3,32 +3,44 @@ module RailsHelpers
3
3
  controller_filename = File.join(rails_root, 'app', 'controllers', "application_controller.rb")
4
4
  end
5
5
 
6
+ def rails2?
7
+ rails_version =~ /^2/
8
+ end
9
+
6
10
  def rails3?
7
11
  rails_version =~ /^3/
8
12
  end
9
13
 
14
+ def rails4?
15
+ rails_version =~ /^4/
16
+ end
17
+
10
18
  def rails_root
11
19
  LOCAL_RAILS_ROOT
12
20
  end
13
21
 
14
22
  def rails_uses_rack?
15
- rails3? || rails_version =~ /^2\.3/
23
+ rails4? || rails3? || rails_version =~ /^2\.3/
16
24
  end
17
25
 
18
26
  def rails_version
19
27
  @rails_version ||= `bundle exec rails -v`[/\d.+/]
20
28
  end
21
29
 
30
+ def rails_uses_bundler?
31
+ rails4? || rails3?
32
+ end
33
+
22
34
  def rails_manages_gems?
23
35
  rails_version =~ /^2\.[123]/
24
36
  end
25
37
 
26
38
  def rails_supports_initializers?
27
- rails3? || rails_version =~ /^2\./
39
+ rails4? || rails3? || rails_version =~ /^2\./
28
40
  end
29
41
 
30
42
  def rails_finds_generators_in_gems?
31
- rails3? || rails_version =~ /^2\./
43
+ rails4? || rails3? || rails_version =~ /^2\./
32
44
  end
33
45
 
34
46
  def environment_path
@@ -72,7 +84,7 @@ module RailsHelpers
72
84
  end
73
85
 
74
86
  def perform_request(uri, environment = 'production')
75
- if rails3?
87
+ if rails4? || rails3?
76
88
  request_script = <<-SCRIPT
77
89
  require File.expand_path('../config/environment', __FILE__)
78
90
 
@@ -91,7 +103,7 @@ module RailsHelpers
91
103
  end
92
104
  SCRIPT
93
105
  File.open(File.join(rails_root, 'request.rb'), 'w') { |file| file.write(request_script) }
94
- step %(I run `ruby -rthread ./script/rails runner -e #{environment} request.rb`)
106
+ step %(I run `rails runner -e #{environment} request.rb`)
95
107
  elsif rails_uses_rack?
96
108
  request_script = <<-SCRIPT
97
109
  require File.expand_path('../config/environment', __FILE__)
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack"
6
+ gem "honeybadger", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: /Users/josh/code/honeybadger-ruby
3
+ specs:
4
+ honeybadger (1.5.0)
5
+ json
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (0.5.1)
11
+ bundler
12
+ rake
13
+ aruba (0.5.1)
14
+ childprocess (~> 0.3.6)
15
+ cucumber (>= 1.1.1)
16
+ rspec-expectations (>= 2.7.0)
17
+ bourne (1.3.0)
18
+ mocha (= 0.13.0)
19
+ builder (3.1.4)
20
+ capistrano (2.14.1)
21
+ highline
22
+ net-scp (>= 1.0.0)
23
+ net-sftp (>= 2.0.0)
24
+ net-ssh (>= 2.0.14)
25
+ net-ssh-gateway (>= 1.1.0)
26
+ childprocess (0.3.6)
27
+ ffi (~> 1.0, >= 1.0.6)
28
+ cucumber (1.2.1)
29
+ builder (>= 2.1.2)
30
+ diff-lcs (>= 1.1.3)
31
+ gherkin (~> 2.11.0)
32
+ json (>= 1.4.6)
33
+ diff-lcs (1.1.3)
34
+ fakeweb (1.3.0)
35
+ ffi (1.3.1)
36
+ ffi (1.3.1-java)
37
+ gherkin (2.11.5)
38
+ json (>= 1.4.6)
39
+ gherkin (2.11.5-java)
40
+ json (>= 1.4.6)
41
+ highline (1.6.15)
42
+ json (1.7.6)
43
+ json (1.7.6-java)
44
+ metaclass (0.0.1)
45
+ mocha (0.13.0)
46
+ metaclass (~> 0.0.1)
47
+ net-scp (1.0.4)
48
+ net-ssh (>= 1.99.1)
49
+ net-sftp (2.0.5)
50
+ net-ssh (>= 2.0.9)
51
+ net-ssh (2.6.3)
52
+ net-ssh-gateway (1.1.0)
53
+ net-ssh (>= 1.99.1)
54
+ rack (1.4.4)
55
+ rack-protection (1.3.2)
56
+ rack
57
+ rake (10.0.3)
58
+ rspec (2.12.0)
59
+ rspec-core (~> 2.12.0)
60
+ rspec-expectations (~> 2.12.0)
61
+ rspec-mocks (~> 2.12.0)
62
+ rspec-core (2.12.2)
63
+ rspec-expectations (2.12.1)
64
+ diff-lcs (~> 1.1.3)
65
+ rspec-mocks (2.12.1)
66
+ sham_rack (1.3.4)
67
+ rack
68
+ shoulda (2.11.3)
69
+ sinatra (1.3.3)
70
+ rack (~> 1.3, >= 1.3.6)
71
+ rack-protection (~> 1.2)
72
+ tilt (~> 1.3, >= 1.3.3)
73
+ tilt (1.3.3)
74
+
75
+ PLATFORMS
76
+ java
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ appraisal
81
+ aruba
82
+ bourne (>= 1.0)
83
+ capistrano
84
+ cucumber (~> 1.2.1)
85
+ fakeweb (~> 1.3.0)
86
+ honeybadger!
87
+ rack
88
+ rake
89
+ rspec (~> 2.12.0)
90
+ sham_rack (~> 1.3.0)
91
+ shoulda (~> 2.11.3)
92
+ sinatra
@@ -1,6 +1,6 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source :rubygems
3
+ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "2.3.14"
6
6
  gem "rake", "0.9.5"
@@ -2,11 +2,10 @@ PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
4
  honeybadger (1.5.0)
5
- activesupport
6
5
  json
7
6
 
8
7
  GEM
9
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
10
9
  specs:
11
10
  actionmailer (2.3.14)
12
11
  actionpack (= 2.3.14)
@@ -44,10 +43,14 @@ GEM
44
43
  diff-lcs (1.1.3)
45
44
  fakeweb (1.3.0)
46
45
  ffi (1.2.0)
46
+ ffi (1.2.0-java)
47
47
  gherkin (2.11.5)
48
48
  json (>= 1.4.6)
49
+ gherkin (2.11.5-java)
50
+ json (>= 1.4.6)
49
51
  highline (1.6.15)
50
52
  json (1.7.5)
53
+ json (1.7.5-java)
51
54
  metaclass (0.0.1)
52
55
  mocha (0.10.5)
53
56
  metaclass (~> 0.0.1)
@@ -84,6 +87,7 @@ GEM
84
87
  tilt (1.3.3)
85
88
 
86
89
  PLATFORMS
90
+ java
87
91
  ruby
88
92
 
89
93
  DEPENDENCIES
@@ -1,8 +1,9 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source :rubygems
3
+ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "3.0.17"
6
6
  gem "honeybadger", :path=>"../"
7
+ gem "better_errors", :require=>false
7
8
 
8
9
  gemspec :path=>"../"
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.4.0)
5
- activesupport
4
+ honeybadger (1.5.0)
6
5
  json
7
6
 
8
7
  GEM
9
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
10
9
  specs:
11
10
  abstract (1.0.0)
12
11
  actionmailer (3.0.17)
@@ -43,6 +42,9 @@ GEM
43
42
  childprocess (~> 0.3.6)
44
43
  cucumber (>= 1.1.1)
45
44
  rspec-expectations (>= 2.7.0)
45
+ better_errors (0.5.0)
46
+ coderay (>= 1.0.0)
47
+ erubis (>= 2.6.6)
46
48
  bourne (1.1.2)
47
49
  mocha (= 0.10.5)
48
50
  builder (2.1.2)
@@ -54,6 +56,7 @@ GEM
54
56
  net-ssh-gateway (>= 1.1.0)
55
57
  childprocess (0.3.6)
56
58
  ffi (~> 1.0, >= 1.0.6)
59
+ coderay (1.0.8)
57
60
  cucumber (1.2.1)
58
61
  builder (>= 2.1.2)
59
62
  diff-lcs (>= 1.1.3)
@@ -64,11 +67,15 @@ GEM
64
67
  abstract (>= 1.0.0)
65
68
  fakeweb (1.3.0)
66
69
  ffi (1.2.0)
70
+ ffi (1.2.0-java)
67
71
  gherkin (2.11.5)
68
72
  json (>= 1.4.6)
73
+ gherkin (2.11.5-java)
74
+ json (>= 1.4.6)
69
75
  highline (1.6.15)
70
76
  i18n (0.5.0)
71
77
  json (1.7.5)
78
+ json (1.7.5-java)
72
79
  mail (2.2.19)
73
80
  activesupport (>= 2.3.6)
74
81
  i18n (>= 0.4.0)
@@ -128,11 +135,13 @@ GEM
128
135
  tzinfo (0.3.35)
129
136
 
130
137
  PLATFORMS
138
+ java
131
139
  ruby
132
140
 
133
141
  DEPENDENCIES
134
142
  appraisal
135
143
  aruba
144
+ better_errors
136
145
  bourne (>= 1.0)
137
146
  capistrano
138
147
  cucumber (~> 1.2.1)