projectlocker_errata 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. data/CHANGELOG +908 -0
  2. data/Gemfile +3 -0
  3. data/Guardfile +6 -0
  4. data/INSTALL +20 -0
  5. data/MIT-LICENSE +23 -0
  6. data/README.md +460 -0
  7. data/README_FOR_HEROKU_ADDON.md +94 -0
  8. data/Rakefile +223 -0
  9. data/SUPPORTED_RAILS_VERSIONS +38 -0
  10. data/TESTING.md +41 -0
  11. data/features/metal.feature +18 -0
  12. data/features/rack.feature +60 -0
  13. data/features/rails.feature +272 -0
  14. data/features/rails_with_js_notifier.feature +97 -0
  15. data/features/rake.feature +27 -0
  16. data/features/sinatra.feature +29 -0
  17. data/features/step_definitions/file_steps.rb +10 -0
  18. data/features/step_definitions/metal_steps.rb +23 -0
  19. data/features/step_definitions/rack_steps.rb +23 -0
  20. data/features/step_definitions/rails_application_steps.rb +478 -0
  21. data/features/step_definitions/rake_steps.rb +17 -0
  22. data/features/support/env.rb +18 -0
  23. data/features/support/matchers.rb +35 -0
  24. data/features/support/projectlocker_errata_shim.rb.template +16 -0
  25. data/features/support/rails.rb +201 -0
  26. data/features/support/rake/Rakefile +68 -0
  27. data/features/support/terminal.rb +107 -0
  28. data/features/user_informer.feature +63 -0
  29. data/generators/projectlocker_errata/lib/insert_commands.rb +34 -0
  30. data/generators/projectlocker_errata/lib/rake_commands.rb +24 -0
  31. data/generators/projectlocker_errata/projectlocker_errata_generator.rb +94 -0
  32. data/generators/projectlocker_errata/templates/capistrano_hook.rb +6 -0
  33. data/generators/projectlocker_errata/templates/initializer.rb +6 -0
  34. data/generators/projectlocker_errata/templates/projectlocker_errata_tasks.rake +25 -0
  35. data/install.rb +1 -0
  36. data/lib/projectlocker_errata/backtrace.rb +108 -0
  37. data/lib/projectlocker_errata/capistrano.rb +43 -0
  38. data/lib/projectlocker_errata/configuration.rb +305 -0
  39. data/lib/projectlocker_errata/notice.rb +390 -0
  40. data/lib/projectlocker_errata/rack.rb +54 -0
  41. data/lib/projectlocker_errata/rails/action_controller_catcher.rb +30 -0
  42. data/lib/projectlocker_errata/rails/controller_methods.rb +85 -0
  43. data/lib/projectlocker_errata/rails/error_lookup.rb +33 -0
  44. data/lib/projectlocker_errata/rails/javascript_notifier.rb +47 -0
  45. data/lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb +33 -0
  46. data/lib/projectlocker_errata/rails.rb +40 -0
  47. data/lib/projectlocker_errata/rails3_tasks.rb +98 -0
  48. data/lib/projectlocker_errata/railtie.rb +48 -0
  49. data/lib/projectlocker_errata/rake_handler.rb +65 -0
  50. data/lib/projectlocker_errata/sender.rb +128 -0
  51. data/lib/projectlocker_errata/shared_tasks.rb +47 -0
  52. data/lib/projectlocker_errata/tasks.rb +83 -0
  53. data/lib/projectlocker_errata/user_informer.rb +27 -0
  54. data/lib/projectlocker_errata/utils/blank.rb +53 -0
  55. data/lib/projectlocker_errata/version.rb +3 -0
  56. data/lib/projectlocker_errata.rb +159 -0
  57. data/lib/projectlocker_errata_tasks.rb +64 -0
  58. data/lib/rails/generators/projectlocker_errata/projectlocker_errata_generator.rb +100 -0
  59. data/lib/templates/javascript_notifier.erb +15 -0
  60. data/lib/templates/rescue.erb +91 -0
  61. data/projectlocker_errata.gemspec +39 -0
  62. data/rails/init.rb +1 -0
  63. data/resources/README.md +34 -0
  64. data/resources/ca-bundle.crt +3376 -0
  65. data/script/integration_test.rb +38 -0
  66. data/test/airbrake_2_3.xsd +88 -0
  67. data/test/backtrace_test.rb +162 -0
  68. data/test/capistrano_test.rb +34 -0
  69. data/test/catcher_test.rb +333 -0
  70. data/test/configuration_test.rb +236 -0
  71. data/test/helper.rb +263 -0
  72. data/test/javascript_notifier_test.rb +51 -0
  73. data/test/logger_test.rb +79 -0
  74. data/test/notice_test.rb +490 -0
  75. data/test/notifier_test.rb +276 -0
  76. data/test/projectlocker_errata_tasks_test.rb +170 -0
  77. data/test/rack_test.rb +58 -0
  78. data/test/rails_initializer_test.rb +36 -0
  79. data/test/recursion_test.rb +10 -0
  80. data/test/sender_test.rb +288 -0
  81. data/test/user_informer_test.rb +29 -0
  82. metadata +440 -0
@@ -0,0 +1,97 @@
1
+ Feature: Install the Gem in a Rails application and enable the JavaScript notifier
2
+
3
+ Background:
4
+ Given I have built and installed the "projectlocker_errata" gem
5
+
6
+ Scenario: Include the Javascript notifier when enabled
7
+ When I generate a new Rails application
8
+ And I configure the ProjectlockerErrata shim
9
+ And I configure my application to require the "projectlocker_errata" gem
10
+ When I configure the notifier to use the following configuration lines:
11
+ """
12
+ config.api_key = "myapikey"
13
+ """
14
+ And I define a response for "TestController#index":
15
+ """
16
+ render :inline => '<html><head profile="http://example.com"><%= projectlocker_errata_javascript_notifier %></head><body></body></html>'
17
+ """
18
+ And I route "/test/index" to "test#index"
19
+ And I perform a request to "http://example.com:123/test/index"
20
+ Then I should see the notifier JavaScript for the following:
21
+ | api_key | environment | host |
22
+ | myapikey | production | api.projectlocker_errata.io |
23
+ And the notifier JavaScript should provide the following errorDefaults:
24
+ | url | component | action |
25
+ | http://example.com:123/test/index | test | index |
26
+
27
+ Scenario: Include the Javascript notifier when enabled using custom configuration settings
28
+ When I generate a new Rails application
29
+ And I configure the ProjectlockerErrata shim
30
+ And I configure my application to require the "projectlocker_errata" gem
31
+ When I configure the notifier to use the following configuration lines:
32
+ """
33
+ config.api_key = "myapikey!"
34
+ config.host = "myprojectlocker_errata.com"
35
+ config.port = 3001
36
+ """
37
+ And I define a response for "TestController#index":
38
+ """
39
+ render :inline => '<html><head><%= projectlocker_errata_javascript_notifier %></head><body></body></html>'
40
+ """
41
+ And I route "/test/index" to "test#index"
42
+ And I perform a request to "http://example.com:123/test/index"
43
+ Then I should see the notifier JavaScript for the following:
44
+ | api_key | environment | host |
45
+ | myapikey! | production | myprojectlocker_errata.com:3001 |
46
+
47
+ Scenario: Don't include the Javascript notifier by default
48
+ When I generate a new Rails application
49
+ And I configure the ProjectlockerErrata shim
50
+ And I configure my application to require the "projectlocker_errata" gem
51
+ When I configure the notifier to use the following configuration lines:
52
+ """
53
+ config.api_key = "myapikey!"
54
+ """
55
+ And I define a response for "TestController#index":
56
+ """
57
+ render :inline => "<html><head></head><body></body></html>"
58
+ """
59
+ And I route "/test/index" to "test#index"
60
+ And I perform a request to "http://example.com:123/test/index"
61
+ Then I should not see notifier JavaScript
62
+
63
+ Scenario: Don't include the Javascript notifier when enabled in non-public environments
64
+ When I generate a new Rails application
65
+ And I configure the ProjectlockerErrata shim
66
+ And I configure my application to require the "projectlocker_errata" gem
67
+ When I configure the notifier to use the following configuration lines:
68
+ """
69
+ config.api_key = "myapikey!"
70
+ config.environment_name = 'test'
71
+ """
72
+ And I define a response for "TestController#index":
73
+ """
74
+ render :inline => '<html><head><%= projectlocker_errata_javascript_notifier %></head><body></body></html>'
75
+ """
76
+ And I route "/test/index" to "test#index"
77
+ And I perform a request to "http://example.com:123/test/index" in the "test" environment
78
+ Then I should not see notifier JavaScript
79
+
80
+ Scenario: Include the Javascript notifier with a custom api key
81
+ When I generate a new Rails application
82
+ And I configure the ProjectlockerErrata shim
83
+ And I configure my application to require the "projectlocker_errata" gem
84
+ When I configure the notifier to use the following configuration lines:
85
+ """
86
+ config.api_key = "myapikey!"
87
+ config.js_api_key = "myjsapikey!"
88
+ """
89
+ And I define a response for "TestController#index":
90
+ """
91
+ render :inline => '<html><head><%= projectlocker_errata_javascript_notifier %></head><body></body></html>'
92
+ """
93
+ And I route "/test/index" to "test#index"
94
+ And I perform a request to "http://example.com:123/test/index"
95
+ Then I should see the notifier JavaScript for the following:
96
+ | api_key | environment | host |
97
+ | myjsapikey! | production | api.projectlocker_errata.io |
@@ -0,0 +1,27 @@
1
+ Feature: Use the Gem to catch errors in a Rake application
2
+ Background:
3
+ Given I have built and installed the "projectlocker_errata" gem
4
+
5
+ Scenario: Catching exceptions in Rake
6
+ When I run rake with projectlocker_errata
7
+ Then ProjectlockerErrata should catch the exception
8
+
9
+ Scenario: Falling back to default handler before ProjectlockerErrata is configured
10
+ When I run rake with projectlocker_errata not yet configured
11
+ Then ProjectlockerErrata should not catch the exception
12
+
13
+ Scenario: Disabling Rake exception catcher
14
+ When I run rake with projectlocker_errata disabled
15
+ Then ProjectlockerErrata should not catch the exception
16
+
17
+ Scenario: Autodetect, running from terminal
18
+ When I run rake with projectlocker_errata autodetect from terminal
19
+ Then ProjectlockerErrata should not catch the exception
20
+
21
+ Scenario: Autodetect, not running from terminal
22
+ When I run rake with projectlocker_errata autodetect not from terminal
23
+ Then ProjectlockerErrata should catch the exception
24
+
25
+ Scenario: Sending the correct component name
26
+ When I run rake with projectlocker_errata
27
+ Then ProjectlockerErrata should send the rake command line as the component name
@@ -0,0 +1,29 @@
1
+ Feature: Use the notifier in a Sinatra app
2
+
3
+ Background:
4
+ Given I have built and installed the "projectlocker_errata" gem
5
+
6
+ Scenario: Rescue an exception in a Sinatra app
7
+ Given the following Rack app:
8
+ """
9
+ require 'sinatra/base'
10
+ require 'projectlocker_errata'
11
+
12
+ ProjectlockerErrata.configure do |config|
13
+ config.api_key = 'my_api_key'
14
+ end
15
+
16
+ class FontaneApp < Sinatra::Base
17
+ use ProjectlockerErrata::Rack
18
+ enable :raise_errors
19
+
20
+ get "/test/index" do
21
+ raise "Sinatra has left the building"
22
+ end
23
+ end
24
+
25
+ app = FontaneApp
26
+ """
27
+ When I perform a Rack request to "http://example.com:123/test/index?param=value"
28
+ Then I should receive a ProjectlockerErrata notification
29
+
@@ -0,0 +1,10 @@
1
+ Then /^"([^\"]*)" should not contain text of "([^\"]*)"$/ do |target_file, contents_file|
2
+ notifier_root = File.join(File.dirname(__FILE__), '..', '..')
3
+ full_path_contents = File.join(notifier_root, contents_file)
4
+ contents_text = File.open(full_path_contents).read
5
+
6
+ full_path_target = File.join(rails_root, target_file)
7
+ target_text = File.open(full_path_target).read
8
+
9
+ target_text.should_not include(contents_text)
10
+ end
@@ -0,0 +1,23 @@
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.underscore}.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
+ When %{the metal endpoint "#{class_name}" is mounted in the Rails 3 routes.rb} if rails3?
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 = "match '/metal(/*other)' => #{class_name}"
16
+ routes = routes[0..-2] + [rack_route, routes[-1]]
17
+ File.open(routesrb, "w") do |f|
18
+ f.puts "require 'app/metal/#{class_name.underscore}'"
19
+ routes.each do |route_line|
20
+ f.puts route_line
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
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
+ shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'airbrake_shim.rb.template')
7
+ request_file = File.join(TEMP_DIR, 'rack_request.rb')
8
+ File.open(request_file, 'w') do |file|
9
+ file.puts "require 'rubygems'"
10
+ file.puts IO.read(shim_file)
11
+ file.puts IO.read(RACK_FILE)
12
+ file.puts "env = Rack::MockRequest.env_for(#{url.inspect})"
13
+ file.puts "status, headers, body = app.call(env)"
14
+ file.puts %{puts "HTTP \#{status}"}
15
+ file.puts %{headers.each { |key, value| puts "\#{key}: \#{value}"}}
16
+ file.puts "body.each { |part| print part }"
17
+ end
18
+ @terminal.run("ruby #{request_file}")
19
+ end
20
+
21
+ Then /^I should receive a Airbrake notification for rack$/ do
22
+ Then %{I should see "You have accessed a deleted account."}
23
+ end