gaffe 1.0.2 → 1.1.0
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/.phare.yml +2 -0
- data/.rubocop.yml +3 -1
- data/.travis.yml +17 -4
- data/Gemfile +2 -0
- data/LICENSE.md +1 -1
- data/README.md +33 -15
- data/gaffe.gemspec +4 -6
- data/gemfiles/{Gemfile.rails-3.2.x → Gemfile.rails-4.2} +1 -1
- data/gemfiles/Gemfile.rails-5.0 +5 -0
- data/lib/gaffe.rb +3 -17
- data/lib/gaffe/errors.rb +4 -4
- data/lib/gaffe/errors_controller_resolver.rb +36 -0
- data/lib/gaffe/version.rb +1 -1
- data/spec/gaffe/errors_controller_resolver_spec.rb +55 -0
- data/spec/gaffe/errors_spec.rb +10 -7
- data/spec/gaffe/gaffe_spec.rb +5 -56
- data/spec/spec_helper.rb +16 -5
- metadata +33 -57
- data/.scss-lint.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a76d88f73a65c01478f10e150f4ec9ef46a9089
|
4
|
+
data.tar.gz: 512a17ddc07b06e40683a8685eacb56950b92205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e87748a54801fea4b59b755a5c52564e1678184309012971042ff4749f3dd04520010365460a73afcadd8d86ce1807a2535074d1ccbe259d66626ae1c47ef86
|
7
|
+
data.tar.gz: 7314dde747616aace314b458bfad68369996971dc08737e81ea3aa284a2b5b5a04a773fdac5f6027588649f911e3d6ddcb533b2c4223082f130137007c4dbfd6
|
data/.phare.yml
ADDED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,14 +1,27 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 1
|
4
|
+
- 2.3.0
|
5
|
+
- 2.1
|
6
|
+
- 2.0
|
7
|
+
|
8
|
+
sudo: false
|
6
9
|
|
7
10
|
gemfile:
|
11
|
+
- gemfiles/Gemfile.rails-4.2
|
8
12
|
- gemfiles/Gemfile.rails-4.0
|
9
|
-
- gemfiles/Gemfile.rails-
|
13
|
+
- gemfiles/Gemfile.rails-5.0
|
14
|
+
|
15
|
+
script:
|
16
|
+
- 'echo "Checking code style" && bundle exec phare'
|
17
|
+
- 'echo "Running specs" && bundle exec rake spec'
|
10
18
|
|
11
|
-
|
19
|
+
matrix:
|
20
|
+
exclude:
|
21
|
+
- rvm: 2.0
|
22
|
+
gemfile: gemfiles/Gemfile.rails-5.0
|
23
|
+
- rvm: 2.1
|
24
|
+
gemfile: gemfiles/Gemfile.rails-5.0
|
12
25
|
|
13
26
|
notifications:
|
14
27
|
hipchat:
|
data/Gemfile
CHANGED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -3,13 +3,12 @@
|
|
3
3
|
<img src="http://i.imgur.com/k9Vo08q.png" alt="gaffe" />
|
4
4
|
</a>
|
5
5
|
<br />
|
6
|
-
Gaffe makes having customized error pages in Rails applications an easy thing.<br /> It takes advantage of a feature present in Rails 3.2 (and 4.0
|
6
|
+
Gaffe makes having customized error pages in Rails applications an easy thing.<br /> It takes advantage of a feature present in Rails 3.2 (and 4.0+, obviously) called <code>exceptions_app</code>.
|
7
7
|
<br /><br />
|
8
|
-
<a href="https://rubygems.org/gems/gaffe"><img src="
|
9
|
-
<a href="https://codeclimate.com/github/mirego/gaffe"><img src="
|
10
|
-
<a href='https://
|
11
|
-
<a href=
|
12
|
-
<a href="https://travis-ci.org/mirego/gaffe"><img src="https://travis-ci.org/mirego/gaffe.png?branch=master" /></a>
|
8
|
+
<a href="https://rubygems.org/gems/gaffe"><img src="http://img.shields.io/gem/v/gaffe.svg" /></a>
|
9
|
+
<a href="https://codeclimate.com/github/mirego/gaffe"><img src="http://img.shields.io/codeclimate/github/mirego/gaffe.svg" /></a>
|
10
|
+
<a href='https://gemnasium.com/mirego/gaffe'><img src="http://img.shields.io/gemnasium/mirego/gaffe.svg" /></a>
|
11
|
+
<a href="https://travis-ci.org/mirego/gaffe"><img src="http://img.shields.io/travis/mirego/gaffe.svg" /></a>
|
13
12
|
</p>
|
14
13
|
|
15
14
|
---
|
@@ -42,7 +41,7 @@ However, if you want to use your own controller:
|
|
42
41
|
```ruby
|
43
42
|
# config/initializers/gaffe.rb
|
44
43
|
Gaffe.configure do |config|
|
45
|
-
config.errors_controller = ErrorsController
|
44
|
+
config.errors_controller = 'ErrorsController'
|
46
45
|
end
|
47
46
|
|
48
47
|
Gaffe.enable!
|
@@ -56,8 +55,8 @@ through JSON and regular errors through HTML pages.
|
|
56
55
|
# config/initializers/gaffe.rb
|
57
56
|
Gaffe.configure do |config|
|
58
57
|
config.errors_controller = {
|
59
|
-
%r[^/api/] => Api::ErrorsController,
|
60
|
-
%r[^/] => ErrorsController
|
58
|
+
%r[^/api/] => 'Api::ErrorsController',
|
59
|
+
%r[^/] => 'ErrorsController'
|
61
60
|
}
|
62
61
|
end
|
63
62
|
|
@@ -77,7 +76,7 @@ class ErrorsController < ApplicationController
|
|
77
76
|
include Gaffe::Errors
|
78
77
|
|
79
78
|
# Make sure anonymous users can see the page
|
80
|
-
|
79
|
+
skip_before_action :authenticate_user!
|
81
80
|
|
82
81
|
# Override 'error' layout
|
83
82
|
layout 'application'
|
@@ -98,7 +97,7 @@ class API::ErrorsController < API::ApplicationController
|
|
98
97
|
include Gaffe::Errors
|
99
98
|
|
100
99
|
# Make sure anonymous users can see the page
|
101
|
-
|
100
|
+
skip_before_action :authenticate_user!
|
102
101
|
|
103
102
|
# Disable layout (your `API::ApplicationController` probably does this already)
|
104
103
|
layout false
|
@@ -107,8 +106,8 @@ class API::ErrorsController < API::ApplicationController
|
|
107
106
|
# plus the exception name and backtrace if we’re in development.
|
108
107
|
def show
|
109
108
|
output = { error: @rescue_response }
|
110
|
-
output.merge! exception: @exception.inspect, backtrace: @exception.backtrace.first(10) if Rails.env.development?
|
111
|
-
render json:
|
109
|
+
output.merge! exception: @exception.inspect, backtrace: @exception.backtrace.first(10) if Rails.env.development? || Rails.env.test?
|
110
|
+
render json: output, status: @status_code
|
112
111
|
end
|
113
112
|
end
|
114
113
|
```
|
@@ -142,7 +141,7 @@ config.action_dispatch.rescue_responses.merge! 'CanCan::AccessDenied' => :forbid
|
|
142
141
|
config.action_dispatch.rescue_responses.merge! 'MyCustomException' => :not_acceptable
|
143
142
|
```
|
144
143
|
|
145
|
-
### Rails development
|
144
|
+
### Rails development environment
|
146
145
|
|
147
146
|
Rails prefers to render its own debug-friendly errors in the `development` environment,
|
148
147
|
which is totally understandable. However, if you want to test Gaffe’s behavior in development
|
@@ -153,6 +152,25 @@ you’ll have to edit the `config/environments/development.rb` file.
|
|
153
152
|
config.consider_all_requests_local = false
|
154
153
|
```
|
155
154
|
|
155
|
+
### Rails test environment
|
156
|
+
|
157
|
+
You also have to configure Rails’ `test` environment so it lets Gaffe handle exceptions
|
158
|
+
in request tests. You’ll have to edit the `config/environments/test.rb` file.
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
# Make Rails use `exceptions_app` in tests
|
162
|
+
config.consider_all_requests_local = false
|
163
|
+
|
164
|
+
# Render exceptions instead of raising them
|
165
|
+
config.action_dispatch.show_exceptions = true
|
166
|
+
```
|
167
|
+
|
168
|
+
Unfortunately, controller tests (called *functional tests* in Rails) do not
|
169
|
+
work with Gaffe, since they only test method calls in the controller class —
|
170
|
+
they do not go through the entire Rack stack to simulate a real HTTP request.
|
171
|
+
|
172
|
+
To test responses sent by Gaffe, you must use *request tests*.
|
173
|
+
|
156
174
|
## Contributors
|
157
175
|
|
158
176
|
* [@remiprev](https://github.com/remiprev)
|
@@ -161,7 +179,7 @@ config.consider_all_requests_local = false
|
|
161
179
|
|
162
180
|
## License
|
163
181
|
|
164
|
-
`Gaffe` is © 2013 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/gaffe/blob/master/LICENSE.md) file.
|
182
|
+
`Gaffe` is © 2013-2015 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/gaffe/blob/master/LICENSE.md) file.
|
165
183
|
|
166
184
|
The mushroom cloud logo is based on [this lovely icon](http://thenounproject.com/noun/mushroom-cloud/#icon-No18596) by [Gokce Ozan](http://thenounproject.com/occultsearcher), from The Noun Project. Used under a [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/) license.
|
167
185
|
|
data/gaffe.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Rémi Prévost', 'Simon Prévost']
|
10
10
|
spec.email = ['rprevost@mirego.com', 'sprevost@mirego.com']
|
11
11
|
spec.description = 'Gaffe handles Rails error pages in a clean, simple way.'
|
12
|
-
spec.summary =
|
12
|
+
spec.summary = spec.description
|
13
13
|
spec.homepage = 'https://github.com/mirego/gaffe'
|
14
14
|
spec.license = "BSD 3-Clause"
|
15
15
|
|
@@ -20,12 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
|
-
spec.add_development_dependency 'rspec', '~>
|
24
|
-
spec.add_development_dependency 'coveralls'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
25
24
|
|
26
|
-
spec.add_development_dependency 'rubocop'
|
27
|
-
spec.add_development_dependency 'scss-lint'
|
25
|
+
spec.add_development_dependency 'rubocop', '>= 0.21'
|
28
26
|
spec.add_development_dependency 'phare'
|
29
27
|
|
30
|
-
spec.add_dependency 'rails', '>=
|
28
|
+
spec.add_dependency 'rails', '>= 4.0.0'
|
31
29
|
end
|
data/lib/gaffe.rb
CHANGED
@@ -3,6 +3,7 @@ require 'gaffe/version'
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'pathname'
|
5
5
|
require 'gaffe/errors'
|
6
|
+
require 'gaffe/errors_controller_resolver'
|
6
7
|
|
7
8
|
module Gaffe
|
8
9
|
# Yield a block to populate @configuration
|
@@ -15,14 +16,6 @@ module Gaffe
|
|
15
16
|
@configuration ||= OpenStruct.new
|
16
17
|
end
|
17
18
|
|
18
|
-
# Return our default controller
|
19
|
-
def self.builtin_errors_controller
|
20
|
-
@builtin_errors_controller ||= begin
|
21
|
-
require 'gaffe/errors_controller'
|
22
|
-
Gaffe::ErrorsController
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
19
|
# Configure Rails to use our code when encountering exceptions
|
27
20
|
def self.enable!
|
28
21
|
Rails.application.config.exceptions_app = lambda do |env|
|
@@ -33,15 +26,8 @@ module Gaffe
|
|
33
26
|
# Return the right errors controller to use for the request that
|
34
27
|
# triggered the error
|
35
28
|
def self.errors_controller_for_request(env)
|
36
|
-
|
37
|
-
|
38
|
-
if controller.is_a?(Hash)
|
39
|
-
controller = controller.find { |pattern, _| env['REQUEST_URI'] =~ pattern }.try(:last)
|
40
|
-
end
|
41
|
-
|
42
|
-
controller ||= builtin_errors_controller
|
43
|
-
|
44
|
-
controller.respond_to?(:constantize) ? controller.constantize : controller
|
29
|
+
resolver = ErrorsControllerResolver.new(env)
|
30
|
+
resolver.resolved_controller
|
45
31
|
end
|
46
32
|
|
47
33
|
# Return the root path of the gem
|
data/lib/gaffe/errors.rb
CHANGED
@@ -3,8 +3,8 @@ module Gaffe
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
|
7
|
-
|
6
|
+
before_action :fetch_exception, only: %w(show)
|
7
|
+
before_action :append_view_paths
|
8
8
|
layout 'error'
|
9
9
|
end
|
10
10
|
|
@@ -17,8 +17,8 @@ module Gaffe
|
|
17
17
|
protected
|
18
18
|
|
19
19
|
def fetch_exception
|
20
|
-
@exception = env['action_dispatch.exception']
|
21
|
-
@status_code = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
|
20
|
+
@exception = request.env['action_dispatch.exception']
|
21
|
+
@status_code = ActionDispatch::ExceptionWrapper.new(request.env, @exception).status_code
|
22
22
|
@rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
|
23
23
|
end
|
24
24
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Gaffe
|
2
|
+
class ErrorsControllerResolver
|
3
|
+
# Accessors
|
4
|
+
attr_reader :controller
|
5
|
+
|
6
|
+
# Constants
|
7
|
+
BUILTIN_CONTROLLER = lambda do
|
8
|
+
require 'gaffe/errors_controller'
|
9
|
+
Gaffe::ErrorsController
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(env)
|
13
|
+
@env = env
|
14
|
+
end
|
15
|
+
|
16
|
+
def resolved_controller
|
17
|
+
# Use the configured controller first
|
18
|
+
controller = Gaffe.configuration.errors_controller
|
19
|
+
|
20
|
+
# Parse the request if multiple controllers are configured
|
21
|
+
controller = request_controller(controller) if controller.is_a?(Hash)
|
22
|
+
|
23
|
+
# Fall back on the builtin errors controller
|
24
|
+
controller ||= BUILTIN_CONTROLLER.call
|
25
|
+
|
26
|
+
# Make sure we return a Class
|
27
|
+
controller.respond_to?(:constantize) ? controller.constantize : controller
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def request_controller(controllers)
|
33
|
+
controllers.find { |pattern, _| @env['REQUEST_URI'] =~ pattern }.try(:last)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/gaffe/version.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gaffe::ErrorsControllerResolver do
|
4
|
+
describe :resolved_controller do
|
5
|
+
let(:resolver) { Gaffe::ErrorsControllerResolver.new(env) }
|
6
|
+
let(:controller) { resolver.resolved_controller }
|
7
|
+
let(:request) { test_request }
|
8
|
+
let(:env) { request.env }
|
9
|
+
|
10
|
+
context 'with custom-defined controller' do
|
11
|
+
before do
|
12
|
+
Gaffe.configure do |config|
|
13
|
+
config.errors_controller = :foo
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it { expect(controller).to eql :foo }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with custom-defined controller that respond to `#constantize`' do
|
21
|
+
before do
|
22
|
+
Gaffe.configure do |config|
|
23
|
+
config.errors_controller = 'String'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it { expect(controller).to eql String }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with multiple custom-defined controllers' do
|
31
|
+
before do
|
32
|
+
Gaffe.configure do |config|
|
33
|
+
config.errors_controller = {
|
34
|
+
%r{^/web/} => :web_controller,
|
35
|
+
%r{^/api/} => :api_controller
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with error coming from matching URL' do
|
41
|
+
let(:env) { request.env.merge 'REQUEST_URI' => '/api/users' }
|
42
|
+
it { expect(controller).to eql :api_controller }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with errors coming from non-matching URL' do
|
46
|
+
let(:env) { request.env.merge 'REQUEST_URI' => '/what' }
|
47
|
+
it { expect(controller).to eql Gaffe::ErrorsController }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'without custom-defined controller' do
|
52
|
+
it { expect(controller).to eql Gaffe::ErrorsController }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/gaffe/errors_spec.rb
CHANGED
@@ -3,16 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe Gaffe::Errors do
|
4
4
|
describe :Actions do
|
5
5
|
describe :show do
|
6
|
-
let(:request) {
|
6
|
+
let(:request) { test_request }
|
7
7
|
let(:env) { request.env.merge 'action_dispatch.exception' => exception }
|
8
|
+
let(:status) { response.first }
|
9
|
+
let(:body) { response.last.body }
|
8
10
|
|
9
|
-
let(:response)
|
10
|
-
|
11
|
+
let(:response) do
|
12
|
+
Gaffe.errors_controller_for_request(env).action(:show).call(env)
|
13
|
+
end
|
11
14
|
|
12
15
|
context 'with builtin exception' do
|
13
16
|
let(:exception) { ActionController::RoutingError.new(:foo) }
|
14
|
-
|
15
|
-
|
17
|
+
it { expect(status).to eql 404 }
|
18
|
+
it { expect(body).to match(/Not Found/) }
|
16
19
|
end
|
17
20
|
|
18
21
|
context 'with custom exception and missing view' do
|
@@ -24,8 +27,8 @@ describe Gaffe::Errors do
|
|
24
27
|
end
|
25
28
|
|
26
29
|
let(:exception) { exception_class.new }
|
27
|
-
|
28
|
-
|
30
|
+
it { expect(status).to eql 500 }
|
31
|
+
it { expect(body).to match(/Internal Server Error/) }
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
data/spec/gaffe/gaffe_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Gaffe do
|
4
4
|
describe :ClassMethods do
|
5
5
|
describe :configure do
|
6
|
-
|
6
|
+
let(:configuration) { Gaffe.configuration }
|
7
7
|
before do
|
8
8
|
Gaffe.configure do |config|
|
9
9
|
config.foo = :bar
|
@@ -11,64 +11,13 @@ describe Gaffe do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
describe :errors_controller_for_request do
|
19
|
-
let(:controller) { Gaffe.errors_controller_for_request(env) }
|
20
|
-
let(:request) { ActionDispatch::TestRequest.new }
|
21
|
-
let(:env) { request.env }
|
22
|
-
|
23
|
-
context 'with custom-defined controller' do
|
24
|
-
before do
|
25
|
-
Gaffe.configure do |config|
|
26
|
-
config.errors_controller = :foo
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it { expect(controller).to eql :foo }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with custom-defined controller that respond to `#constantize`' do
|
34
|
-
before do
|
35
|
-
Gaffe.configure do |config|
|
36
|
-
config.errors_controller = 'String'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it { expect(controller).to eql String }
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with multiple custom-defined controllers' do
|
44
|
-
before do
|
45
|
-
Gaffe.configure do |config|
|
46
|
-
config.errors_controller = {
|
47
|
-
%r[^/web/] => :web_controller,
|
48
|
-
%r[^/api/] => :api_controller
|
49
|
-
}
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'with error coming from matching URL' do
|
54
|
-
let(:env) { request.env.merge 'REQUEST_URI' => '/api/users' }
|
55
|
-
it { expect(controller).to eql :api_controller }
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with errors coming from non-matching URL' do
|
59
|
-
let(:env) { request.env.merge 'REQUEST_URI' => '/what' }
|
60
|
-
it { expect(controller).to eql Gaffe::ErrorsController }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'without custom-defined controller' do
|
65
|
-
it { expect(controller).to eql Gaffe::ErrorsController }
|
66
|
-
end
|
14
|
+
it { expect(configuration.foo).to eql :bar }
|
15
|
+
it { expect(configuration.bar).to eql :foo }
|
67
16
|
end
|
68
17
|
|
69
18
|
describe :enable! do
|
70
|
-
let(:env) {
|
71
|
-
let(:action_double) { double(call:
|
19
|
+
let(:env) { test_request.env }
|
20
|
+
let(:action_double) { double(call: proc { [400, {}, 'SOMETHING WENT WRONG.'] }) }
|
72
21
|
before { Gaffe.enable! }
|
73
22
|
|
74
23
|
specify do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
2
|
|
3
|
-
require 'coveralls'
|
4
|
-
Coveralls.wear!
|
5
|
-
|
6
3
|
require 'rspec'
|
7
4
|
require 'action_controller/railtie'
|
8
5
|
require 'gaffe'
|
9
6
|
|
10
7
|
RSpec.configure do |config|
|
8
|
+
# Disable `should` syntax
|
9
|
+
config.expect_with :rspec do |c|
|
10
|
+
c.syntax = :expect
|
11
|
+
end
|
12
|
+
|
11
13
|
config.before(:each) do
|
12
14
|
# Fake Rails.root
|
13
|
-
Rails.
|
15
|
+
allow(Rails).to receive(:root).and_return(RAILS_ROOT)
|
14
16
|
|
15
17
|
# Fake Rails.application
|
16
|
-
|
18
|
+
application = double('Rails Application', config: OpenStruct.new, env_config: {})
|
19
|
+
allow(Rails).to receive(:application).and_return(application)
|
17
20
|
|
18
21
|
# Make sure we clear memoized variables before each test
|
19
22
|
[:@configuration].each do |variable|
|
@@ -26,5 +29,13 @@ end
|
|
26
29
|
class ApplicationController < ActionController::Base
|
27
30
|
end
|
28
31
|
|
32
|
+
def test_request
|
33
|
+
if Rails::VERSION::MAJOR >= 5
|
34
|
+
ActionDispatch::TestRequest.create
|
35
|
+
else
|
36
|
+
ActionDispatch::TestRequest.new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
29
40
|
# We need Rails.root
|
30
41
|
RAILS_ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaffe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Prévost
|
@@ -9,120 +9,92 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.3'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 3.1.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: coveralls
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
55
|
+
version: 3.1.0
|
70
56
|
- !ruby/object:Gem::Dependency
|
71
57
|
name: rubocop
|
72
58
|
requirement: !ruby/object:Gem::Requirement
|
73
59
|
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - '>='
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: scss-lint
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - '>='
|
60
|
+
- - ">="
|
89
61
|
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
62
|
+
version: '0.21'
|
91
63
|
type: :development
|
92
64
|
prerelease: false
|
93
65
|
version_requirements: !ruby/object:Gem::Requirement
|
94
66
|
requirements:
|
95
|
-
- -
|
67
|
+
- - ">="
|
96
68
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
69
|
+
version: '0.21'
|
98
70
|
- !ruby/object:Gem::Dependency
|
99
71
|
name: phare
|
100
72
|
requirement: !ruby/object:Gem::Requirement
|
101
73
|
requirements:
|
102
|
-
- -
|
74
|
+
- - ">="
|
103
75
|
- !ruby/object:Gem::Version
|
104
76
|
version: '0'
|
105
77
|
type: :development
|
106
78
|
prerelease: false
|
107
79
|
version_requirements: !ruby/object:Gem::Requirement
|
108
80
|
requirements:
|
109
|
-
- -
|
81
|
+
- - ">="
|
110
82
|
- !ruby/object:Gem::Version
|
111
83
|
version: '0'
|
112
84
|
- !ruby/object:Gem::Dependency
|
113
85
|
name: rails
|
114
86
|
requirement: !ruby/object:Gem::Requirement
|
115
87
|
requirements:
|
116
|
-
- -
|
88
|
+
- - ">="
|
117
89
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
90
|
+
version: 4.0.0
|
119
91
|
type: :runtime
|
120
92
|
prerelease: false
|
121
93
|
version_requirements: !ruby/object:Gem::Requirement
|
122
94
|
requirements:
|
123
|
-
- -
|
95
|
+
- - ">="
|
124
96
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
97
|
+
version: 4.0.0
|
126
98
|
description: Gaffe handles Rails error pages in a clean, simple way.
|
127
99
|
email:
|
128
100
|
- rprevost@mirego.com
|
@@ -131,11 +103,11 @@ executables: []
|
|
131
103
|
extensions: []
|
132
104
|
extra_rdoc_files: []
|
133
105
|
files:
|
134
|
-
- .gitignore
|
135
|
-
- .
|
136
|
-
- .
|
137
|
-
- .
|
138
|
-
- .travis.yml
|
106
|
+
- ".gitignore"
|
107
|
+
- ".phare.yml"
|
108
|
+
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
110
|
+
- ".travis.yml"
|
139
111
|
- Gemfile
|
140
112
|
- LICENSE.md
|
141
113
|
- README.md
|
@@ -152,12 +124,15 @@ files:
|
|
152
124
|
- app/views/errors/unprocessable_entity.html.erb
|
153
125
|
- app/views/layouts/error.html.erb
|
154
126
|
- gaffe.gemspec
|
155
|
-
- gemfiles/Gemfile.rails-3.2.x
|
156
127
|
- gemfiles/Gemfile.rails-4.0
|
128
|
+
- gemfiles/Gemfile.rails-4.2
|
129
|
+
- gemfiles/Gemfile.rails-5.0
|
157
130
|
- lib/gaffe.rb
|
158
131
|
- lib/gaffe/errors.rb
|
159
132
|
- lib/gaffe/errors_controller.rb
|
133
|
+
- lib/gaffe/errors_controller_resolver.rb
|
160
134
|
- lib/gaffe/version.rb
|
135
|
+
- spec/gaffe/errors_controller_resolver_spec.rb
|
161
136
|
- spec/gaffe/errors_spec.rb
|
162
137
|
- spec/gaffe/gaffe_spec.rb
|
163
138
|
- spec/spec_helper.rb
|
@@ -171,21 +146,22 @@ require_paths:
|
|
171
146
|
- lib
|
172
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
148
|
requirements:
|
174
|
-
- -
|
149
|
+
- - ">="
|
175
150
|
- !ruby/object:Gem::Version
|
176
151
|
version: '0'
|
177
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
153
|
requirements:
|
179
|
-
- -
|
154
|
+
- - ">="
|
180
155
|
- !ruby/object:Gem::Version
|
181
156
|
version: '0'
|
182
157
|
requirements: []
|
183
158
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.1
|
159
|
+
rubygems_version: 2.5.1
|
185
160
|
signing_key:
|
186
161
|
specification_version: 4
|
187
162
|
summary: Gaffe handles Rails error pages in a clean, simple way.
|
188
163
|
test_files:
|
164
|
+
- spec/gaffe/errors_controller_resolver_spec.rb
|
189
165
|
- spec/gaffe/errors_spec.rb
|
190
166
|
- spec/gaffe/gaffe_spec.rb
|
191
167
|
- spec/spec_helper.rb
|