exception_handler 0.8.0.0 → 0.8.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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +3 -3
  5. data/.travis.yml +6 -0
  6. data/README.md +327 -326
  7. data/app/views/layouts/exception.html.erb +1 -1
  8. data/app/views/layouts/mailer.html.erb +5 -5
  9. data/app/views/layouts/mailer.text.erb +1 -1
  10. data/config/locales/exception_handler.en.yml +1 -1
  11. data/config/routes.rb +42 -42
  12. data/exception_handler.gemspec +1 -0
  13. data/lib/exception_handler/version.rb +1 -1
  14. data/spec/controllers/controller_spec.rb +107 -107
  15. data/spec/dummy/Rakefile +6 -6
  16. data/spec/dummy/app/assets/config/manifest.js +3 -3
  17. data/spec/dummy/app/assets/javascripts/application.js +15 -15
  18. data/spec/dummy/app/assets/javascripts/cable.js +13 -13
  19. data/spec/dummy/app/assets/stylesheets/application.css +15 -15
  20. data/spec/dummy/app/channels/application_cable/channel.rb +4 -4
  21. data/spec/dummy/app/channels/application_cable/connection.rb +4 -4
  22. data/spec/dummy/app/controllers/application_controller.rb +2 -2
  23. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  24. data/spec/dummy/app/jobs/application_job.rb +2 -2
  25. data/spec/dummy/app/mailers/application_mailer.rb +4 -4
  26. data/spec/dummy/app/models/application_record.rb +3 -3
  27. data/spec/dummy/app/views/layouts/application.html.erb +15 -15
  28. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -13
  29. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -1
  30. data/spec/dummy/bin/bundle +3 -3
  31. data/spec/dummy/bin/rails +4 -4
  32. data/spec/dummy/bin/rake +4 -4
  33. data/spec/dummy/bin/setup +36 -36
  34. data/spec/dummy/bin/update +31 -31
  35. data/spec/dummy/bin/yarn +11 -11
  36. data/spec/dummy/config.ru +5 -5
  37. data/spec/dummy/config/application.rb +18 -18
  38. data/spec/dummy/config/boot.rb +5 -5
  39. data/spec/dummy/config/cable.yml +10 -10
  40. data/spec/dummy/config/database.yml +25 -25
  41. data/spec/dummy/config/environment.rb +5 -5
  42. data/spec/dummy/config/environments/development.rb +61 -61
  43. data/spec/dummy/config/environments/production.rb +94 -94
  44. data/spec/dummy/config/environments/test.rb +46 -46
  45. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -8
  46. data/spec/dummy/config/initializers/assets.rb +14 -14
  47. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  48. data/spec/dummy/config/initializers/content_security_policy.rb +25 -25
  49. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -5
  50. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  51. data/spec/dummy/config/initializers/inflections.rb +16 -16
  52. data/spec/dummy/config/initializers/mime_types.rb +4 -4
  53. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  54. data/spec/dummy/config/locales/en.yml +33 -33
  55. data/spec/dummy/config/puma.rb +34 -34
  56. data/spec/dummy/config/routes.rb +3 -3
  57. data/spec/dummy/config/storage.yml +34 -34
  58. data/spec/dummy/package.json +5 -5
  59. data/spec/dummy/public/404.html +67 -67
  60. data/spec/dummy/public/422.html +67 -67
  61. data/spec/dummy/public/500.html +66 -66
  62. data/spec/dummy/spec/rails_helper.rb +57 -57
  63. data/spec/features/asset_spec.rb +61 -61
  64. data/spec/features/config_spec.rb +51 -51
  65. data/spec/features/engine_spec.rb +180 -180
  66. data/spec/mailers/mailer_spec.rb +26 -0
  67. data/spec/models/model_spec.rb +26 -0
  68. data/spec/routing/routing_spec.rb +85 -85
  69. data/spec/spec_helper.rb +101 -93
  70. data/spec/views/views_spec.rb +29 -29
  71. metadata +22 -6
@@ -3,7 +3,7 @@
3
3
  <!-- Head -->
4
4
  <head>
5
5
  <!-- Info -->
6
- <%= content_tag :title, "Error - #{@exception.status} (#{@exception.response.to_s.gsub("_", " ").titleize}) | #{Rails.application.class.parent_name.titleize}" %>
6
+ <%= content_tag :title, "Error - #{@exception.status} (#{@exception.response.to_s.gsub("_", " ").titleize})" %>
7
7
 
8
8
  <!-- Styling -->
9
9
  <%= stylesheet_link_tag :exception_handler %>
@@ -1,5 +1,5 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /></head>
4
- <body><%= yield %></body>
5
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /></head>
4
+ <body><%= yield %></body>
5
+ </html>
@@ -1 +1 @@
1
- <%= yield %>
1
+ <%= yield %>
@@ -22,7 +22,7 @@
22
22
 
23
23
  en:
24
24
  exception_handler:
25
- internal_server_error: "<strong>%{status} Error</strong> %{message}"
25
+ internal_server_error: "<strong>%{status} Error</strong> %{message}"
26
26
 
27
27
  #######################################################################################
28
28
  #######################################################################################
data/config/routes.rb CHANGED
@@ -1,42 +1,42 @@
1
- ########################################
2
- ########################################
3
- ## _____ _ ##
4
- ## | ___ \ | | ##
5
- ## | |_/ /___ _ _| |_ ___ ___ ##
6
- ## | // _ \| | | | __/ _ \/ __| ##
7
- ## | |\ \ (_) | |_| | || __/\__ \ ##
8
- ## \_| \_\___/ \__,_|\__\___||___/ ##
9
- ## ##
10
- ########################################
11
- ########################################
12
-
13
- ## Good resource
14
- ## https://gist.github.com/maxivak/5d428ade54828836e6b6#merge-engine-and-app-routes
15
-
16
- ########################################
17
- ########################################
18
-
19
- ## Routes ##
20
- Rails.application.routes.draw do
21
-
22
- ########################################
23
- ########################################
24
-
25
- # => ExceptionHandler
26
- # => Used to provide error page examples in "dev" mode
27
- if Object.const_defined?('ExceptionHandler') && ExceptionHandler.config.try(:dev)
28
-
29
- # => Items
30
- Rack::Utils::SYMBOL_TO_STATUS_CODE.select{ |key, value| value.to_s.match('\b(?:4[0-9]{2}|5[0-9]{2}|599)\b') }.each do |code, status|
31
- get status.to_s, to: 'exception_handler/exceptions#show', as: code, code: code
32
- end
33
-
34
- end
35
-
36
- ########################################
37
- ########################################
38
-
39
- end
40
-
41
- ########################################
42
- ########################################
1
+ ########################################
2
+ ########################################
3
+ ## _____ _ ##
4
+ ## | ___ \ | | ##
5
+ ## | |_/ /___ _ _| |_ ___ ___ ##
6
+ ## | // _ \| | | | __/ _ \/ __| ##
7
+ ## | |\ \ (_) | |_| | || __/\__ \ ##
8
+ ## \_| \_\___/ \__,_|\__\___||___/ ##
9
+ ## ##
10
+ ########################################
11
+ ########################################
12
+
13
+ ## Good resource
14
+ ## https://gist.github.com/maxivak/5d428ade54828836e6b6#merge-engine-and-app-routes
15
+
16
+ ########################################
17
+ ########################################
18
+
19
+ ## Routes ##
20
+ Rails.application.routes.draw do
21
+
22
+ ########################################
23
+ ########################################
24
+
25
+ # => ExceptionHandler
26
+ # => Used to provide error page examples in "dev" mode
27
+ if Object.const_defined?('ExceptionHandler') && ExceptionHandler.config.try(:dev)
28
+
29
+ # => Items
30
+ Rack::Utils::SYMBOL_TO_STATUS_CODE.select{ |key, value| value.to_s.match('\b(?:4[0-9]{2}|5[0-9]{2}|599)\b') }.each do |code, status|
31
+ get status.to_s, to: 'exception_handler/exceptions#show', as: code, code: code
32
+ end
33
+
34
+ end
35
+
36
+ ########################################
37
+ ########################################
38
+
39
+ end
40
+
41
+ ########################################
42
+ ########################################
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
55
55
  s.add_development_dependency "rake"
56
56
  s.add_development_dependency "rspec"
57
57
  s.add_development_dependency "rspec-rails"
58
+ s.add_development_dependency "coveralls"
58
59
  s.add_development_dependency "sqlite3", ">= 1.3.10"
59
60
 
60
61
  ##############################################################
@@ -15,7 +15,7 @@ module ExceptionHandler
15
15
  MAJOR = 0
16
16
  MINOR = 8
17
17
  TINY = 0
18
- PRE = 0 # "alpha"
18
+ PRE = 1 # "alpha"
19
19
 
20
20
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
21
21
  end
@@ -1,107 +1,107 @@
1
- #####################################################
2
- #####################################################
3
- ## _____ _ _ _ ##
4
- ## / __ \ | | | | | ##
5
- ## | / \/ ___ _ __ | |_ _ __ ___ | | | ___ _ __ ##
6
- ## | | / _ \| '_ \| __| '__/ _ \| | |/ _ \ '__| ##
7
- ## | \__/\ (_) | | | | |_| | | (_) | | | __/ | ##
8
- ## \____/\___/|_| |_|\__|_| \___/|_|_|\___|_| ##
9
- ## ##
10
- #####################################################
11
- #####################################################
12
-
13
- require 'spec_helper'
14
-
15
- ###############################################
16
- ###############################################
17
-
18
- # => ExceptionHandler (Controller)
19
- # => Test erroneous requests under different circumstances
20
- # => Expect the return of 404, 500 (etc) Error Pages
21
- # => Test layout, show action, @exception object and different config options
22
- RSpec.describe ExceptionHandler::ExceptionsController do
23
-
24
- # => General
25
- # => Used to describe the actual Controller class
26
- describe "class" do
27
- subject { controller }
28
- it { should respond_to :show }
29
- end
30
-
31
- #################################
32
- #################################
33
-
34
- # => Layout
35
- # => Expected results & overall views
36
- describe "layout" do
37
- #subject { response.layout }
38
- #it { should be_a String }
39
- end
40
-
41
- #################################
42
- #################################
43
-
44
- # => Response
45
- # => Should deliver 404 / 500 error responses
46
- # => Should deliver appropriate headers, layout etc
47
- describe "response" do
48
-
49
- # => Before
50
- before(:each) { }
51
-
52
- # => 404
53
- context "404" do
54
- subject { response }
55
- it { should have_http_status :ok }
56
-
57
- end
58
-
59
- # => 500
60
- context "500" do
61
- end
62
-
63
- end
64
-
65
- #################################
66
- #################################
67
-
68
- # => Dev Routes
69
- # => Should deliver 404 / 500 error responses
70
- # => Should deliver appropriate headers, layout etc
71
- describe "dev routes" do
72
-
73
- # => Item
74
- before(:context) { ExceptionHandler.config.dev = true }
75
- before(:context) { Rails.application.reload_routes! }
76
-
77
- # => Items
78
- let(:dev) { ExceptionHandler.config.dev }
79
-
80
- # => Config
81
-
82
- # => Pages
83
- # => These are shown when
84
- context "pages" do
85
-
86
- # => Dev Mode
87
- # => Only works with dev enabled
88
- it "has Dev mode enabled" do
89
- expect(dev).to eq(true)
90
- end
91
-
92
- # => The error pages need to return the correct status code
93
- #Rack::Utils::SYMBOL_TO_STATUS_CODE.select{ |key, value| value.to_s.match('\b(?:4[0-9]{2}|5[0-9]{2}|599)\b') }.each do |status,code|
94
- # it "shows #{code.to_s} page" do
95
- # get :show, params: { code: status.to_sym }
96
- # expect(response).to have_http_status status.to_sym
97
- # expect(response.body).to match /404/
98
- # end
99
- #end
100
-
101
- end
102
- end
103
-
104
- end
105
-
106
- ###############################################
107
- ###############################################
1
+ #####################################################
2
+ #####################################################
3
+ ## _____ _ _ _ ##
4
+ ## / __ \ | | | | | ##
5
+ ## | / \/ ___ _ __ | |_ _ __ ___ | | | ___ _ __ ##
6
+ ## | | / _ \| '_ \| __| '__/ _ \| | |/ _ \ '__| ##
7
+ ## | \__/\ (_) | | | | |_| | | (_) | | | __/ | ##
8
+ ## \____/\___/|_| |_|\__|_| \___/|_|_|\___|_| ##
9
+ ## ##
10
+ #####################################################
11
+ #####################################################
12
+
13
+ require 'spec_helper'
14
+
15
+ ###############################################
16
+ ###############################################
17
+
18
+ # => ExceptionHandler (Controller)
19
+ # => Test erroneous requests under different circumstances
20
+ # => Expect the return of 404, 500 (etc) Error Pages
21
+ # => Test layout, show action, @exception object and different config options
22
+ RSpec.describe ExceptionHandler::ExceptionsController do
23
+
24
+ # => General
25
+ # => Used to describe the actual Controller class
26
+ describe "class" do
27
+ subject { controller }
28
+ it { should respond_to :show }
29
+ end
30
+
31
+ #################################
32
+ #################################
33
+
34
+ # => Layout
35
+ # => Expected results & overall views
36
+ describe "layout" do
37
+ #subject { response.layout }
38
+ #it { should be_a String }
39
+ end
40
+
41
+ #################################
42
+ #################################
43
+
44
+ # => Response
45
+ # => Should deliver 404 / 500 error responses
46
+ # => Should deliver appropriate headers, layout etc
47
+ describe "response" do
48
+
49
+ # => Before
50
+ before(:each) { }
51
+
52
+ # => 404
53
+ context "404" do
54
+ subject { response }
55
+ it { should have_http_status :ok }
56
+
57
+ end
58
+
59
+ # => 500
60
+ context "500" do
61
+ end
62
+
63
+ end
64
+
65
+ #################################
66
+ #################################
67
+
68
+ # => Dev Routes
69
+ # => Should deliver 404 / 500 error responses
70
+ # => Should deliver appropriate headers, layout etc
71
+ describe "dev routes" do
72
+
73
+ # => Item
74
+ before(:context) { ExceptionHandler.config.dev = true }
75
+ before(:context) { Rails.application.reload_routes! }
76
+
77
+ # => Items
78
+ let(:dev) { ExceptionHandler.config.dev }
79
+
80
+ # => Config
81
+
82
+ # => Pages
83
+ # => These are shown when
84
+ context "pages" do
85
+
86
+ # => Dev Mode
87
+ # => Only works with dev enabled
88
+ it "has Dev mode enabled" do
89
+ expect(dev).to eq(true)
90
+ end
91
+
92
+ # => The error pages need to return the correct status code
93
+ #Rack::Utils::SYMBOL_TO_STATUS_CODE.select{ |key, value| value.to_s.match('\b(?:4[0-9]{2}|5[0-9]{2}|599)\b') }.each do |status,code|
94
+ # it "shows #{code.to_s} page" do
95
+ # get :show, params: { code: status.to_sym }
96
+ # expect(response).to have_http_status status.to_sym
97
+ # expect(response.body).to match /404/
98
+ # end
99
+ #end
100
+
101
+ end
102
+ end
103
+
104
+ end
105
+
106
+ ###############################################
107
+ ###############################################
data/spec/dummy/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require_relative 'config/application'
5
-
6
- Rails.application.load_tasks
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -1,3 +1,3 @@
1
- //= link_tree ../images
2
- //= link_directory ../javascripts .js
3
- //= link_directory ../stylesheets .css
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -1,15 +1,15 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require rails-ujs
14
- //= require activestorage
15
- //= require_tree .
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require activestorage
15
+ //= require_tree .
@@ -1,13 +1,13 @@
1
- // Action Cable provides the framework to deal with WebSockets in Rails.
2
- // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
- //
4
- //= require action_cable
5
- //= require_self
6
- //= require_tree ./channels
7
-
8
- (function() {
9
- this.App || (this.App = {});
10
-
11
- App.cable = ActionCable.createConsumer();
12
-
13
- }).call(this);
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -1,15 +1,15 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */