erratum 1.1.0 → 2.0.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/LICENSE.txt +1 -1
  4. data/lib/erratum/configuration.rb +6 -5
  5. data/lib/erratum/error.rb +14 -13
  6. data/lib/erratum/errors/authentication_error.rb +1 -0
  7. data/lib/erratum/errors/authentication_errors/duplicate_authentication_error.rb +1 -0
  8. data/lib/erratum/errors/authentication_errors/invalid_token_error.rb +1 -0
  9. data/lib/erratum/errors/authentication_errors/invalid_username_or_password_error.rb +1 -0
  10. data/lib/erratum/errors/authorization_error.rb +1 -0
  11. data/lib/erratum/errors/authorization_errors/forbidden_error.rb +3 -2
  12. data/lib/erratum/errors/crud_error.rb +1 -0
  13. data/lib/erratum/errors/crud_errors/association_error.rb +4 -3
  14. data/lib/erratum/errors/crud_errors/resource_not_found_error.rb +1 -0
  15. data/lib/erratum/errors/crud_errors/resource_persistence_error.rb +1 -0
  16. data/lib/erratum/errors/request_errors/parameter_missing_error.rb +1 -0
  17. data/lib/erratum/errors/request_errors/unpermitted_parameters_error.rb +1 -0
  18. data/lib/erratum/rescuable_resource.rb +1 -0
  19. data/lib/erratum/resource_naming.rb +11 -10
  20. data/lib/erratum/utilities/string.rb +1 -0
  21. data/lib/erratum/verifiable_resource.rb +1 -0
  22. data/lib/erratum/version.rb +2 -1
  23. data/lib/erratum.rb +2 -1
  24. data.tar.gz.sig +5 -1
  25. metadata +41 -54
  26. metadata.gz.sig +1 -2
  27. data/Rakefile +0 -2
  28. data/spec/lib/erratum/configuration_spec.rb +0 -27
  29. data/spec/lib/erratum/error_spec.rb +0 -173
  30. data/spec/lib/erratum/errors/authentication_errors/duplicate_authentication_error_spec.rb +0 -43
  31. data/spec/lib/erratum/errors/authentication_errors/invalid_token_error_spec.rb +0 -33
  32. data/spec/lib/erratum/errors/authentication_errors/invalid_username_or_password_error_spec.rb +0 -35
  33. data/spec/lib/erratum/errors/authorization_errors/forbidden_error_spec.rb +0 -52
  34. data/spec/lib/erratum/errors/crud_errors/association_error_spec.rb +0 -69
  35. data/spec/lib/erratum/errors/crud_errors/resource_not_found_error_spec.rb +0 -89
  36. data/spec/lib/erratum/errors/crud_errors/resource_persistence_error_spec.rb +0 -92
  37. data/spec/lib/erratum/errors/request_errors/parameter_missing_error_spec.rb +0 -58
  38. data/spec/lib/erratum/errors/request_errors/unpermitted_parameters_error_spec.rb +0 -67
  39. data/spec/lib/erratum/rescuable_resource_spec.rb +0 -8
  40. data/spec/lib/human_error_spec.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 982e57d709215c3038efc5bec08ee2c2fe3ec196
4
- data.tar.gz: 7bb38ea005d8ca877560a156ae4ee28f897b4741
3
+ metadata.gz: 5adebb18c185bba738d9ade01bb25b422874cec3
4
+ data.tar.gz: 0c44bfaeca6bc92ecaaa1cdf0683ccb2bc0a5d13
5
5
  SHA512:
6
- metadata.gz: 5251259e5374837ab0d30bdd78b90345c85c30754efc395b70041a0b785b2412084f631eeed8e912d2af0dd7da2f796fd1574ddd84a5ea71bebb09a9f7adba5f
7
- data.tar.gz: 075e5ce7e21137754139f8c67a5afb691a501ad48186e9af9f348c76be4970d25d26cab979596da5f8fe299970f638b9bc346f97fb939db62c0c2a8242b9d5a6
6
+ metadata.gz: 7111601d73851f7f06fa0afe8bbb7efeb83ffb3b1977aaf223200689d9074e772c7427ade962d6a42230adbaa6efa415a53d189adcdd63eaf602fec9c2227f92
7
+ data.tar.gz: ffac65174a222d3ed9d1e5feb7472103d65946845de5955115a53328e6ac943d574f0a0ca6ef048afa471ef7274333101cde3d6588abf3adaa036b58f79ce6a6
checksums.yaml.gz.sig CHANGED
Binary file
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 The Grand Design
1
+ Copyright (c) 2010-2016 The Kompanee, Ltd
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -1,24 +1,25 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'singleton'
3
4
 
4
5
  class Erratum
5
6
  class Configuration
6
7
  include Singleton
7
8
 
8
- attr_accessor :url_mappings
9
+ attr_writer :url_mappings
9
10
 
10
11
  def external_documentation_urls
11
- @external_documentation_urls ||= url_mappings['external_documentation_urls']
12
+ url_mappings['external_documentation_urls']
12
13
  end
13
14
 
14
15
  def developer_documentation_urls
15
- @developer_documentation_urls ||= url_mappings['developer_documentation_urls']
16
+ url_mappings['developer_documentation_urls']
16
17
  end
17
18
 
18
19
  def to_h
19
20
  {
20
- external_documentation_urls: external_documentation_urls,
21
- developer_documentation_urls: developer_documentation_urls,
21
+ 'external_documentation_urls' => external_documentation_urls,
22
+ 'developer_documentation_urls' => developer_documentation_urls,
22
23
  }
23
24
  end
24
25
 
data/lib/erratum/error.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'json'
3
4
  require 'erratum/configuration'
4
5
  require 'erratum/utilities/string'
@@ -13,15 +14,15 @@ module Error
13
14
  end
14
15
  end
15
16
 
16
- attr_accessor :id,
17
- :external_documentation_url,
18
- :developer_documentation_url,
19
- :http_status,
20
- :code,
21
- :title,
22
- :detail,
23
- :source,
24
- :message
17
+ attr_writer :id,
18
+ :code,
19
+ :detail,
20
+ :developer_documentation_url,
21
+ :external_documentation_url,
22
+ :http_status,
23
+ :message,
24
+ :source,
25
+ :title
25
26
 
26
27
  def initialize(**args)
27
28
  args.each do |variable, value|
@@ -67,10 +68,10 @@ module Error
67
68
  alias status http_status
68
69
 
69
70
  def code
70
- @code ||= Erratum::Utilities::String.
71
- underscore(self.class.name).
72
- gsub(%r{\A[^/]+/}, '').
73
- gsub(%r{/}, '.')
71
+ @code ||= Erratum::Utilities::String
72
+ .underscore(self.class.name)
73
+ .gsub(%r{\A[^/]+/}, '')
74
+ .gsub(%r{/}, '.')
74
75
  end
75
76
 
76
77
  def title
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/error'
3
4
 
4
5
  class Erratum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/errors/authentication_error'
3
4
 
4
5
  class Erratum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/errors/authentication_error'
3
4
 
4
5
  class Erratum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/errors/authentication_error'
3
4
 
4
5
  class Erratum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/error'
3
4
 
4
5
  class Erratum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/errors/authorization_error'
3
4
 
4
5
  class Erratum
@@ -10,8 +11,8 @@ class ForbiddenError < RuntimeError
10
11
  NON_SPECIFIC_RESOURCE_ACTIONS = %w{index create}.freeze
11
12
 
12
13
  attr_accessor :resource_name,
13
- :resource_id,
14
- :action
14
+ :resource_id
15
+ attr_writer :action
15
16
 
16
17
  def http_status
17
18
  403
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Erratum
3
4
  module Errors
4
5
  module CrudError
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/errors/crud_error'
3
4
 
4
5
  class Erratum
@@ -17,9 +18,9 @@ class AssociationError < RuntimeError
17
18
  case original_error.class.name
18
19
  when 'ActiveRecord::InvalidForeignKey'
19
20
  message_info_pattern = /DETAIL: Key \((.*)_id\)=\(([a-f0-9\-]+)\)/
20
- message_info = original_error.
21
- message.
22
- match(message_info_pattern)[1..-1]
21
+ message_info = original_error
22
+ .message
23
+ .match(message_info_pattern)[1..-1]
23
24
 
24
25
  initialization_parameters = {
25
26
  association_name: message_info[0],
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/errors/crud_error'
3
4
 
4
5
  class Erratum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/error'
3
4
  require 'erratum/errors/crud_error'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Erratum
3
4
  module Errors
4
5
  class ParameterMissingError < RuntimeError
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Erratum
3
4
  module Errors
4
5
  class UnpermittedParametersError < RuntimeError
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/resource_naming'
3
4
 
4
5
  class Erratum
@@ -1,26 +1,27 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Erratum
3
4
  module ResourceNaming
4
5
  CONTROLLER_RESOURCE_NAME_PATTERN = /\A((.*?::)?.*?)(\w+)Controller\z/
5
6
 
6
7
  module ClassMethods
7
8
  def plural_resource_name
8
- @plural_resource_name ||= name[CONTROLLER_RESOURCE_NAME_PATTERN, 3].
9
- underscore.
10
- pluralize.
11
- downcase
9
+ @plural_resource_name ||= name[CONTROLLER_RESOURCE_NAME_PATTERN, 3]
10
+ .underscore
11
+ .pluralize
12
+ .downcase
12
13
  end
13
14
 
14
15
  def singular_resource_name
15
- @singular_resource_name ||= name[CONTROLLER_RESOURCE_NAME_PATTERN, 3].
16
- underscore.
17
- singularize.
18
- downcase
16
+ @singular_resource_name ||= name[CONTROLLER_RESOURCE_NAME_PATTERN, 3]
17
+ .underscore
18
+ .singularize
19
+ .downcase
19
20
  end
20
21
 
21
22
  def resource_class_name
22
- @resource_class_name ||= singular_resource_name.
23
- camelize
23
+ @resource_class_name ||= singular_resource_name
24
+ .camelize
24
25
  end
25
26
  end
26
27
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Erratum
3
4
  module Utilities
4
5
  class String
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/resource_naming'
3
4
 
4
5
  class Erratum
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Erratum
3
- VERSION = '1.1.0'
4
+ VERSION = '2.0.0'
4
5
  end
data/lib/erratum.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'erratum/configuration'
3
4
  require 'erratum/error'
4
5
  require 'erratum/errors/authorization_error'
@@ -35,7 +36,7 @@ class Erratum
35
36
  when 'ActiveRecord::RecordInvalid',
36
37
  'ActiveRecord::RecordNotSaved'
37
38
  fetch('ResourcePersistenceError').convert(original_error, overrides)
38
- when 'ActionController::ParameterMissing',
39
+ when 'ActionController::ParameterMissing'
39
40
  fetch('ParameterMissingError').convert(original_error, overrides)
40
41
  when 'ActionController::UnpermittedParameters'
41
42
  fetch('UnpermittedParametersError').convert(original_error, overrides)
data.tar.gz.sig CHANGED
@@ -1 +1,5 @@
1
- �op�)�:�$�e����RKB�Ƞ�����N�O��P ��v�>ez=��quD&�J�.�62����@�4�Y��9>cN��K�4��:�0��8�TeώV*��mv�l��~�uT|w8bl0�E�~yS"�����op2��E)�\�AU^�^��)8��m�� m,����HD r��ןZ+2�Ά*uW8u��،L�Z��՘ڏ,!a�'�gS֞�{^@��1�[��3Y7�l�%����jz�����
1
+ o\)�[,��v�`r��=d'����`x�:�)OBRjj,������l��a8R)RX��k J�'hX��
2
+ �0�&�<��"xߴn{�.D�ݫ �Le���&?��X�=M��УV��#oD1=�rJ
3
+ �3#��vB�[3�)c�=���^�Z�|8�����MG{o�1��[�ՊV�����
4
+ ��]z��,5�Q���wu"00S&%���m6;��X�W�P �IP:d:�>�HP��\�؀
5
+ W���.��m
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erratum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -12,26 +12,26 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDqjCCApKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBNMREwDwYDVQQDDAhydWJ5
14
14
  Z2VtczEjMCEGCgmSJomT8ixkARkWE2xpdmluZ2hpZ2hvbnRoZWJsb2cxEzARBgoJ
15
- kiaJk/IsZAEZFgNjb20wHhcNMTYwNTAxMDIzMDIzWhcNMTcwNTAxMDIzMDIzWjBN
15
+ kiaJk/IsZAEZFgNjb20wHhcNMTcwODAyMjI1OTM1WhcNMTgwODAyMjI1OTM1WjBN
16
16
  MREwDwYDVQQDDAhydWJ5Z2VtczEjMCEGCgmSJomT8ixkARkWE2xpdmluZ2hpZ2hv
17
17
  bnRoZWJsb2cxEzARBgoJkiaJk/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUA
18
- A4IBDwAwggEKAoIBAQC/Oxo4PMAOCC3dfzGt7DZJwoDY9MGBXoWkbWIEP91yyKIB
19
- mWheQ1epDXkj1R6SM1+iclwgUKJQvFrSeD5i1NS9+3qRrD6gPCf3RDAbWNdUpyei
20
- F/W4+G7eCxGC6FHv7WsBjrGWQVTjZtKYOiQCxwwkPlZSX8aBXViO8D9bZJAURocY
21
- CbsMGeS0sPISRb0GCnI8VOIoab7GM8tdmIj4Uv0lzp4uOlKRJBss5/Sjp1mjgCvI
22
- vuXy0X+r1l2xiXL3/uTT/Tch3lPWctEEDw9rUzNz0N5oTGK4vooq4m4AIzU1pa1Z
23
- ZneO33rn3QVWVpOsK6NQVpBNhSism+Ju1mlvdmKFAgMBAAGjgZQwgZEwCQYDVR0T
24
- BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFLpr4AqEQwV9hUch3fxKvCkHUw3i
18
+ A4IBDwAwggEKAoIBAQDtLa7+7p49gW15OgOyRZad/F92iZcMdDjZ2kAxZlviXgVe
19
+ PCtjfdURobH+YMdt++6eRkE25utIFqHyN51Shxfdc21T3fPQe/ZEoMyiJK4tYzbh
20
+ 7VjNJG4ldvKKpS1p7iVz9imnyTxNwb0JaIOsOFCA04T0u6aCQi2acNvAPLviXk0q
21
+ xJ/CKjI4QUTZKVrBt8Q1Egrp2yzmEnSNftDuTbBb8m4vDR+w325CwbKCgycHJ1/g
22
+ YZ3FO76TzJuRVbsYS/bU5XKHVEpkeFmWBqEXsk4DuUIWLa6WZEJcoZf+YP+1pycG
23
+ 7YqSbydpINtEdopD+EEI+g+zNJ4nSI8/eQcQyEjBAgMBAAGjgZQwgZEwCQYDVR0T
24
+ BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFDWuVrg4ve0vLu71kqiGdyBnzJGV
25
25
  MCsGA1UdEQQkMCKBIHJ1YnlnZW1zQGxpdmluZ2hpZ2hvbnRoZWJsb2cuY29tMCsG
26
26
  A1UdEgQkMCKBIHJ1YnlnZW1zQGxpdmluZ2hpZ2hvbnRoZWJsb2cuY29tMA0GCSqG
27
- SIb3DQEBBQUAA4IBAQB5lDS+51DxC1GMpILDt++z5Isx2gSybmGKhNFFWWWo5iVW
28
- 6jLsj7H1T934Bn31sVET2cvrFGMVLKoitGgZuZPxjzkmm2+TDPbt02ThsLqjsh7W
29
- 000RFl0u7xJE8dg9y3Kmntar83Mr/Uf1F88/4mQsvGNnxGa39QP9IY4p6FkyEO3L
30
- RRz+3xE8j0OBl1FNALFtP74/A3zmBRbCizr8En/jbQe/DISJG2o8QOyqm/64uNoy
31
- zRIv8lqQM8QFT76rzP5SBCERwN+ltKAFbQ5/FwmZNGWYnmCP3RZMQiRnbh+9H9lh
32
- mlbwaYZTjgsXq6cy8N38EecewgBbZYS1IYJraE/M
27
+ SIb3DQEBBQUAA4IBAQDJIpHjbBPGiaY4wOHcXlltQ+BMmhWQNh+1fZtyajQd+7Ay
28
+ fv23mO7Mf25Q38gopQlpaODkfxq54Jt8FvQbr5RYRS4j+JEKb75NgrAtehd8USUd
29
+ CiJJGH+yvGNWug9IGZCGX91HIbTsLQ5IUUWQasC5jGP8nxXufUr9xgAJZZenewny
30
+ B2qKu8q1A/kj6cw62RCY7yBmUXxlcJBj8g+JKYAFbYYKUdQSzf50k9IiWLWunJM+
31
+ Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
32
+ iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
33
33
  -----END CERTIFICATE-----
34
- date: 2016-05-26 00:00:00.000000000 Z
34
+ date: 2018-01-24 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
@@ -39,14 +39,14 @@ dependencies:
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '3.4'
42
+ version: '3.7'
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '3.4'
49
+ version: '3.7'
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspeckled
52
52
  requirement: !ruby/object:Gem::Requirement
@@ -65,39 +65,51 @@ dependencies:
65
65
  name: activerecord
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - "~>"
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '6.0'
71
+ - - ">="
69
72
  - !ruby/object:Gem::Version
70
73
  version: '4.2'
71
74
  type: :development
72
75
  prerelease: false
73
76
  version_requirements: !ruby/object:Gem::Requirement
74
77
  requirements:
75
- - - "~>"
78
+ - - "<"
79
+ - !ruby/object:Gem::Version
80
+ version: '6.0'
81
+ - - ">="
76
82
  - !ruby/object:Gem::Version
77
83
  version: '4.2'
78
84
  - !ruby/object:Gem::Dependency
79
85
  name: actionpack
80
86
  requirement: !ruby/object:Gem::Requirement
81
87
  requirements:
82
- - - "~>"
88
+ - - "<"
89
+ - !ruby/object:Gem::Version
90
+ version: '6.0'
91
+ - - ">="
83
92
  - !ruby/object:Gem::Version
84
93
  version: '4.2'
85
94
  type: :development
86
95
  prerelease: false
87
96
  version_requirements: !ruby/object:Gem::Requirement
88
97
  requirements:
89
- - - "~>"
98
+ - - "<"
99
+ - !ruby/object:Gem::Version
100
+ version: '6.0'
101
+ - - ">="
90
102
  - !ruby/object:Gem::Version
91
103
  version: '4.2'
92
104
  description: ''
93
- email: rubygems@livinghighontheblog.com
105
+ email:
106
+ - rubygems@livinghighontheblog.com
94
107
  executables: []
95
108
  extensions: []
96
109
  extra_rdoc_files: []
97
110
  files:
98
111
  - LICENSE.txt
99
112
  - README.md
100
- - Rakefile
101
113
  - lib/erratum.rb
102
114
  - lib/erratum/configuration.rb
103
115
  - lib/erratum/error.rb
@@ -118,23 +130,11 @@ files:
118
130
  - lib/erratum/utilities/string.rb
119
131
  - lib/erratum/verifiable_resource.rb
120
132
  - lib/erratum/version.rb
121
- - spec/lib/erratum/configuration_spec.rb
122
- - spec/lib/erratum/error_spec.rb
123
- - spec/lib/erratum/errors/authentication_errors/duplicate_authentication_error_spec.rb
124
- - spec/lib/erratum/errors/authentication_errors/invalid_token_error_spec.rb
125
- - spec/lib/erratum/errors/authentication_errors/invalid_username_or_password_error_spec.rb
126
- - spec/lib/erratum/errors/authorization_errors/forbidden_error_spec.rb
127
- - spec/lib/erratum/errors/crud_errors/association_error_spec.rb
128
- - spec/lib/erratum/errors/crud_errors/resource_not_found_error_spec.rb
129
- - spec/lib/erratum/errors/crud_errors/resource_persistence_error_spec.rb
130
- - spec/lib/erratum/errors/request_errors/parameter_missing_error_spec.rb
131
- - spec/lib/erratum/errors/request_errors/unpermitted_parameters_error_spec.rb
132
- - spec/lib/erratum/rescuable_resource_spec.rb
133
- - spec/lib/human_error_spec.rb
134
- homepage:
133
+ homepage: https://github.com/thekompanee/erratum
135
134
  licenses:
136
135
  - MIT
137
- metadata: {}
136
+ metadata:
137
+ allowed_push_host: https://rubygems.org
138
138
  post_install_message:
139
139
  rdoc_options: []
140
140
  require_paths:
@@ -151,21 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.5.1
154
+ rubygems_version: 2.6.14
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Errors Need Love
158
- test_files:
159
- - spec/lib/erratum/configuration_spec.rb
160
- - spec/lib/erratum/error_spec.rb
161
- - spec/lib/erratum/errors/authentication_errors/duplicate_authentication_error_spec.rb
162
- - spec/lib/erratum/errors/authentication_errors/invalid_token_error_spec.rb
163
- - spec/lib/erratum/errors/authentication_errors/invalid_username_or_password_error_spec.rb
164
- - spec/lib/erratum/errors/authorization_errors/forbidden_error_spec.rb
165
- - spec/lib/erratum/errors/crud_errors/association_error_spec.rb
166
- - spec/lib/erratum/errors/crud_errors/resource_not_found_error_spec.rb
167
- - spec/lib/erratum/errors/crud_errors/resource_persistence_error_spec.rb
168
- - spec/lib/erratum/errors/request_errors/parameter_missing_error_spec.rb
169
- - spec/lib/erratum/errors/request_errors/unpermitted_parameters_error_spec.rb
170
- - spec/lib/erratum/rescuable_resource_spec.rb
171
- - spec/lib/human_error_spec.rb
158
+ test_files: []
metadata.gz.sig CHANGED
@@ -1,2 +1 @@
1
- \@ [��ͪ;�*1�@
2
- �@|r�Q�M/]��y�́�(\�PH�aB%�`pr��=�?T�T��\HUq��~f%�.e:u^��b�8b;Jo��t1G>�
1
+ �M���K�[�%�%��ʾE�/�����ʦL�B�AL�!�<�-��b���d�%��T����=T��d2E�N�� T%��潳� �cb5�k�D���E��E�����XMǁ��_f���L��OsՂH�7��q`#��PQ����(��A.��Ў�����*�Q��f*��p��S-P�N��+����_#��s<�� ��U�.9�����o�o8�(iH9��/8ҳ5s��'���@dz �?4N�O�n&�(7�?R�
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'bundler/gem_tasks'
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/configuration'
4
-
5
- class Erratum
6
- RSpec.describe Configuration, singletons: true do
7
- it 'can set the url mappings' do
8
- configuration = Configuration.instance
9
- configuration.url_mappings = 'foobarbaz'
10
-
11
- expect(configuration.url_mappings).to eql 'foobarbaz'
12
- end
13
-
14
- it 'can convert itself into a hash' do
15
- configuration = Configuration.instance
16
- configuration.url_mappings = {
17
- 'external_documentation_urls' => 'blah',
18
- 'developer_documentation_urls' => 'asdf',
19
- }
20
-
21
- expect(configuration.to_h).to eql(
22
- external_documentation_urls: 'blah',
23
- developer_documentation_urls: 'asdf',
24
- )
25
- end
26
- end
27
- end
@@ -1,173 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/error'
4
-
5
- class CustomError < RuntimeError
6
- include Erratum::Error
7
- end
8
-
9
- class Erratum
10
- RSpec.describe Error do
11
- it 'can wrap an error with another error' do
12
- original_error = RuntimeError.new('My Runtime Error Message')
13
- wrapped_error = CustomError.wrap(original_error)
14
-
15
- expect(wrapped_error.class.name).to eql 'CustomError'
16
- end
17
-
18
- it 'can wrap the message of an error by identifying the original error type' do
19
- original_error = RuntimeError.new('My Runtime Error Message')
20
- wrapped_error = CustomError.wrap(original_error)
21
-
22
- expect(wrapped_error.message).to eql 'RuntimeError: My Runtime Error Message'
23
- end
24
-
25
- it 'can transfer the backtrace of the original error to the wrapped error' do
26
- original_error = RuntimeError.new('My Runtime Error Message')
27
- original_error.set_backtrace %w{foo bar baz}
28
- wrapped_error = CustomError.wrap(original_error)
29
-
30
- expect(wrapped_error.backtrace).to eql %w{foo bar baz}
31
- end
32
-
33
- it 'can have its message explicitly set when it is generated' do
34
- error = CustomError.new(message: 'My Message')
35
-
36
- expect(error.message).to eql 'My Message'
37
- end
38
-
39
- it 'can have its message explicitly set when it is generated' do
40
- error = CustomError.new
41
- allow(error).to receive(:detail).
42
- and_return('My Developer Message')
43
-
44
- expect(error.message).to eql 'My Developer Message'
45
- end
46
-
47
- it 'can generate error data' do
48
- custom_error = CustomError.new(
49
- id: 'identifier',
50
- http_status: 'flibbity',
51
- code: 'jibbit',
52
- title: 'roll dem bones and stones',
53
- detail: 'I cannot receive any satisfaction',
54
- source: 'But perhaps if I attempt it one more time, I can',
55
- developer_documentation_url: 'asimof/jibbit?version=janky',
56
- external_documentation_url: 'jinkies/87654321',
57
- )
58
-
59
- expect(custom_error.as_json).to eql(
60
- id: 'identifier',
61
- links: {
62
- about: 'jinkies/87654321',
63
- documentation: 'asimof/jibbit?version=janky',
64
- },
65
- status: 'flibbity',
66
- code: 'jibbit',
67
- title: 'roll dem bones and stones',
68
- detail: 'I cannot receive any satisfaction',
69
- source: 'But perhaps if I attempt it one more time, I can',
70
- )
71
- end
72
-
73
- it 'can extract configuration from the global config if it is not passed in',
74
- singletons: Erratum::Configuration do
75
-
76
- Erratum.configure do |config|
77
- config.url_mappings = {
78
- 'external_documentation_urls' => {
79
- 'jibbit' => 'http://example.com/edu',
80
- },
81
- 'developer_documentation_urls' => {
82
- 'jibbit' => 'http://example.com/ddu',
83
- },
84
- }
85
- end
86
-
87
- custom_error = CustomError.new(
88
- id: 'identifier',
89
- http_status: 'flibbity',
90
- code: 'jibbit',
91
- title: 'roll dem bones and stones',
92
- detail: 'I cannot receive any satisfaction',
93
- source: 'But perhaps if I attempt it one more time, I can',
94
- )
95
-
96
- expect(custom_error.as_json).to eql(
97
- id: 'identifier',
98
- links: {
99
- about: 'http://example.com/edu',
100
- documentation: 'http://example.com/ddu',
101
- },
102
- status: 'flibbity',
103
- code: 'jibbit',
104
- title: 'roll dem bones and stones',
105
- detail: 'I cannot receive any satisfaction',
106
- source: 'But perhaps if I attempt it one more time, I can',
107
- )
108
- end
109
-
110
- it 'can override the global config if it is set, but an explicit value is passed in',
111
- singletons: Erratum::Configuration do
112
-
113
- Erratum.configure do |config|
114
- config.url_mappings = {
115
- 'external_documentation_urls' => {
116
- 'jibbit' => 'http://example.com/edu',
117
- },
118
- 'developer_documentation_urls' => {
119
- 'jibbit' => 'http://example.com/ddu',
120
- },
121
- }
122
- end
123
-
124
- custom_error = CustomError.new(
125
- id: 'identifier',
126
- http_status: 'flibbity',
127
- code: 'jibbit',
128
- title: 'roll dem bones and stones',
129
- detail: 'I cannot receive any satisfaction',
130
- source: 'But perhaps if I attempt it one more time, I can',
131
- developer_documentation_url: 'hasimof/jibbit?version=hanky',
132
- external_documentation_url: 'hinkies/87654321',
133
- )
134
-
135
- expect(custom_error.as_json).to eql(
136
- id: 'identifier',
137
- links: {
138
- about: 'hinkies/87654321',
139
- documentation: 'hasimof/jibbit?version=hanky',
140
- },
141
- status: 'flibbity',
142
- code: 'jibbit',
143
- title: 'roll dem bones and stones',
144
- detail: 'I cannot receive any satisfaction',
145
- source: 'But perhaps if I attempt it one more time, I can',
146
- )
147
- end
148
-
149
- it 'can handle if it finds no URL mappings' do
150
- custom_error = CustomError.new(
151
- id: 'identifier',
152
- http_status: 'flibbity',
153
- code: 'jibbit',
154
- title: 'roll dem bones and stones',
155
- detail: 'I cannot receive any satisfaction',
156
- source: 'But perhaps if I attempt it one more time, I can',
157
- )
158
-
159
- expect(custom_error.as_json).to eql(
160
- id: 'identifier',
161
- links: {
162
- about: nil,
163
- documentation: nil,
164
- },
165
- status: 'flibbity',
166
- code: 'jibbit',
167
- title: 'roll dem bones and stones',
168
- detail: 'I cannot receive any satisfaction',
169
- source: 'But perhaps if I attempt it one more time, I can',
170
- )
171
- end
172
- end
173
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/errors/authentication_errors/duplicate_authentication_error'
4
-
5
- class Erratum
6
- module Errors
7
- RSpec.describe DuplicateAuthenticationError do
8
- let(:error) do
9
- DuplicateAuthenticationError.new(provider: 'flibbity',
10
- provider_user_id: '12345',
11
- user_id: '54321')
12
- end
13
-
14
- it 'has a status of 409' do
15
- expect(error.http_status).to eql 409
16
- end
17
-
18
- it 'has a code' do
19
- expect(error.code).to eql 'errors.duplicate_authentication_error'
20
- end
21
-
22
- it 'has a title' do
23
- expect(error.title).to eql 'Duplicate Authentication'
24
- end
25
-
26
- it 'can output the detail' do
27
- expect(error.detail).to eql 'The authentication you attempted to ' \
28
- 'register has already been registered by ' \
29
- 'another user. We do not currently support ' \
30
- 'allowing multiple users to be connected to ' \
31
- 'the same authentication.'
32
- end
33
-
34
- it 'can output the source' do
35
- expect(error.source).to eql(
36
- 'provider' => 'flibbity',
37
- 'provider_user_id' => '12345',
38
- 'user_id' => '54321',
39
- )
40
- end
41
- end
42
- end
43
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/errors/authentication_errors/invalid_token_error'
4
-
5
- class Erratum
6
- module Errors
7
- RSpec.describe InvalidTokenError do
8
- let(:error) { InvalidTokenError.new }
9
-
10
- it 'has a status of 401' do
11
- expect(error.http_status).to eql 401
12
- end
13
-
14
- it 'has a code' do
15
- expect(error.code).to eql 'errors.invalid_token_error'
16
- end
17
-
18
- it 'has a title' do
19
- expect(error.title).to eql 'Invalid Token'
20
- end
21
-
22
- it 'can output the detail' do
23
- expect(error.detail).to eql 'The token you attempted to use for this ' \
24
- 'request is invalid for this resource. ' \
25
- 'Please double-check and try again.'
26
- end
27
-
28
- it 'can output the source' do
29
- expect(error.source).to eql(token: '[FILTERED]')
30
- end
31
- end
32
- end
33
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/errors/authentication_errors/invalid_username_or_password_error'
4
-
5
- class Erratum
6
- module Errors
7
- RSpec.describe InvalidUsernameOrPasswordError do
8
- let(:error) { InvalidUsernameOrPasswordError.new }
9
-
10
- it 'has a status of 401' do
11
- expect(error.http_status).to eql 401
12
- end
13
-
14
- it 'has a code' do
15
- expect(error.code).to eql 'errors.invalid_username_or_password_error'
16
- end
17
-
18
- it 'has a title' do
19
- expect(error.title).to eql 'Invalid Username/Password'
20
- end
21
-
22
- it 'can output the detail' do
23
- expect(error.detail).to eql 'Either the username or password passed in ' \
24
- 'or this request is invalid. Please ' \
25
- 'double-check and try again.'
26
- end
27
-
28
- it 'can output the source' do
29
- error = InvalidUsernameOrPasswordError.new username: 'neo'
30
-
31
- expect(error.source).to eql(username: 'neo', password: '[FILTERED]')
32
- end
33
- end
34
- end
35
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/errors/authorization_errors/forbidden_error'
4
-
5
- class Erratum
6
- module Errors
7
- RSpec.describe ForbiddenError do
8
- let(:error) { ForbiddenError.new }
9
-
10
- it 'has a status of 403' do
11
- expect(error.http_status).to eql 403
12
- end
13
-
14
- it 'has a code' do
15
- expect(error.code).to eql 'errors.forbidden_error'
16
- end
17
-
18
- it 'has a title' do
19
- expect(error.title).to eql 'Forbidden'
20
- end
21
-
22
- it 'can output the detail for actions affecting a specific resource' do
23
- error = ForbiddenError.new(resource_name: 'resource',
24
- resource_id: '123',
25
- action: 'show')
26
-
27
- expect(error.detail).to eql \
28
- 'You do not have access to show the resource with ID 123. Providing a different ' \
29
- 'set of credentials may potentially allow you access to this resource.'
30
- end
31
-
32
- it 'can output the detail for actions affecting multiple resources' do
33
- error = ForbiddenError.new(resource_name: 'resource',
34
- action: 'create')
35
-
36
- expect(error.detail).to eql \
37
- 'You do not have access to create a resource. Providing a different ' \
38
- 'set of credentials may potentially allow you access to this resource.'
39
- end
40
-
41
- it 'can output the source' do
42
- error = ForbiddenError.new(resource_name: 'resource',
43
- resource_id: '123',
44
- action: 'show')
45
-
46
- expect(error.source).to eql('resource_name' => 'resource',
47
- 'resource_id' => '123',
48
- 'action' => 'show')
49
- end
50
- end
51
- end
52
- end
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/errors/crud_errors/association_error'
4
- require 'active_record/errors'
5
-
6
- class Erratum
7
- module Errors
8
- RSpec.describe AssociationError do
9
- let(:foreign_key_error) do
10
- ActiveRecord::InvalidForeignKey.new('DETAIL: Key (resource_id)=(123)')
11
- end
12
-
13
- it 'has a status of 422' do
14
- error = AssociationError.new
15
-
16
- expect(error.http_status).to eql 422
17
- end
18
-
19
- it 'has a code' do
20
- error = AssociationError.new
21
-
22
- expect(error.code).to eql 'errors.association_error'
23
- end
24
-
25
- it 'has a title' do
26
- error = AssociationError.new
27
-
28
- expect(error.title).to eql 'Association Error'
29
- end
30
-
31
- it 'includes the resource name and action in the detail' do
32
- error = AssociationError.new association_name: 'dragon',
33
- resource_name: 'Daenerys'
34
-
35
- expect(error.detail).to eql 'The dragon that you ' \
36
- 'attempted to associate with the Daenerys was ' \
37
- 'not valid.'
38
- end
39
-
40
- it 'includes the resource name and action in the source' do
41
- error = AssociationError.new association_name: 'dragon',
42
- resource_name: 'Daenerys',
43
- attributes: 'winter is coming',
44
- association_id: '123'
45
-
46
- expect(error.source).to eql(
47
- 'Daenerys' => 'winter is coming',
48
- 'dragon id' => '123',
49
- )
50
- end
51
-
52
- it 'can convert an "ActiveRecord::InvalidForeignKey"' do
53
- error = AssociationError.convert(foreign_key_error)
54
-
55
- expect(error.resource_name).to eql nil
56
- expect(error.association_name).to eql 'resource'
57
- expect(error.association_id).to eql '123'
58
- end
59
-
60
- it 'can convert an "ActiveRecord::InvalidForeignKey" while overriding attributes' do
61
- error = AssociationError.convert(foreign_key_error, resource_name: 'my_resource')
62
-
63
- expect(error.resource_name).to eql 'my_resource'
64
- expect(error.association_name).to eql 'resource'
65
- expect(error.association_id).to eql '123'
66
- end
67
- end
68
- end
69
- end
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/errors/crud_errors/resource_not_found_error'
4
- require 'active_record/errors'
5
-
6
- class Erratum
7
- module Errors
8
- RSpec.describe ResourceNotFoundError do
9
- it 'has a status of 404' do
10
- error = ResourceNotFoundError.new
11
-
12
- expect(error.http_status).to eql 404
13
- end
14
-
15
- it 'has a code' do
16
- error = ResourceNotFoundError.new
17
-
18
- expect(error.code).to eql 'errors.resource_not_found_error'
19
- end
20
-
21
- it 'has a title' do
22
- error = ResourceNotFoundError.new
23
-
24
- expect(error.title).to eql 'Resource Not Found'
25
- end
26
-
27
- it 'includes the resource name and action in the detail' do
28
- error = ResourceNotFoundError.new resource_name: 'dragon',
29
- action: 'ride'
30
-
31
- expect(error.detail).to eql 'The dragon you attempted ' \
32
- 'to ride for this request is either ' \
33
- 'not authorized for the authenticated user ' \
34
- 'or does not exist.'
35
- end
36
-
37
- it 'includes the resource name and action in the source' do
38
- error = ResourceNotFoundError.new resource_name: 'dragon',
39
- resource_id: 123
40
-
41
- expect(error.source).to eql('dragon_id' => 123)
42
- end
43
-
44
- it 'can accept an array of IDs' do
45
- error = ResourceNotFoundError.new resource_name: 'dragon',
46
- resource_id: %w{123 456}
47
-
48
- expect(error.source).to eql('dragon_id' => %w{123 456})
49
- end
50
-
51
- it 'can convert an "ActiveRecord::RecordNotFound" with no IDs' do
52
- record_not_found_error = ActiveRecord::RecordNotFound.new \
53
- "Couldn't find resource without an ID"
54
- error = ResourceNotFoundError.convert(record_not_found_error)
55
-
56
- expect(error.resource_name).to eql nil
57
- expect(error.resource_id).to eql []
58
- end
59
-
60
- it 'can convert an "ActiveRecord::RecordNotFound" with one ID' do
61
- record_not_found_error = ActiveRecord::RecordNotFound.new \
62
- "Couldn't find resource with 'id'=123"
63
- error = ResourceNotFoundError.convert(record_not_found_error)
64
-
65
- expect(error.resource_name).to eql nil
66
- expect(error.resource_id).to eql %w{123}
67
- end
68
-
69
- it 'can convert an "ActiveRecord::RecordNotFound" with multiple IDs' do
70
- record_not_found_error = ActiveRecord::RecordNotFound.new \
71
- "Couldn't find all resource with 'id': 123, 456, 789"
72
- error = ResourceNotFoundError.convert(record_not_found_error)
73
-
74
- expect(error.resource_name).to eql nil
75
- expect(error.resource_id).to eql %w{123 456 789}
76
- end
77
-
78
- it 'can convert an "ActiveRecord::RecordNotFound" while overriding attributes' do
79
- record_not_found_error = ActiveRecord::RecordNotFound.new \
80
- "Couldn't find resource with 'id'=123"
81
- error = ResourceNotFoundError.convert(record_not_found_error,
82
- resource_name: 'my_resource')
83
-
84
- expect(error.resource_name).to eql 'my_resource'
85
- expect(error.resource_id).to eql %w{123}
86
- end
87
- end
88
- end
89
- end
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/errors/crud_errors/resource_persistence_error'
4
- require 'active_support'
5
- require 'active_model'
6
- require 'active_record/errors'
7
- require 'active_record/validations'
8
-
9
- class ErratumTestModel
10
- include ActiveModel::Model
11
- include ActiveModel::AttributeMethods
12
-
13
- attr_accessor :some_attribute
14
-
15
- validates_presence_of :some_attribute
16
-
17
- def attributes
18
- {
19
- 'some_attribute' => @some_attribute,
20
- }
21
- end
22
- end
23
-
24
- class Erratum
25
- module Errors
26
- RSpec.describe ResourcePersistenceError do
27
- it 'has a status of 422' do
28
- error = ResourcePersistenceError.new
29
-
30
- expect(error.http_status).to eql 422
31
- end
32
-
33
- it 'has a code' do
34
- error = ResourcePersistenceError.new
35
-
36
- expect(error.code).to eql 'errors.resource_persistence_error'
37
- end
38
-
39
- it 'has a title' do
40
- error = ResourcePersistenceError.new
41
-
42
- expect(error.title).to eql 'Resource Persistence Error'
43
- end
44
-
45
- it 'includes the resource name and action in the detail' do
46
- error = ResourcePersistenceError.new resource_name: 'dragon',
47
- action: 'ride'
48
-
49
- expect(error.detail).to eql 'One or more of the attributes on the dragon you ' \
50
- 'attempted to ride is invalid.'
51
- end
52
-
53
- it 'includes the resource name and action in the source' do
54
- error = ResourcePersistenceError.new pointer: '/data/pointer/stuff',
55
- attribute: 'my_attribute',
56
- value: 'my_value'
57
-
58
- expect(error.source).to eql('pointer' => '/data/pointer/stuff',
59
- 'parameter' => 'my_attribute',
60
- 'value' => 'my_value')
61
- end
62
-
63
- it 'can convert an "ActiveRecord::RecordNotSaved"' do
64
- record = ErratumTestModel.new
65
- record.valid?
66
- resource_persistence_error = ActiveRecord::RecordNotSaved.new('message', record)
67
- errors = ResourcePersistenceError.
68
- convert(resource_persistence_error)
69
- error = errors.first
70
-
71
- expect(error.pointer).to eql '/data/attributes/some_attribute'
72
- expect(error.attribute).to eql 'someAttribute'
73
- expect(error.value).to eql ''
74
- expect(error.detail).to eql "Some attribute can't be blank"
75
- end
76
-
77
- it 'can convert an "ActiveRecord::RecordInvalid"' do
78
- record = ErratumTestModel.new
79
- record.valid?
80
- resource_persistence_error = ActiveRecord::RecordInvalid.new(record)
81
- errors = ResourcePersistenceError.
82
- convert(resource_persistence_error)
83
- error = errors.first
84
-
85
- expect(error.pointer).to eql '/data/attributes/some_attribute'
86
- expect(error.attribute).to eql 'someAttribute'
87
- expect(error.value).to eql ''
88
- expect(error.detail).to eql "Some attribute can't be blank"
89
- end
90
- end
91
- end
92
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum'
4
- require 'action_controller'
5
-
6
- class Erratum
7
- module Errors
8
- RSpec.describe ParameterMissingError do
9
- it 'has a status' do
10
- error = ParameterMissingError.new
11
-
12
- expect(error.http_status).to eql 400
13
- end
14
-
15
- it 'has a code' do
16
- error = ParameterMissingError.new
17
-
18
- expect(error.code).to eql 'errors.parameter_missing_error'
19
- end
20
-
21
- it 'has a title' do
22
- error = ParameterMissingError.new
23
-
24
- expect(error.title).to eql 'Missing Parameter'
25
- end
26
-
27
- it 'includes the resource name and action in the detail' do
28
- error = ParameterMissingError.new resource_name: 'dragon',
29
- action: 'create',
30
- parameter: 'color'
31
-
32
- expect(error.detail).to eql "When attempting to create a dragon, 'color' is " \
33
- "a required parameter."
34
- end
35
-
36
- it 'includes the resource name and action in the source' do
37
- error = ParameterMissingError.new parameter: 'dragon'
38
-
39
- expect(error.source).to eql('required_parameter' => 'dragon')
40
- end
41
-
42
- it 'can convert an "ActionController::ParameterMissing"' do
43
- parameter_missing_error = ActionController::ParameterMissing.new('dragon')
44
- error = ParameterMissingError.convert(parameter_missing_error)
45
-
46
- expect(error.parameter).to eql 'dragon'
47
- end
48
-
49
- it 'can convert an "ActionController::ParameterMissing" while overriding attributes' do
50
- parameter_missing_error = ActionController::ParameterMissing.new('dragon')
51
- error = ParameterMissingError.convert(parameter_missing_error,
52
- parameter: 'westeros')
53
-
54
- expect(error.parameter).to eql 'westeros'
55
- end
56
- end
57
- end
58
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum'
4
- require 'action_controller'
5
-
6
- class Erratum
7
- module Errors
8
- RSpec.describe UnpermittedParametersError do
9
- it 'has a status' do
10
- error = UnpermittedParametersError.new
11
-
12
- expect(error.http_status).to eql 400
13
- end
14
-
15
- it 'has a code' do
16
- error = UnpermittedParametersError.new
17
-
18
- expect(error.code).to eql 'errors.unpermitted_parameters_error'
19
- end
20
-
21
- it 'has a title' do
22
- error = UnpermittedParametersError.new
23
-
24
- expect(error.title).to eql 'Unpermitted Parameters'
25
- end
26
-
27
- it 'includes the resource name and action in the detail' do
28
- error = UnpermittedParametersError.new resource_name: 'dragon',
29
- action: 'create',
30
- parameters: 'color'
31
-
32
- expect(error.detail).to eql 'Attempting to create a dragon with the ' \
33
- 'following parameters is not allowed: color'
34
- end
35
-
36
- it 'includes the resource name and action in the detail' do
37
- error = UnpermittedParametersError.new resource_name: 'dragon',
38
- action: 'create',
39
- parameters: %w{color size}
40
-
41
- expect(error.detail).to eql 'Attempting to create a dragon with the ' \
42
- 'following parameters is not allowed: color, size'
43
- end
44
-
45
- it 'includes the resource name and action in the source' do
46
- error = UnpermittedParametersError.new parameters: 'dragon'
47
-
48
- expect(error.source).to eql('unpermitted_parameters' => ['dragon'])
49
- end
50
-
51
- it 'can convert an "ActionController::UnpermittedParameters"' do
52
- parameters_error = ActionController::UnpermittedParameters.new(%w{dragon})
53
- error = UnpermittedParametersError.convert(parameters_error)
54
-
55
- expect(error.parameters).to eql %w{dragon}
56
- end
57
-
58
- it 'can convert an "ActionController::ParameterMissing" while overriding attributes' do
59
- parameters_error = ActionController::UnpermittedParameters.new(%w{dragon})
60
- error = UnpermittedParametersError.convert(parameters_error,
61
- parameters: 'westeros')
62
-
63
- expect(error.parameters).to eql %w{westeros}
64
- end
65
- end
66
- end
67
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum/rescuable_resource'
4
-
5
- class Erratum
6
- RSpec.describe RescuableResource do
7
- end
8
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspeckled'
3
- require 'erratum'
4
- require 'active_record/errors'
5
-
6
- RSpec.describe Erratum do
7
- let(:original_error) do
8
- ActiveRecord::RecordNotFound.new("Couldn't find resource with 'id'=3")
9
- end
10
-
11
- it 'can lookup errors' do
12
- expect(Erratum.fetch('InvalidTokenError')).to \
13
- eql Erratum::Errors::InvalidTokenError
14
- end
15
-
16
- it 'can raise an error' do
17
- expect { Erratum.raise('InvalidTokenError') }.to \
18
- raise_error Erratum::Errors::InvalidTokenError
19
- end
20
- end