exceptron 0.0.2

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 (75) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/lib/exceptron.rb +38 -0
  4. data/lib/exceptron/dispatcher.rb +58 -0
  5. data/lib/exceptron/exception.rb +97 -0
  6. data/lib/exceptron/exceptions_controller.rb +19 -0
  7. data/lib/exceptron/helpers.rb +24 -0
  8. data/lib/exceptron/local_exceptions_controller.rb +17 -0
  9. data/lib/exceptron/local_helpers.rb +27 -0
  10. data/lib/exceptron/middleware.rb +27 -0
  11. data/lib/exceptron/railtie.rb +16 -0
  12. data/lib/exceptron/version.rb +3 -0
  13. data/lib/exceptron/views/exceptron/exceptions/internal_server_error.html.erb +26 -0
  14. data/lib/exceptron/views/exceptron/local_exceptions/_request_and_response.erb +27 -0
  15. data/lib/exceptron/views/exceptron/local_exceptions/_trace.erb +26 -0
  16. data/lib/exceptron/views/exceptron/local_exceptions/diagnostics.erb +10 -0
  17. data/lib/exceptron/views/exceptron/local_exceptions/missing_template.erb +2 -0
  18. data/lib/exceptron/views/exceptron/local_exceptions/routing_error.erb +10 -0
  19. data/lib/exceptron/views/exceptron/local_exceptions/template_error.erb +17 -0
  20. data/lib/exceptron/views/exceptron/local_exceptions/unknown_action.erb +2 -0
  21. data/lib/exceptron/views/layouts/exceptron/local_exceptions.erb +31 -0
  22. data/test/dummy/Rakefile +7 -0
  23. data/test/dummy/app/controllers/application_controller.rb +4 -0
  24. data/test/dummy/app/controllers/exceptions_controller.rb +24 -0
  25. data/test/dummy/app/controllers/home_controller.rb +4 -0
  26. data/test/dummy/app/helpers/application_helper.rb +2 -0
  27. data/test/dummy/app/views/app_exceptions/internal_server_error.html.erb +2 -0
  28. data/test/dummy/app/views/app_exceptions/not_found.html.erb +2 -0
  29. data/test/dummy/app/views/home/index.erb +1 -0
  30. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/test/dummy/app/views/layouts/exceptions.html.erb +12 -0
  32. data/test/dummy/config.ru +4 -0
  33. data/test/dummy/config/application.rb +49 -0
  34. data/test/dummy/config/boot.rb +10 -0
  35. data/test/dummy/config/database.yml +22 -0
  36. data/test/dummy/config/environment.rb +5 -0
  37. data/test/dummy/config/environments/development.rb +25 -0
  38. data/test/dummy/config/environments/production.rb +49 -0
  39. data/test/dummy/config/environments/test.rb +35 -0
  40. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  41. data/test/dummy/config/initializers/inflections.rb +10 -0
  42. data/test/dummy/config/initializers/mime_types.rb +5 -0
  43. data/test/dummy/config/initializers/secret_token.rb +7 -0
  44. data/test/dummy/config/initializers/session_store.rb +8 -0
  45. data/test/dummy/config/locales/en.yml +5 -0
  46. data/test/dummy/config/routes.rb +60 -0
  47. data/test/dummy/db/development.sqlite3 +0 -0
  48. data/test/dummy/db/production.sqlite3 +0 -0
  49. data/test/dummy/db/schema.rb +15 -0
  50. data/test/dummy/db/test.sqlite3 +0 -0
  51. data/test/dummy/log/test.log +40506 -0
  52. data/test/dummy/public/favicon.ico +0 -0
  53. data/test/dummy/public/javascripts/application.js +2 -0
  54. data/test/dummy/public/javascripts/controls.js +965 -0
  55. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  56. data/test/dummy/public/javascripts/effects.js +1123 -0
  57. data/test/dummy/public/javascripts/prototype.js +4874 -0
  58. data/test/dummy/public/javascripts/rails.js +118 -0
  59. data/test/dummy/public/stylesheets/exceptions.css +17 -0
  60. data/test/dummy/script/rails +6 -0
  61. data/test/exceptron_local_custom_test.rb +173 -0
  62. data/test/exceptron_local_test.rb +122 -0
  63. data/test/exceptron_public_custom_test.rb +128 -0
  64. data/test/exceptron_public_test.rb +72 -0
  65. data/test/test_helper.rb +48 -0
  66. data/test/views/exceptions_custom/internal_server_error.da.html.erb +1 -0
  67. data/test/views/exceptions_custom/internal_server_error.json +1 -0
  68. data/test/views/exceptions_custom/not_found.html +26 -0
  69. data/test/views/exceptions_custom/not_found.xml +5 -0
  70. data/test/views/exceptions_custom/not_implemented.html.erb +26 -0
  71. data/test/views/layouts/exception_test.html.erb +12 -0
  72. data/test/views/local_exceptions_custom/diagnostics.da.html.erb +1 -0
  73. data/test/views/local_exceptions_custom/not_implemented.html.erb +26 -0
  74. data/test/views/local_exceptions_custom/unknown_action.erb +2 -0
  75. metadata +197 -0
@@ -0,0 +1,72 @@
1
+ require 'test_helper'
2
+
3
+ class ExceptronPublicTest < ActionDispatch::IntegrationTest
4
+ test "rescue in public from a remote ip" do
5
+ @app = ProductionApp
6
+ self.remote_addr = '208.77.188.166'
7
+
8
+ get "/"
9
+ assert_response 500
10
+ assert_equal 'text/html', response.content_type.to_s
11
+ assert_select 'title', "We're sorry, but something went wrong (500)"
12
+ assert_select 'body' do
13
+ assert_select 'h1', "We're sorry, but something went wrong."
14
+ assert_select 'p', "We've been notified about this issue and we'll take a look at it shortly."
15
+ end
16
+
17
+ get "/not_found"
18
+ assert_response 404
19
+ assert_equal 'text/html', response.content_type.to_s
20
+ assert_select 'title', "The page you were looking for doesn't exist (404)"
21
+ assert_select 'body' do
22
+ assert_select 'h1', "The page you were looking for doesn't exist."
23
+ assert_select 'p', "You may have mistyped the address or the page may have moved."
24
+ end
25
+
26
+ get "/method_not_allowed"
27
+ assert_response 405
28
+ assert_equal 'text/html', response.content_type.to_s
29
+ assert_select 'title', "We're sorry, but something went wrong (405)"
30
+ assert_select 'body' do
31
+ assert_select 'h1', "We're sorry, but something went wrong."
32
+ assert_select 'p', "We've been notified about this issue and we'll take a look at it shortly."
33
+ end
34
+ end
35
+
36
+ test "show registered original exception for wrapped exceptions when consider_all_requests_local is false" do
37
+ @app = ProductionApp
38
+ self.remote_addr = '208.77.188.166'
39
+
40
+ get "/not_found_original_exception"
41
+ assert_response 404
42
+ assert_equal 'text/html', response.content_type.to_s
43
+ assert_select 'title', "The page you were looking for doesn't exist (404)"
44
+ assert_select 'body' do
45
+ assert_select 'h1', "The page you were looking for doesn't exist."
46
+ assert_select 'p', "You may have mistyped the address or the page may have moved."
47
+ end
48
+ end
49
+
50
+ test "rescue other formats in public from a remote ip" do
51
+ @app = ProductionApp
52
+ self.remote_addr = '208.77.188.166'
53
+
54
+ get "/", {}, 'HTTP_ACCEPT' => 'application/json'
55
+ assert_response 500
56
+ assert_equal 'application/json', response.content_type.to_s
57
+ assert_match %r{"message":"Internal Server Error"}, response.body
58
+ assert_match %r{"status":500}, response.body
59
+
60
+ get "/not_found", {}, 'HTTP_ACCEPT' => 'application/xml'
61
+ assert_response 404
62
+ assert_equal 'application/xml', response.content_type.to_s
63
+ assert_match %r{<message>Not Found</message>}, response.body
64
+ assert_match %r{<status type="integer">404</status>}, response.body
65
+
66
+ get "/method_not_allowed", {}, 'HTTP_ACCEPT' => 'application/json'
67
+ assert_response 405
68
+ assert_equal 'application/json', response.content_type.to_s
69
+ assert_match %r{"message":"Method Not Allowed"}, response.body
70
+ assert_match %r{"status":405}, response.body
71
+ end
72
+ end
@@ -0,0 +1,48 @@
1
+ # Configure Rails Envinronment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ ActionMailer::Base.delivery_method = :test
8
+ ActionMailer::Base.perform_deliveries = true
9
+ ActionMailer::Base.default_url_options[:host] = "test.com"
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+
13
+ # Run any available migration
14
+ ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
15
+
16
+ # Move to abstract_unit.rb
17
+ module Exceptron
18
+ class Dispatcher
19
+ protected
20
+ undef :logger
21
+ # Silence logger
22
+ def logger
23
+ nil
24
+ end
25
+ end
26
+ end
27
+
28
+ Boomer = lambda do |env|
29
+ req = ActionDispatch::Request.new(env)
30
+ case req.path
31
+ when "/not_found"
32
+ raise AbstractController::ActionNotFound
33
+ when "/method_not_allowed"
34
+ raise ActionController::MethodNotAllowed
35
+ when "/not_implemented"
36
+ raise ActionController::NotImplemented
37
+ when "/unprocessable_entity"
38
+ raise ActionController::InvalidAuthenticityToken
39
+ when "/not_found_original_exception"
40
+ raise ActionView::Template::Error.new(ActionView::Template::Text.new('template'), {}, AbstractController::ActionNotFound.new)
41
+ else
42
+ raise "puke!"
43
+ end
44
+ end
45
+
46
+ ProductionApp = Exceptron::Middleware.new(Boomer, false)
47
+ DevelopmentApp = Exceptron::Middleware.new(Boomer, true)
48
+
@@ -0,0 +1 @@
1
+ 500 localized error fixture
@@ -0,0 +1 @@
1
+ {"message":"CUSTOM Internal Server Error", "status":500}
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>[CUSTOM] The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>[CUSTOM] The page you were looking for doesn't exist.</h1>
23
+ <p>[CUSTOM] You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <error>
3
+ <status type="integer">404</status>
4
+ <message>CUSTOM Not Found</message>
5
+ </error>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>[CUSTOM] 501 Not Implemented</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <div class="dialog">
21
+ <h1>[CUSTOM] 501 Not Implemented</h1>
22
+ <p>[CUSTOM] 501 Not Implemented</p>
23
+ <%= request.filtered_parameters.inspect %>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (<%= exception.status_message %>)</title>
5
+ <%= stylesheet_link_tag "exceptions" %>
6
+ </head>
7
+ <body>
8
+ <div class="dialog">
9
+ <%= yield %>
10
+ </div>
11
+ </body>
12
+ </html>
@@ -0,0 +1 @@
1
+ 500 localized error fixture
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>[CUSTOM] 501 Not Implemented</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <div class="dialog">
21
+ <h1>[CUSTOM] 501 Not Implemented</h1>
22
+ <p>[CUSTOM] 501 Not Implemented</p>
23
+ <%= request.filtered_parameters.inspect %>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,2 @@
1
+ <h1>[CUSTOM] Unknown action</h1>
2
+ <p>[CUSTOM] <%=h exception.message %></p>
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exceptron
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Santiago Pastorino
9
+ - José Valim
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-08-02 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: &2157099220 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 3.1.0.rc1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2157099220
26
+ - !ruby/object:Gem::Dependency
27
+ name: sqlite3
28
+ requirement: &2157094340 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *2157094340
37
+ description: Exceptron comes from the future to make your exceptions rock!
38
+ email:
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files:
42
+ - README.rdoc
43
+ files:
44
+ - lib/exceptron/dispatcher.rb
45
+ - lib/exceptron/exception.rb
46
+ - lib/exceptron/exceptions_controller.rb
47
+ - lib/exceptron/helpers.rb
48
+ - lib/exceptron/local_exceptions_controller.rb
49
+ - lib/exceptron/local_helpers.rb
50
+ - lib/exceptron/middleware.rb
51
+ - lib/exceptron/railtie.rb
52
+ - lib/exceptron/version.rb
53
+ - lib/exceptron.rb
54
+ - lib/exceptron/views/exceptron/exceptions/internal_server_error.html.erb
55
+ - lib/exceptron/views/exceptron/local_exceptions/_request_and_response.erb
56
+ - lib/exceptron/views/exceptron/local_exceptions/_trace.erb
57
+ - lib/exceptron/views/exceptron/local_exceptions/diagnostics.erb
58
+ - lib/exceptron/views/exceptron/local_exceptions/missing_template.erb
59
+ - lib/exceptron/views/exceptron/local_exceptions/routing_error.erb
60
+ - lib/exceptron/views/exceptron/local_exceptions/template_error.erb
61
+ - lib/exceptron/views/exceptron/local_exceptions/unknown_action.erb
62
+ - lib/exceptron/views/layouts/exceptron/local_exceptions.erb
63
+ - README.rdoc
64
+ - MIT-LICENSE
65
+ - test/dummy/app/controllers/application_controller.rb
66
+ - test/dummy/app/controllers/exceptions_controller.rb
67
+ - test/dummy/app/controllers/home_controller.rb
68
+ - test/dummy/app/helpers/application_helper.rb
69
+ - test/dummy/app/views/app_exceptions/internal_server_error.html.erb
70
+ - test/dummy/app/views/app_exceptions/not_found.html.erb
71
+ - test/dummy/app/views/home/index.erb
72
+ - test/dummy/app/views/layouts/application.html.erb
73
+ - test/dummy/app/views/layouts/exceptions.html.erb
74
+ - test/dummy/config/application.rb
75
+ - test/dummy/config/boot.rb
76
+ - test/dummy/config/database.yml
77
+ - test/dummy/config/environment.rb
78
+ - test/dummy/config/environments/development.rb
79
+ - test/dummy/config/environments/production.rb
80
+ - test/dummy/config/environments/test.rb
81
+ - test/dummy/config/initializers/backtrace_silencers.rb
82
+ - test/dummy/config/initializers/inflections.rb
83
+ - test/dummy/config/initializers/mime_types.rb
84
+ - test/dummy/config/initializers/secret_token.rb
85
+ - test/dummy/config/initializers/session_store.rb
86
+ - test/dummy/config/locales/en.yml
87
+ - test/dummy/config/routes.rb
88
+ - test/dummy/config.ru
89
+ - test/dummy/db/development.sqlite3
90
+ - test/dummy/db/production.sqlite3
91
+ - test/dummy/db/schema.rb
92
+ - test/dummy/db/test.sqlite3
93
+ - test/dummy/log/test.log
94
+ - test/dummy/public/favicon.ico
95
+ - test/dummy/public/javascripts/application.js
96
+ - test/dummy/public/javascripts/controls.js
97
+ - test/dummy/public/javascripts/dragdrop.js
98
+ - test/dummy/public/javascripts/effects.js
99
+ - test/dummy/public/javascripts/prototype.js
100
+ - test/dummy/public/javascripts/rails.js
101
+ - test/dummy/public/stylesheets/exceptions.css
102
+ - test/dummy/Rakefile
103
+ - test/dummy/script/rails
104
+ - test/exceptron_local_custom_test.rb
105
+ - test/exceptron_local_test.rb
106
+ - test/exceptron_public_custom_test.rb
107
+ - test/exceptron_public_test.rb
108
+ - test/test_helper.rb
109
+ - test/views/exceptions_custom/internal_server_error.da.html.erb
110
+ - test/views/exceptions_custom/internal_server_error.json
111
+ - test/views/exceptions_custom/not_found.html
112
+ - test/views/exceptions_custom/not_found.xml
113
+ - test/views/exceptions_custom/not_implemented.html.erb
114
+ - test/views/layouts/exception_test.html.erb
115
+ - test/views/local_exceptions_custom/diagnostics.da.html.erb
116
+ - test/views/local_exceptions_custom/not_implemented.html.erb
117
+ - test/views/local_exceptions_custom/unknown_action.erb
118
+ homepage: http://github.com/jorlhuda/exceptron
119
+ licenses: []
120
+ post_install_message:
121
+ rdoc_options:
122
+ - --main
123
+ - README.rdoc
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project: exceptron
140
+ rubygems_version: 1.8.5
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: Exceptron comes from the future to make your exceptions rock!
144
+ test_files:
145
+ - test/dummy/app/controllers/application_controller.rb
146
+ - test/dummy/app/controllers/exceptions_controller.rb
147
+ - test/dummy/app/controllers/home_controller.rb
148
+ - test/dummy/app/helpers/application_helper.rb
149
+ - test/dummy/app/views/app_exceptions/internal_server_error.html.erb
150
+ - test/dummy/app/views/app_exceptions/not_found.html.erb
151
+ - test/dummy/app/views/home/index.erb
152
+ - test/dummy/app/views/layouts/application.html.erb
153
+ - test/dummy/app/views/layouts/exceptions.html.erb
154
+ - test/dummy/config/application.rb
155
+ - test/dummy/config/boot.rb
156
+ - test/dummy/config/database.yml
157
+ - test/dummy/config/environment.rb
158
+ - test/dummy/config/environments/development.rb
159
+ - test/dummy/config/environments/production.rb
160
+ - test/dummy/config/environments/test.rb
161
+ - test/dummy/config/initializers/backtrace_silencers.rb
162
+ - test/dummy/config/initializers/inflections.rb
163
+ - test/dummy/config/initializers/mime_types.rb
164
+ - test/dummy/config/initializers/secret_token.rb
165
+ - test/dummy/config/initializers/session_store.rb
166
+ - test/dummy/config/locales/en.yml
167
+ - test/dummy/config/routes.rb
168
+ - test/dummy/config.ru
169
+ - test/dummy/db/development.sqlite3
170
+ - test/dummy/db/production.sqlite3
171
+ - test/dummy/db/schema.rb
172
+ - test/dummy/db/test.sqlite3
173
+ - test/dummy/log/test.log
174
+ - test/dummy/public/favicon.ico
175
+ - test/dummy/public/javascripts/application.js
176
+ - test/dummy/public/javascripts/controls.js
177
+ - test/dummy/public/javascripts/dragdrop.js
178
+ - test/dummy/public/javascripts/effects.js
179
+ - test/dummy/public/javascripts/prototype.js
180
+ - test/dummy/public/javascripts/rails.js
181
+ - test/dummy/public/stylesheets/exceptions.css
182
+ - test/dummy/Rakefile
183
+ - test/dummy/script/rails
184
+ - test/exceptron_local_custom_test.rb
185
+ - test/exceptron_local_test.rb
186
+ - test/exceptron_public_custom_test.rb
187
+ - test/exceptron_public_test.rb
188
+ - test/test_helper.rb
189
+ - test/views/exceptions_custom/internal_server_error.da.html.erb
190
+ - test/views/exceptions_custom/internal_server_error.json
191
+ - test/views/exceptions_custom/not_found.html
192
+ - test/views/exceptions_custom/not_found.xml
193
+ - test/views/exceptions_custom/not_implemented.html.erb
194
+ - test/views/layouts/exception_test.html.erb
195
+ - test/views/local_exceptions_custom/diagnostics.da.html.erb
196
+ - test/views/local_exceptions_custom/not_implemented.html.erb
197
+ - test/views/local_exceptions_custom/unknown_action.erb