kinetic_cafe_error 1.0.1 → 1.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/History.rdoc +29 -2
- data/Manifest.txt +13 -5
- data/app/controllers/concerns/kinetic_cafe/error_handler.rb +2 -2
- data/app/views/kinetic_cafe_error/_table.html.erb +12 -0
- data/app/views/kinetic_cafe_error/_table.html.haml +8 -0
- data/app/views/kinetic_cafe_error/_table.html.slim +8 -0
- data/app/views/kinetic_cafe_error/page.html.erb +9 -0
- data/app/views/kinetic_cafe_error/page.html.haml +8 -0
- data/app/views/kinetic_cafe_error/page.html.slim +8 -0
- data/config/i18n-tasks.yml.erb +111 -0
- data/config/locales/kinetic_cafe_error.en-CA.yml +14 -0
- data/config/locales/kinetic_cafe_error.en-UK.yml +14 -0
- data/config/locales/kinetic_cafe_error.en-US.yml +14 -0
- data/config/locales/kinetic_cafe_error.en.yml +5 -12
- data/config/locales/{kinetic_cafe_error.fr_ca.yml → kinetic_cafe_error.fr-CA.yml} +4 -11
- data/config/locales/kinetic_cafe_error.fr.yml +5 -12
- data/lib/kinetic_cafe/error.rb +2 -1
- data/lib/kinetic_cafe/error/minitest.rb +68 -0
- data/lib/kinetic_cafe/error_rspec.rb +49 -0
- metadata +17 -9
- data/app/views/kinetic_cafe/error/page.html.erb +0 -8
- data/config/locales/kinetic_cafe_error.en_ca.yml +0 -21
- data/config/locales/kinetic_cafe_error.en_uk.yml +0 -21
- data/config/locales/kinetic_cafe_error.en_us.yml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be8bfda8e64ddea25cca49dd080dacfe1b489690
|
4
|
+
data.tar.gz: ada56cc846a9262dca8941335a32d290d29aa7ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811a51c61090c41d0ec80e7abf28fd3bdeb61852a8031d2c4159487d62562df9a81cf3f30ccfc0c3aa4e41be99f020ee03a6100ce26ef809ca8a1bfd03304dc6
|
7
|
+
data.tar.gz: 3ba9c1634d770fe886f268c085ddff9c941e5d1cd18b49f723ce71d20fd9bd7fe757825637f607e9aad72c4008aca011e614c16f7b9b88469938ff6e7ea2f0bb
|
data/History.rdoc
CHANGED
@@ -1,7 +1,34 @@
|
|
1
|
+
=== 1.1 / 2015-06-05
|
2
|
+
|
3
|
+
* 7 minor enhancements
|
4
|
+
|
5
|
+
* Added Minitest assertions and expectations.
|
6
|
+
* Added Rspec expectation matchers.
|
7
|
+
* Changed the error table to be a partial and renamed keys to support this
|
8
|
+
change (kinetic_cafe_error/_table.html.*). Removed the previous key. Now
|
9
|
+
an error is nominally embeddable in your own views without being a full
|
10
|
+
page.
|
11
|
+
* Added HAML templates.
|
12
|
+
* Added Slim templates.
|
13
|
+
* Move error page to kinetic_cafe_error/page.html.* instead of
|
14
|
+
kinetic_cafe/error/page.html.*. This could be a breaking change, but I
|
15
|
+
consider it low risk.
|
16
|
+
* Added KineticCafe::Error#code as an alias for KineticCafe::Error#i18n_key.
|
17
|
+
|
18
|
+
* 2 minor bugfixes:
|
19
|
+
|
20
|
+
* The en and fr translation files were reporting en-CA and fr-CA as their
|
21
|
+
locales, which is incorrect.
|
22
|
+
|
23
|
+
* Renamed locale files to better match their names to their locales. The
|
24
|
+
locale is not en_ca, but en-CA.
|
25
|
+
|
1
26
|
=== 1.0.1 / 2015-05-27
|
2
27
|
|
3
|
-
*
|
4
|
-
|
28
|
+
* 1 minor bugfix
|
29
|
+
|
30
|
+
* Mac OS X is not case-sensitive and I do not currently have Rails-specific
|
31
|
+
tests.
|
5
32
|
|
6
33
|
=== 1.0.0 / 2015-05-27
|
7
34
|
|
data/Manifest.txt
CHANGED
@@ -9,16 +9,24 @@ Manifest.txt
|
|
9
9
|
README.rdoc
|
10
10
|
Rakefile
|
11
11
|
app/controllers/concerns/kinetic_cafe/error_handler.rb
|
12
|
-
app/views/
|
12
|
+
app/views/kinetic_cafe_error/_table.html.erb
|
13
|
+
app/views/kinetic_cafe_error/_table.html.haml
|
14
|
+
app/views/kinetic_cafe_error/_table.html.slim
|
15
|
+
app/views/kinetic_cafe_error/page.html.erb
|
16
|
+
app/views/kinetic_cafe_error/page.html.haml
|
17
|
+
app/views/kinetic_cafe_error/page.html.slim
|
18
|
+
config/i18n-tasks.yml.erb
|
19
|
+
config/locales/kinetic_cafe_error.en-CA.yml
|
20
|
+
config/locales/kinetic_cafe_error.en-UK.yml
|
21
|
+
config/locales/kinetic_cafe_error.en-US.yml
|
13
22
|
config/locales/kinetic_cafe_error.en.yml
|
14
|
-
config/locales/kinetic_cafe_error.
|
15
|
-
config/locales/kinetic_cafe_error.en_uk.yml
|
16
|
-
config/locales/kinetic_cafe_error.en_us.yml
|
23
|
+
config/locales/kinetic_cafe_error.fr-CA.yml
|
17
24
|
config/locales/kinetic_cafe_error.fr.yml
|
18
|
-
config/locales/kinetic_cafe_error.fr_ca.yml
|
19
25
|
lib/kinetic_cafe/error.rb
|
26
|
+
lib/kinetic_cafe/error/minitest.rb
|
20
27
|
lib/kinetic_cafe/error_dsl.rb
|
21
28
|
lib/kinetic_cafe/error_engine.rb
|
29
|
+
lib/kinetic_cafe/error_rspec.rb
|
22
30
|
lib/kinetic_cafe_error.rb
|
23
31
|
test/test_helper.rb
|
24
32
|
test/test_kinetic_cafe_error.rb
|
@@ -31,11 +31,11 @@ module KineticCafe::ErrorHandler
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
# Render the +error+ as HTML. Uses the template +
|
34
|
+
# Render the +error+ as HTML. Uses the template +kinetic_cafe_error/page+
|
35
35
|
# with +error+ passed as a local of the same name. The render status is set
|
36
36
|
# to <tt>error.status</tt>.
|
37
37
|
def kinetic_cafe_error_render_html(error)
|
38
|
-
render template: '
|
38
|
+
render template: 'kinetic_cafe_error/page', locals: { error: error },
|
39
39
|
status: error.status
|
40
40
|
end
|
41
41
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<table class='kcerror'>
|
2
|
+
<tbody>
|
3
|
+
<tr>
|
4
|
+
<th><%= I18n.t('kinetic_cafe_error.table.header.status') %></th>
|
5
|
+
<td><%= error.status %></td>
|
6
|
+
</tr>
|
7
|
+
<tr>
|
8
|
+
<th><%= I18n.t('kinetic_cafe_error.table.header.code') %></th>
|
9
|
+
<td><%= error.code %></td>
|
10
|
+
</tr>
|
11
|
+
</tbody>
|
12
|
+
</table>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<h2><%= I18n.t('kinetic_cafe_error.page.title') %></h2>
|
2
|
+
|
3
|
+
<% unless error.header_only? || error.internal? -%>
|
4
|
+
<blockquote><%= error.i18n_message %></blockquote>
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
<%= I18n.t('kinetic_cafe_error.page.body_html') %>
|
8
|
+
|
9
|
+
<%= render partial: 'kinetic_cafe_error/table', locals: { error: error } %>
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# i18n-tasks finds and manages missing and unused translations:
|
2
|
+
# https://github.com/glebm/i18n-tasks
|
3
|
+
|
4
|
+
# The "main" locale.
|
5
|
+
base_locale: en-CA
|
6
|
+
## All available locales are inferred from the data by default. Alternatively,
|
7
|
+
## specify them explicitly:
|
8
|
+
# locales: [es, fr]
|
9
|
+
|
10
|
+
## Reporting locale, default: en. Available: en, ru.
|
11
|
+
internal_locale: en
|
12
|
+
|
13
|
+
## Read and write translations.
|
14
|
+
data:
|
15
|
+
## Translations are read from the file system. Supported format: YAML, JSON.
|
16
|
+
## Provide a custom adapter:
|
17
|
+
# adapter: I18n::Tasks::Data::FileSystem
|
18
|
+
|
19
|
+
# Locale files or `File.find` patterns where translations are read from:
|
20
|
+
read:
|
21
|
+
- config/locales/*.%{locale}.yml
|
22
|
+
# <%# - <%= %x(bundle show aldo-datahub-kinetic-cafe-errors).chomp %1>/config/locales/*.%{locale}.yml %>
|
23
|
+
# <%# - <%= %x(bundle show kinetic_cafe_error).chomp %1>/config/locales/*.%{locale}.yml %>
|
24
|
+
|
25
|
+
# Locale files to write new keys to, based on a list of key pattern => file
|
26
|
+
# rules. Matched from top to bottom:
|
27
|
+
# `i18n-tasks normalize -p` will force move the keys according to these rules
|
28
|
+
write:
|
29
|
+
## For example, write devise and simple form keys to their respective files:
|
30
|
+
- - '{kinetic_cafe_error}.*'
|
31
|
+
- 'config/locales/missing-\1.%{locale}.yml'
|
32
|
+
## Catch-all.
|
33
|
+
- config/locales/missing.%{locale}.yml
|
34
|
+
|
35
|
+
## Specify the router (see Readme for details). Valid values:
|
36
|
+
## conservative_router, pattern_router, or a custom class.
|
37
|
+
# router: convervative_router
|
38
|
+
|
39
|
+
yaml:
|
40
|
+
write:
|
41
|
+
# do not wrap lines at 80 characters
|
42
|
+
line_width: 90
|
43
|
+
# line_width: -1
|
44
|
+
|
45
|
+
## Pretty-print JSON:
|
46
|
+
# json:
|
47
|
+
# write:
|
48
|
+
# indent: ' '
|
49
|
+
# space: ' '
|
50
|
+
# object_nl: "\n"
|
51
|
+
# array_nl: "\n"
|
52
|
+
|
53
|
+
# Find translate calls
|
54
|
+
search:
|
55
|
+
## Paths or `File.find` patterns to search in:
|
56
|
+
# paths:
|
57
|
+
# - app/
|
58
|
+
|
59
|
+
## Root directories for relative keys resolution.
|
60
|
+
# relative_roots:
|
61
|
+
# - app/views
|
62
|
+
# - app/controllers
|
63
|
+
# - app/helpers
|
64
|
+
# - app/presenters
|
65
|
+
|
66
|
+
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
|
67
|
+
## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
|
68
|
+
exclude:
|
69
|
+
- app/assets/images
|
70
|
+
- app/assets/fonts
|
71
|
+
|
72
|
+
## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
|
73
|
+
## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
|
74
|
+
# include: ["*.rb", "*.html.slim"]
|
75
|
+
|
76
|
+
## Default scanner finds t() and I18n.t() calls.
|
77
|
+
# scanner: I18n::Tasks::Scanners::PatternWithScopeScanner
|
78
|
+
|
79
|
+
## Google Translate
|
80
|
+
# translation:
|
81
|
+
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
|
82
|
+
# api_key: "AbC-dEf5"
|
83
|
+
|
84
|
+
## Do not consider these keys missing:
|
85
|
+
# ignore_missing:
|
86
|
+
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
|
87
|
+
# - '{devise,simple_form}.*'
|
88
|
+
|
89
|
+
## Consider these keys used:
|
90
|
+
# ignore_unused:
|
91
|
+
# - 'activerecord.attributes.*'
|
92
|
+
# - '{devise,kaminari,will_paginate}.*'
|
93
|
+
# - 'simple_form.{yes,no}'
|
94
|
+
# - 'simple_form.{placeholders,hints,labels}.*'
|
95
|
+
# - 'simple_form.{error_notification,required}.:'
|
96
|
+
|
97
|
+
## Exclude these keys from the `i18n-tasks eq-base' report:
|
98
|
+
ignore_eq_base:
|
99
|
+
all:
|
100
|
+
- kinetic_cafe_error.table.header.code
|
101
|
+
|
102
|
+
# fr-CA,fr:
|
103
|
+
en-UK,en-US,en:
|
104
|
+
- kinetic_cafe_error.page.body_html
|
105
|
+
- kinetic_cafe_error.page.error_table_html
|
106
|
+
- kinetic_cafe_error.page.title
|
107
|
+
- kinetic_cafe_error.table.header.status
|
108
|
+
|
109
|
+
## Ignore these keys completely:
|
110
|
+
# ignore:
|
111
|
+
# - kaminari.*
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en-CA:
|
2
|
+
kinetic_cafe_error:
|
3
|
+
page:
|
4
|
+
title: >-
|
5
|
+
An error occurred.
|
6
|
+
body_html: |
|
7
|
+
<p>The person responsible has been informed.</p>
|
8
|
+
<p>I’m not allowed to say anything else.</p>
|
9
|
+
<p>…</p>
|
10
|
+
<p>OK. Just for you, here’s a bit more:</p>
|
11
|
+
table:
|
12
|
+
header:
|
13
|
+
status: Status
|
14
|
+
code: Code
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en-UK:
|
2
|
+
kinetic_cafe_error:
|
3
|
+
page:
|
4
|
+
title: >-
|
5
|
+
An error occurred.
|
6
|
+
body_html: |
|
7
|
+
<p>The person responsible has been informed.</p>
|
8
|
+
<p>I’m not allowed to say anything else.</p>
|
9
|
+
<p>…</p>
|
10
|
+
<p>OK. Just for you, here’s a bit more:</p>
|
11
|
+
table:
|
12
|
+
header:
|
13
|
+
status: Status
|
14
|
+
code: Code
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en-US:
|
2
|
+
kinetic_cafe_error:
|
3
|
+
page:
|
4
|
+
title: >-
|
5
|
+
An error occurred.
|
6
|
+
body_html: |
|
7
|
+
<p>The person responsible has been informed.</p>
|
8
|
+
<p>I’m not allowed to say anything else.</p>
|
9
|
+
<p>…</p>
|
10
|
+
<p>OK. Just for you, here’s a bit more:</p>
|
11
|
+
table:
|
12
|
+
header:
|
13
|
+
status: Status
|
14
|
+
code: Code
|
@@ -1,4 +1,4 @@
|
|
1
|
-
en
|
1
|
+
en:
|
2
2
|
kinetic_cafe_error:
|
3
3
|
page:
|
4
4
|
title: >-
|
@@ -8,14 +8,7 @@ en-CA:
|
|
8
8
|
<p>I’m not allowed to say anything else.</p>
|
9
9
|
<p>…</p>
|
10
10
|
<p>OK. Just for you, here’s a bit more:</p>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<th>Status</th><td> </td><td>%{status}</td>
|
16
|
-
</tr>
|
17
|
-
<tr>
|
18
|
-
<th>Code</th><td> </td><td>%{code}</td>
|
19
|
-
</tr>
|
20
|
-
</tbody>
|
21
|
-
</table>
|
11
|
+
table:
|
12
|
+
header:
|
13
|
+
status: Status
|
14
|
+
code: Code
|
@@ -8,14 +8,7 @@ fr-CA:
|
|
8
8
|
<p>Je ne suis pas autorisé à dire quoi que ce soit d’autre à ce sujet.</p>
|
9
9
|
<p>…</p>
|
10
10
|
<p>D’ACCORD. Juste pour vous, voici un peu plus:</p>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<th>Condition</th><td> </td><td>%{status}</td>
|
16
|
-
</tr>
|
17
|
-
<tr>
|
18
|
-
<th>Code</th><td> </td><td>%{code}</td>
|
19
|
-
</tr>
|
20
|
-
</tbody>
|
21
|
-
</table>
|
11
|
+
table:
|
12
|
+
header:
|
13
|
+
status: Condition
|
14
|
+
code: Code
|
@@ -1,4 +1,4 @@
|
|
1
|
-
fr
|
1
|
+
fr:
|
2
2
|
kinetic_cafe_error:
|
3
3
|
page:
|
4
4
|
title: >-
|
@@ -8,14 +8,7 @@ fr-CA:
|
|
8
8
|
<p>Je ne suis pas autorisé à dire quoi que ce soit d’autre à ce sujet.</p>
|
9
9
|
<p>…</p>
|
10
10
|
<p>D’ACCORD. Juste pour vous, voici un peu plus:</p>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<th>Condition</th><td> </td><td>%{status}</td>
|
16
|
-
</tr>
|
17
|
-
<tr>
|
18
|
-
<th>Code</th><td> </td><td>%{code}</td>
|
19
|
-
</tr>
|
20
|
-
</tbody>
|
21
|
-
</table>
|
11
|
+
table:
|
12
|
+
header:
|
13
|
+
status: Condition
|
14
|
+
code: Code
|
data/lib/kinetic_cafe/error.rb
CHANGED
@@ -25,7 +25,7 @@ module KineticCafe #:nodoc:
|
|
25
25
|
# rescue clause and handled there, as is shown in the included
|
26
26
|
# KineticCafe::ErrorHandler controller concern for Rails.
|
27
27
|
class Error < ::StandardError
|
28
|
-
VERSION = '1.
|
28
|
+
VERSION = '1.1' # :nodoc:
|
29
29
|
|
30
30
|
# The HTTP status to be returned. If not provided in the constructor, uses
|
31
31
|
# #default_status.
|
@@ -101,6 +101,7 @@ module KineticCafe #:nodoc:
|
|
101
101
|
def i18n_key
|
102
102
|
@i18n_key ||= "#{self.class.i18n_key_base}.#{name}".freeze
|
103
103
|
end
|
104
|
+
alias_method :code, :i18n_key
|
104
105
|
|
105
106
|
# Indicates that this error should *not* have its details rendered to the
|
106
107
|
# user, but should use the +head+ method.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Minitest #:nodoc:
|
2
|
+
# Add assertions to Minitest for testing KineticCafe::Error objects.
|
3
|
+
module KineticCafeErrorAssertions
|
4
|
+
# Assert that the +actual+ exception received is the +expected+ descendant
|
5
|
+
# of KineticCafe::Error and that it has been constructed with the same
|
6
|
+
# +params+ provided.
|
7
|
+
def assert_kc_error expected, actual, params = {}, msg = nil
|
8
|
+
msg, params = params, {} if msg.nil? && params.kind_of?(String)
|
9
|
+
|
10
|
+
assert_kind_of expected, actual,
|
11
|
+
msg || "Expected #{actual} to be #{expected}, but it was not."
|
12
|
+
|
13
|
+
expected = expected.new(params)
|
14
|
+
assert_equal expected, actual,
|
15
|
+
msg || "Expected #{actual} to be #{expected}, but it was not."
|
16
|
+
end
|
17
|
+
|
18
|
+
# Assert that the +actual+ string received is the +expected+ descendant of
|
19
|
+
# KineticCafe::Error and that it has been constructed with the same
|
20
|
+
# +params+ provided.
|
21
|
+
#
|
22
|
+
# This differs from +assert_kc_error+ in that comparison of the parsed JSON
|
23
|
+
# output is compared, not KineticCafe::Error objects. The JSON for the
|
24
|
+
# provided KineticCafe::Error object is generated through
|
25
|
+
# KineticCafe::Error#error_json.
|
26
|
+
def assert_kc_error_json expected, actual, params = {}, msg = nil
|
27
|
+
msg, params = params, {} if msg.nil? && params.kind_of?(String)
|
28
|
+
|
29
|
+
msg ||= "Expected #{actual} to be JSON for #{expected}, but it was not."
|
30
|
+
actual = JSON.parse(actual)
|
31
|
+
expected = JSON.parse(expected.new(params).error_result.to_json)
|
32
|
+
|
33
|
+
assert_equal expected, actual, msg
|
34
|
+
end
|
35
|
+
|
36
|
+
# Assert that a reponse body (<tt>@response.body</tt>, useful from
|
37
|
+
# ActionController::TestCase) is JSON for the expected error. This is a
|
38
|
+
# convenience wrapper around #assert_kc_error_json.
|
39
|
+
def assert_response_kc_error expected, params = {}, msg = nil
|
40
|
+
if msg.nil? && params.kind_of?(String)
|
41
|
+
msg, params = params, {}
|
42
|
+
end
|
43
|
+
msg ||= "Expected response to be #{expected}, but was not."
|
44
|
+
assert_kc_error_json expected, @response.body, params, msg
|
45
|
+
end
|
46
|
+
|
47
|
+
Minitest::Test.send(:include, self)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Extend Minitest::Expectations with expectations for KineticCafe::Error
|
51
|
+
# tests.
|
52
|
+
module Expectations
|
53
|
+
##
|
54
|
+
# See Minitest::KineticCafeErrorAssertions#assert_kc_error
|
55
|
+
#
|
56
|
+
# :method: must_be_kc_error expected, params = {}, msg = nil
|
57
|
+
|
58
|
+
infect_an_assertion :assert_kc_error, :must_be_kc_error, :dont_flip
|
59
|
+
|
60
|
+
##
|
61
|
+
# See Minitest::KineticCafeErrorAssertions#assert_kc_error_json
|
62
|
+
#
|
63
|
+
# :method: must_be_kc_error_json expected, params = {}, msg = nil
|
64
|
+
|
65
|
+
infect_an_assertion :assert_kc_error_json, :must_be_kc_error_json,
|
66
|
+
:dont_flip
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rspec/expectations'
|
2
|
+
|
3
|
+
module KineticCafe
|
4
|
+
# Provide a number of useful expectations against Kinetic Cafe errors. Enable
|
5
|
+
# these with:
|
6
|
+
#
|
7
|
+
# require 'kinetic_cafe/error_rspec'
|
8
|
+
# Rspec.configure do |c|
|
9
|
+
# c.include KineticCafe::ErrorRspec
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# +be_json_for+:: Verifies that the expected value is a JSON representation
|
13
|
+
# of the actual value. If the actual value responds to
|
14
|
+
# #body, the actual value is replaced with +actual.body+.
|
15
|
+
module ErrorRspec
|
16
|
+
extend ::Rspec::Matchers::DSL
|
17
|
+
|
18
|
+
matcher :be_json_for do |expected|
|
19
|
+
match do |actual|
|
20
|
+
compare = if actual.respond_to?(:body)
|
21
|
+
actual.body
|
22
|
+
else
|
23
|
+
compare
|
24
|
+
end
|
25
|
+
expect(JSON.parse(compare)).to eq(expected)
|
26
|
+
end
|
27
|
+
|
28
|
+
diffable
|
29
|
+
end
|
30
|
+
|
31
|
+
matcher :be_kc_error do |expected, params = {}|
|
32
|
+
match do |actual|
|
33
|
+
expect(actual).to be_kind_of(expected)
|
34
|
+
expect(actual).to eq(expected.new(params))
|
35
|
+
end
|
36
|
+
|
37
|
+
diffable
|
38
|
+
end
|
39
|
+
|
40
|
+
matcher :be_kc_error_json do |expected, params = {}|
|
41
|
+
match do |actual|
|
42
|
+
expect(actual).to \
|
43
|
+
be_json_for(JSON.parse(expected.new(params).error_result.to_json))
|
44
|
+
end
|
45
|
+
|
46
|
+
diffable
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinetic_cafe_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,16 +261,24 @@ files:
|
|
261
261
|
- README.rdoc
|
262
262
|
- Rakefile
|
263
263
|
- app/controllers/concerns/kinetic_cafe/error_handler.rb
|
264
|
-
- app/views/
|
264
|
+
- app/views/kinetic_cafe_error/_table.html.erb
|
265
|
+
- app/views/kinetic_cafe_error/_table.html.haml
|
266
|
+
- app/views/kinetic_cafe_error/_table.html.slim
|
267
|
+
- app/views/kinetic_cafe_error/page.html.erb
|
268
|
+
- app/views/kinetic_cafe_error/page.html.haml
|
269
|
+
- app/views/kinetic_cafe_error/page.html.slim
|
270
|
+
- config/i18n-tasks.yml.erb
|
271
|
+
- config/locales/kinetic_cafe_error.en-CA.yml
|
272
|
+
- config/locales/kinetic_cafe_error.en-UK.yml
|
273
|
+
- config/locales/kinetic_cafe_error.en-US.yml
|
265
274
|
- config/locales/kinetic_cafe_error.en.yml
|
266
|
-
- config/locales/kinetic_cafe_error.
|
267
|
-
- config/locales/kinetic_cafe_error.en_uk.yml
|
268
|
-
- config/locales/kinetic_cafe_error.en_us.yml
|
275
|
+
- config/locales/kinetic_cafe_error.fr-CA.yml
|
269
276
|
- config/locales/kinetic_cafe_error.fr.yml
|
270
|
-
- config/locales/kinetic_cafe_error.fr_ca.yml
|
271
277
|
- lib/kinetic_cafe/error.rb
|
278
|
+
- lib/kinetic_cafe/error/minitest.rb
|
272
279
|
- lib/kinetic_cafe/error_dsl.rb
|
273
280
|
- lib/kinetic_cafe/error_engine.rb
|
281
|
+
- lib/kinetic_cafe/error_rspec.rb
|
274
282
|
- lib/kinetic_cafe_error.rb
|
275
283
|
- test/test_helper.rb
|
276
284
|
- test/test_kinetic_cafe_error.rb
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<h2><%= t('kinetic_cafe_error.page.title') %></h2>
|
2
|
-
|
3
|
-
<% unless error.header_only? || error.internal? -%>
|
4
|
-
<blockquote><%= error.i18n_message %></blockquote>
|
5
|
-
<% end -%>
|
6
|
-
<%= t('kinetic_cafe_error.page.body_html') %>
|
7
|
-
<%= t('kinetic_cafe_error.page.error_table_html',
|
8
|
-
status: error.status, code: error.i18n_key) -%>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
en-CA:
|
2
|
-
kinetic_cafe_error:
|
3
|
-
page:
|
4
|
-
title: >-
|
5
|
-
An error occurred.
|
6
|
-
body_html: |
|
7
|
-
<p>The person responsible has been informed.</p>
|
8
|
-
<p>I’m not allowed to say anything else.</p>
|
9
|
-
<p>…</p>
|
10
|
-
<p>OK. Just for you, here’s a bit more:</p>
|
11
|
-
error_table_html: |
|
12
|
-
<table>
|
13
|
-
<tbody>
|
14
|
-
<tr>
|
15
|
-
<th>Status</th><td> </td><td>%{status}</td>
|
16
|
-
</tr>
|
17
|
-
<tr>
|
18
|
-
<th>Code</th><td> </td><td>%{code}</td>
|
19
|
-
</tr>
|
20
|
-
</tbody>
|
21
|
-
</table>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
en-UK:
|
2
|
-
kinetic_cafe_error:
|
3
|
-
page:
|
4
|
-
title: >-
|
5
|
-
An error occurred.
|
6
|
-
body_html: |
|
7
|
-
<p>The person responsible has been informed.</p>
|
8
|
-
<p>I’m not allowed to say anything else.</p>
|
9
|
-
<p>…</p>
|
10
|
-
<p>OK. Just for you, here’s a bit more:</p>
|
11
|
-
error_table_html: |
|
12
|
-
<table>
|
13
|
-
<tbody>
|
14
|
-
<tr>
|
15
|
-
<th>Status</th><td> </td><td>%{status}</td>
|
16
|
-
</tr>
|
17
|
-
<tr>
|
18
|
-
<th>Code</th><td> </td><td>%{code}</td>
|
19
|
-
</tr>
|
20
|
-
</tbody>
|
21
|
-
</table>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
en-US:
|
2
|
-
kinetic_cafe_error:
|
3
|
-
page:
|
4
|
-
title: >-
|
5
|
-
An error occurred.
|
6
|
-
body_html: |
|
7
|
-
<p>The person responsible has been informed.</p>
|
8
|
-
<p>I’m not allowed to say anything else.</p>
|
9
|
-
<p>…</p>
|
10
|
-
<p>OK. Just for you, here’s a bit more:</p>
|
11
|
-
error_table_html: |
|
12
|
-
<table>
|
13
|
-
<tbody>
|
14
|
-
<tr>
|
15
|
-
<th>Status</th><td> </td><td>%{status}</td>
|
16
|
-
</tr>
|
17
|
-
<tr>
|
18
|
-
<th>Code</th><td> </td><td>%{code}</td>
|
19
|
-
</tr>
|
20
|
-
</tbody>
|
21
|
-
</table>
|