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.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +1 -0
- data/.rspec +3 -3
- data/.travis.yml +6 -0
- data/README.md +327 -326
- data/app/views/layouts/exception.html.erb +1 -1
- data/app/views/layouts/mailer.html.erb +5 -5
- data/app/views/layouts/mailer.text.erb +1 -1
- data/config/locales/exception_handler.en.yml +1 -1
- data/config/routes.rb +42 -42
- data/exception_handler.gemspec +1 -0
- data/lib/exception_handler/version.rb +1 -1
- data/spec/controllers/controller_spec.rb +107 -107
- data/spec/dummy/Rakefile +6 -6
- data/spec/dummy/app/assets/config/manifest.js +3 -3
- data/spec/dummy/app/assets/javascripts/application.js +15 -15
- data/spec/dummy/app/assets/javascripts/cable.js +13 -13
- data/spec/dummy/app/assets/stylesheets/application.css +15 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -4
- data/spec/dummy/app/controllers/application_controller.rb +2 -2
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/jobs/application_job.rb +2 -2
- data/spec/dummy/app/mailers/application_mailer.rb +4 -4
- data/spec/dummy/app/models/application_record.rb +3 -3
- data/spec/dummy/app/views/layouts/application.html.erb +15 -15
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -1
- data/spec/dummy/bin/bundle +3 -3
- data/spec/dummy/bin/rails +4 -4
- data/spec/dummy/bin/rake +4 -4
- data/spec/dummy/bin/setup +36 -36
- data/spec/dummy/bin/update +31 -31
- data/spec/dummy/bin/yarn +11 -11
- data/spec/dummy/config.ru +5 -5
- data/spec/dummy/config/application.rb +18 -18
- data/spec/dummy/config/boot.rb +5 -5
- data/spec/dummy/config/cable.yml +10 -10
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +61 -61
- data/spec/dummy/config/environments/production.rb +94 -94
- data/spec/dummy/config/environments/test.rb +46 -46
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -8
- data/spec/dummy/config/initializers/assets.rb +14 -14
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -25
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
- data/spec/dummy/config/initializers/inflections.rb +16 -16
- data/spec/dummy/config/initializers/mime_types.rb +4 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +33 -33
- data/spec/dummy/config/puma.rb +34 -34
- data/spec/dummy/config/routes.rb +3 -3
- data/spec/dummy/config/storage.yml +34 -34
- data/spec/dummy/package.json +5 -5
- data/spec/dummy/public/404.html +67 -67
- data/spec/dummy/public/422.html +67 -67
- data/spec/dummy/public/500.html +66 -66
- data/spec/dummy/spec/rails_helper.rb +57 -57
- data/spec/features/asset_spec.rb +61 -61
- data/spec/features/config_spec.rb +51 -51
- data/spec/features/engine_spec.rb +180 -180
- data/spec/mailers/mailer_spec.rb +26 -0
- data/spec/models/model_spec.rb +26 -0
- data/spec/routing/routing_spec.rb +85 -85
- data/spec/spec_helper.rb +101 -93
- data/spec/views/views_spec.rb +29 -29
- metadata +22 -6
@@ -0,0 +1,26 @@
|
|
1
|
+
#####################################################
|
2
|
+
#####################################################
|
3
|
+
## __ __ _ _ ##
|
4
|
+
## | \/ | (_) | ##
|
5
|
+
## | . . | __ _ _| | ___ _ __ ##
|
6
|
+
## | |\/| |/ _` | | |/ _ \ '__| ##
|
7
|
+
## | | | | (_| | | | __/ | ##
|
8
|
+
## \_| |_/\__,_|_|_|\___|_| ##
|
9
|
+
## ##
|
10
|
+
#####################################################
|
11
|
+
#####################################################
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
###############################################
|
16
|
+
###############################################
|
17
|
+
|
18
|
+
# => ExceptionHandler (Mailer)
|
19
|
+
# => Check veracity of methods / returned results
|
20
|
+
# =>
|
21
|
+
RSpec.describe ExceptionHandler::ExceptionMailer do
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
###############################################
|
26
|
+
###############################################
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#####################################################
|
2
|
+
#####################################################
|
3
|
+
## __ __ _ _ ##
|
4
|
+
## | \/ | | | | | ##
|
5
|
+
## | . . | ___ __| | ___| | ##
|
6
|
+
## | |\/| |/ _ \ / _` |/ _ \ | ##
|
7
|
+
## | | | | (_) | (_| | __/ | ##
|
8
|
+
## \_| |_/\___/ \__,_|\___|_| ##
|
9
|
+
## ##
|
10
|
+
#####################################################
|
11
|
+
#####################################################
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
###############################################
|
16
|
+
###############################################
|
17
|
+
|
18
|
+
# => ExceptionHandler (Model)
|
19
|
+
# => Check veracity of methods / returned results
|
20
|
+
# =>
|
21
|
+
RSpec.describe ExceptionHandler::Exception do
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
###############################################
|
26
|
+
###############################################
|
@@ -1,85 +1,85 @@
|
|
1
|
-
###############################################
|
2
|
-
###############################################
|
3
|
-
## _____ _ ##
|
4
|
-
## | ___ \ | | ##
|
5
|
-
## | |_/ /___ _ _| |_ ___ ___ ##
|
6
|
-
## | // _ \| | | | __/ _ \/ __| ##
|
7
|
-
## | |\ \ (_) | |_| | || __/\__ \ ##
|
8
|
-
## \_| \_\___/ \__,_|\__\___||___/ ##
|
9
|
-
## ##
|
10
|
-
###############################################
|
11
|
-
###############################################
|
12
|
-
|
13
|
-
require 'spec_helper'
|
14
|
-
|
15
|
-
###############################################
|
16
|
-
###############################################
|
17
|
-
|
18
|
-
# => Routes (base)
|
19
|
-
# => Test underlying routes + engine routes
|
20
|
-
RSpec.describe 'ExceptionHandler::Engine.routes' do
|
21
|
-
|
22
|
-
#############################################
|
23
|
-
#############################################
|
24
|
-
|
25
|
-
# => Let (config)
|
26
|
-
let(:dev) { ExceptionHandler.config.dev }
|
27
|
-
|
28
|
-
#############################################
|
29
|
-
#############################################
|
30
|
-
|
31
|
-
# => Rails application Routes
|
32
|
-
# => Should be routable WITH dev option
|
33
|
-
# => Should not be routable WITHOUT dev option
|
34
|
-
['Rails.application.routes', 'ExceptionHandler::Engine.routes'].each do |item|
|
35
|
-
|
36
|
-
# => Different types of route
|
37
|
-
# => Shouldn't have any routes for engine
|
38
|
-
context item do
|
39
|
-
|
40
|
-
# => Routes
|
41
|
-
routes { eval item }
|
42
|
-
|
43
|
-
# => Dev mode
|
44
|
-
context "✔️ dev mode" do
|
45
|
-
subject { dev }
|
46
|
-
before { ExceptionHandler.config.dev = true }
|
47
|
-
before { Rails.application.reload_routes! }
|
48
|
-
|
49
|
-
it { should eq(true) }
|
50
|
-
it "has exception routes" do
|
51
|
-
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|
|
52
|
-
if item == 'Rails.application.routes'
|
53
|
-
expect(:get => code.to_s).to route_to(:controller => "exception_handler/exceptions", :action => "show", :code => status.to_sym)
|
54
|
-
else
|
55
|
-
expect(:get => code.to_s).not_to be_routable
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
# => Non Dev mode
|
63
|
-
context "❌ dev mode" do
|
64
|
-
subject { dev }
|
65
|
-
before { ExceptionHandler.config.dev = false }
|
66
|
-
before { Rails.application.reload_routes! }
|
67
|
-
|
68
|
-
it { should_not eq(true) }
|
69
|
-
it "does not have exception routes" do
|
70
|
-
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|
|
71
|
-
expect(:get => code.to_s).not_to be_routable
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
#############################################
|
80
|
-
#############################################
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
###############################################
|
85
|
-
###############################################
|
1
|
+
###############################################
|
2
|
+
###############################################
|
3
|
+
## _____ _ ##
|
4
|
+
## | ___ \ | | ##
|
5
|
+
## | |_/ /___ _ _| |_ ___ ___ ##
|
6
|
+
## | // _ \| | | | __/ _ \/ __| ##
|
7
|
+
## | |\ \ (_) | |_| | || __/\__ \ ##
|
8
|
+
## \_| \_\___/ \__,_|\__\___||___/ ##
|
9
|
+
## ##
|
10
|
+
###############################################
|
11
|
+
###############################################
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
###############################################
|
16
|
+
###############################################
|
17
|
+
|
18
|
+
# => Routes (base)
|
19
|
+
# => Test underlying routes + engine routes
|
20
|
+
RSpec.describe 'ExceptionHandler::Engine.routes' do
|
21
|
+
|
22
|
+
#############################################
|
23
|
+
#############################################
|
24
|
+
|
25
|
+
# => Let (config)
|
26
|
+
let(:dev) { ExceptionHandler.config.dev }
|
27
|
+
|
28
|
+
#############################################
|
29
|
+
#############################################
|
30
|
+
|
31
|
+
# => Rails application Routes
|
32
|
+
# => Should be routable WITH dev option
|
33
|
+
# => Should not be routable WITHOUT dev option
|
34
|
+
['Rails.application.routes', 'ExceptionHandler::Engine.routes'].each do |item|
|
35
|
+
|
36
|
+
# => Different types of route
|
37
|
+
# => Shouldn't have any routes for engine
|
38
|
+
context item do
|
39
|
+
|
40
|
+
# => Routes
|
41
|
+
routes { eval item }
|
42
|
+
|
43
|
+
# => Dev mode
|
44
|
+
context "✔️ dev mode" do
|
45
|
+
subject { dev }
|
46
|
+
before { ExceptionHandler.config.dev = true }
|
47
|
+
before { Rails.application.reload_routes! }
|
48
|
+
|
49
|
+
it { should eq(true) }
|
50
|
+
it "has exception routes" do
|
51
|
+
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|
|
52
|
+
if item == 'Rails.application.routes'
|
53
|
+
expect(:get => code.to_s).to route_to(:controller => "exception_handler/exceptions", :action => "show", :code => status.to_sym)
|
54
|
+
else
|
55
|
+
expect(:get => code.to_s).not_to be_routable
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
# => Non Dev mode
|
63
|
+
context "❌ dev mode" do
|
64
|
+
subject { dev }
|
65
|
+
before { ExceptionHandler.config.dev = false }
|
66
|
+
before { Rails.application.reload_routes! }
|
67
|
+
|
68
|
+
it { should_not eq(true) }
|
69
|
+
it "does not have exception routes" do
|
70
|
+
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|
|
71
|
+
expect(:get => code.to_s).not_to be_routable
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
#############################################
|
80
|
+
#############################################
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
###############################################
|
85
|
+
###############################################
|
data/spec/spec_helper.rb
CHANGED
@@ -1,93 +1,101 @@
|
|
1
|
-
###############################################
|
2
|
-
###############################################
|
3
|
-
## _____ _____ ##
|
4
|
-
## | ___ \/ ___| ##
|
5
|
-
## | |_/ /\ `--. _ __ ___ ___ ##
|
6
|
-
## | / `--. \ '_ \ / _ \/ __| ##
|
7
|
-
## | |\ \ /\__/ / |_) | __/ (__ ##
|
8
|
-
## \_| \_|\____/| .__/ \___|\___| ##
|
9
|
-
## | | ##
|
10
|
-
## |_| ##
|
11
|
-
###############################################
|
12
|
-
###############################################
|
13
|
-
|
14
|
-
# =>
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
#
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
config.
|
81
|
-
|
82
|
-
#
|
83
|
-
config.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
config.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
1
|
+
###############################################
|
2
|
+
###############################################
|
3
|
+
## _____ _____ ##
|
4
|
+
## | ___ \/ ___| ##
|
5
|
+
## | |_/ /\ `--. _ __ ___ ___ ##
|
6
|
+
## | / `--. \ '_ \ / _ \/ __| ##
|
7
|
+
## | |\ \ /\__/ / |_) | __/ (__ ##
|
8
|
+
## \_| \_|\____/| .__/ \___|\___| ##
|
9
|
+
## | | ##
|
10
|
+
## |_| ##
|
11
|
+
###############################################
|
12
|
+
###############################################
|
13
|
+
|
14
|
+
# => Coveralls
|
15
|
+
# => https://docs.coveralls.io/
|
16
|
+
require 'coveralls'
|
17
|
+
Coveralls.wear!('rails')
|
18
|
+
|
19
|
+
###############################################
|
20
|
+
###############################################
|
21
|
+
|
22
|
+
# => Helper
|
23
|
+
require 'spec_helper'
|
24
|
+
|
25
|
+
# => ENV
|
26
|
+
ENV["RAILS_ENV"] ||= "test"
|
27
|
+
|
28
|
+
# => Rails
|
29
|
+
require_relative './dummy/config/environment'
|
30
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
31
|
+
|
32
|
+
# => RSpec
|
33
|
+
require 'rspec/rails'
|
34
|
+
|
35
|
+
# => Environment
|
36
|
+
ActiveRecord::Migrator.migrations_paths = [File.expand_path("./dummy/db/migrate", __dir__)]
|
37
|
+
|
38
|
+
# => Gem (to test)
|
39
|
+
require 'exception_handler'
|
40
|
+
|
41
|
+
###############################################
|
42
|
+
###############################################
|
43
|
+
|
44
|
+
# => ActiveRecord
|
45
|
+
ActiveRecord::Migration.maintain_test_schema!
|
46
|
+
|
47
|
+
# Load fixtures from the engine
|
48
|
+
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
49
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
|
50
|
+
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
51
|
+
ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
|
52
|
+
ActiveSupport::TestCase.fixtures :all
|
53
|
+
end
|
54
|
+
|
55
|
+
###############################################
|
56
|
+
###############################################
|
57
|
+
|
58
|
+
#=> Custom Matchers
|
59
|
+
RSpec::Matchers.define :be_boolean do
|
60
|
+
match do |value|
|
61
|
+
[true, false].include? value
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
###############################################
|
66
|
+
###############################################
|
67
|
+
|
68
|
+
# => http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
69
|
+
RSpec.configure do |config|
|
70
|
+
|
71
|
+
# rspec-expectations config goes here. You can use an alternate
|
72
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
73
|
+
# assertions if you prefer.
|
74
|
+
config.expect_with :rspec do |expectations|
|
75
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
76
|
+
expectations.syntax = :expect
|
77
|
+
end
|
78
|
+
|
79
|
+
# Enable flags like --only-failures and --next-failure
|
80
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
81
|
+
|
82
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
83
|
+
config.disable_monkey_patching!
|
84
|
+
|
85
|
+
# => Rails (Fixtures etc)
|
86
|
+
config.infer_spec_type_from_file_location!
|
87
|
+
config.filter_rails_from_backtrace!
|
88
|
+
config.order = :random
|
89
|
+
|
90
|
+
# => Asset Precompile
|
91
|
+
config.before(:suite) do
|
92
|
+
Rails.application.load_tasks
|
93
|
+
Rake::Task["assets:precompile"].invoke
|
94
|
+
end
|
95
|
+
|
96
|
+
config.after(:suite) do
|
97
|
+
Rails.application.load_tasks
|
98
|
+
Rake::Task["assets:clobber"].invoke
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/spec/views/views_spec.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
###############################################
|
2
|
-
###############################################
|
3
|
-
## _ _ _ ##
|
4
|
-
## | | | (_) ##
|
5
|
-
## | | | |_ _____ _____ ##
|
6
|
-
## | | | | |/ _ \ \ /\ / / __| ##
|
7
|
-
## \ \_/ / | __/\ V V /\__ \ ##
|
8
|
-
## \___/|_|\___| \_/\_/ |___/ ##
|
9
|
-
## ##
|
10
|
-
###############################################
|
11
|
-
###############################################
|
12
|
-
|
13
|
-
require 'spec_helper'
|
14
|
-
|
15
|
-
###############################################
|
16
|
-
###############################################
|
17
|
-
|
18
|
-
# => ExceptionHandler (Views)
|
19
|
-
# => Determine views / layout for different exceptions
|
20
|
-
# => Needs to explain exactly what users is doing to see (request.status, message etc)
|
21
|
-
# => Needs to include 404/500 dev routes
|
22
|
-
RSpec.describe "ExceptionHandler Views" do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
###############################################
|
29
|
-
###############################################
|
1
|
+
###############################################
|
2
|
+
###############################################
|
3
|
+
## _ _ _ ##
|
4
|
+
## | | | (_) ##
|
5
|
+
## | | | |_ _____ _____ ##
|
6
|
+
## | | | | |/ _ \ \ /\ / / __| ##
|
7
|
+
## \ \_/ / | __/\ V V /\__ \ ##
|
8
|
+
## \___/|_|\___| \_/\_/ |___/ ##
|
9
|
+
## ##
|
10
|
+
###############################################
|
11
|
+
###############################################
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
###############################################
|
16
|
+
###############################################
|
17
|
+
|
18
|
+
# => ExceptionHandler (Views)
|
19
|
+
# => Determine views / layout for different exceptions
|
20
|
+
# => Needs to explain exactly what users is doing to see (request.status, message etc)
|
21
|
+
# => Needs to include 404/500 dev routes
|
22
|
+
RSpec.describe "ExceptionHandler Views" do
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
###############################################
|
29
|
+
###############################################
|