evil-client 2.1.1 → 3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ccf12ec7a65e3b93d702235488587267b4b63bf
4
- data.tar.gz: 24d639ea31d94a956cf919c873098f3ec2beea75
3
+ metadata.gz: 7421a1b4c64b31e781aa9a7b8468d2590bbdb89a
4
+ data.tar.gz: accdb2d3b7687f9e2729a319bd52059f0c13f656
5
5
  SHA512:
6
- metadata.gz: c0db70d946408b64ec9875605b37c7f26af598c0f062c31bf4524ddb820b41ff43d598626e9f865ffd859ab7a911c7c20c4add08f3e080ab0ba6e83c128ba050
7
- data.tar.gz: 25f5a6ffb7c7c05ed40ceb47a3899ce651db16453f7561b631c6bb680a4713b963ba10eb291044a4ce168d9fd653abe214537555828bf0882471018020f6cf39
6
+ metadata.gz: a7e681e013572dca96e759387b5c4fa3462e4dcd78f173376628fd620e839e2e388409f1f57cb97157e7a16b431e925dbd2ef5f5593627c6e1a89223a74ed9ec
7
+ data.tar.gz: a5327b283c6481d972dd9f0c3939200e55c1b6e9021d918997cb6cc3a956b3d2612d47228c3e4ad6cb77a6c03b198a891300b477dff7d5ea980f02daae8b1a1e
@@ -6,6 +6,10 @@ AllCops:
6
6
  Lint/AmbiguousBlockAssociation:
7
7
  Enabled: false
8
8
 
9
+ Naming/FileName:
10
+ Exclude:
11
+ - lib/evil-client.rb
12
+
9
13
  Metrics/BlockLength:
10
14
  Enabled: false
11
15
 
@@ -18,10 +22,6 @@ Style/ClassAndModuleChildren:
18
22
  Style/DateTime:
19
23
  Enabled: false
20
24
 
21
- Style/FileName:
22
- Exclude:
23
- - lib/evil-client.rb
24
-
25
25
  Style/FrozenStringLiteralComment:
26
26
  Enabled: false
27
27
 
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog], and this project adheres
5
5
  to [Semantic Versioning].
6
6
 
7
+ ## [3.0.0] [2018-01-05]
8
+
9
+ ### [BREAKING] Changed
10
+
11
+ - Stop re-raising exceptions in model constructors, and remove `Evil::Client::ValidationError` (nepalez)
12
+
13
+ Instead of ValidationError, the original StandardError exceptions will be risen.
14
+
15
+ See [the issue #22 by Envek](https://github.com/evilmartians/evil-client/issues/22)
16
+
7
17
  ## [2.1.1] [2018-01-05]
8
18
 
9
19
  ### Changed
@@ -447,3 +457,5 @@ formats will be added.
447
457
  [1.1.0]: https://github.com/evilmartians/evil-client/compare/v1.0.0...v1.1.0
448
458
  [2.0.0]: https://github.com/evilmartians/evil-client/compare/v1.1.0...v2.0.0
449
459
  [2.1.0]: https://github.com/evilmartians/evil-client/compare/v2.0.0...v2.1.0
460
+ [2.1.1]: https://github.com/evilmartians/evil-client/compare/v2.1.0...v2.1.1
461
+ [3.0.0]: https://github.com/evilmartians/evil-client/compare/v2.1.1...v3.0.0
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "evil-client"
3
- gem.version = "2.1.1"
3
+ gem.version = "3.0.0"
4
4
  gem.author = ["Andrew Kozin (nepalez)", "Ravil Bairamgalin (brainopia)"]
5
5
  gem.email = ["andrew.kozin@gmail.com", "nepalez@evilmartians.com"]
6
6
  gem.homepage = "https://github.com/evilmartians/evil-client"
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.add_runtime_dependency "dry-initializer", "~> 2.1"
17
17
  gem.add_runtime_dependency "mime-types", "~> 3.1"
18
18
  gem.add_runtime_dependency "rack", "~> 2"
19
- gem.add_runtime_dependency "tram-policy", "~> 0.2.3"
19
+ gem.add_runtime_dependency "tram-policy", "~> 0.3.0"
20
20
 
21
21
  gem.add_development_dependency "rake", ">= 10"
22
22
  gem.add_development_dependency "rspec", "~> 3.0"
@@ -25,7 +25,6 @@ module Evil
25
25
  require_relative "client/exceptions/name_error"
26
26
  require_relative "client/exceptions/response_error"
27
27
  require_relative "client/exceptions/type_error"
28
- require_relative "client/exceptions/validation_error"
29
28
 
30
29
  require_relative "client/chaining"
31
30
  require_relative "client/options"
@@ -93,8 +93,6 @@ class Evil::Client
93
93
  def new(op = {})
94
94
  op = Hash(op).each_with_object({}) { |(k, v), obj| obj[k.to_sym] = v }
95
95
  super(op).tap { |item| in_english { policy[item].validate! } }
96
- rescue StandardError => error
97
- raise ValidationError, error.message
98
96
  end
99
97
  alias call new
100
98
  alias [] call
@@ -48,24 +48,24 @@ RSpec.describe "operation options" do
48
48
  context "when required options missed" do
49
49
  subject { users.operations[:create].new(language: "it") }
50
50
 
51
- it "raises Evil::Client::ValidationError" do
52
- expect { subject }.to raise_error Evil::Client::ValidationError, /name/
51
+ it "raises StandardError" do
52
+ expect { subject }.to raise_error StandardError, /name/
53
53
  end
54
54
  end
55
55
 
56
56
  context "when operation validation failed" do
57
57
  subject { users.operations[:filter].new }
58
58
 
59
- it "raises Evil::Client::ValidationError" do
60
- expect { subject }.to raise_error Evil::Client::ValidationError, /id/
59
+ it "raises StandardError" do
60
+ expect { subject }.to raise_error StandardError, /id/
61
61
  end
62
62
  end
63
63
 
64
64
  context "when scope validation failed" do
65
65
  subject { users.operations[:fetch].new id: 8, token: nil }
66
66
 
67
- it "raises Evil::Client::ValidationError" do
68
- expect { subject }.to raise_error Evil::Client::ValidationError, /token/
67
+ it "raises StandardError" do
68
+ expect { subject }.to raise_error StandardError, /token/
69
69
  end
70
70
  end
71
71
  end
@@ -35,18 +35,18 @@ RSpec.describe "scope options" do
35
35
  context "when required options missed" do
36
36
  subject { client.crm }
37
37
 
38
- it "raises Evil::Client::ValidationError" do
38
+ it "raises StandardError" do
39
39
  expect { subject }
40
- .to raise_error Evil::Client::ValidationError, /version/
40
+ .to raise_error StandardError, /version/
41
41
  end
42
42
  end
43
43
 
44
44
  context "when some validation failed" do
45
45
  subject { crm.users(token: nil) }
46
46
 
47
- it "raises Evil::Client::ValidationError" do
47
+ it "raises StandardError" do
48
48
  expect { subject }
49
- .to raise_error Evil::Client::ValidationError, /token/
49
+ .to raise_error StandardError, /token/
50
50
  end
51
51
  end
52
52
  end
@@ -69,7 +69,7 @@ RSpec.describe Evil::Client::Model do
69
69
  it "adds validation for an instance" do
70
70
  # see spec/fixtures/locale/en.yml
71
71
  expect { model }
72
- .to raise_error(Evil::Client::ValidationError, /The user has no name/)
72
+ .to raise_error(StandardError, /The user has no name/)
73
73
  end
74
74
  end
75
75
 
@@ -79,8 +79,8 @@ RSpec.describe Evil::Client::Model do
79
79
  context "with wrong options" do
80
80
  before { klass.option :user, as: :customer }
81
81
 
82
- it "raises Evil::Client::ValidationError" do
83
- expect { subject }.to raise_error Evil::Client::ValidationError, /user/
82
+ it "raises StandardError" do
83
+ expect { subject }.to raise_error StandardError, /user/
84
84
  end
85
85
  end
86
86
  end
@@ -98,7 +98,7 @@ RSpec.describe Evil::Client::Settings do
98
98
  it "adds validation for an instance" do
99
99
  # see spec/fixtures/locale/en.yml
100
100
  expect { settings }
101
- .to raise_error(Evil::Client::ValidationError, /The user has no name/)
101
+ .to raise_error(StandardError, /The user has no name/)
102
102
  end
103
103
  end
104
104
 
@@ -161,8 +161,8 @@ RSpec.describe Evil::Client::Settings do
161
161
  context "with wrong options" do
162
162
  before { klass.option :user, as: :customer }
163
163
 
164
- it "raises Evil::Client::ValidationError" do
165
- expect { subject }.to raise_error Evil::Client::ValidationError, /user/
164
+ it "raises StandardError" do
165
+ expect { subject }.to raise_error StandardError, /user/
166
166
  end
167
167
  end
168
168
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evil-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin (nepalez)
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-04 00:00:00.000000000 Z
12
+ date: 2018-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-initializer
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 0.2.3
62
+ version: 0.3.0
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 0.2.3
69
+ version: 0.3.0
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rake
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -205,7 +205,6 @@ files:
205
205
  - lib/evil/client/exceptions/name_error.rb
206
206
  - lib/evil/client/exceptions/response_error.rb
207
207
  - lib/evil/client/exceptions/type_error.rb
208
- - lib/evil/client/exceptions/validation_error.rb
209
208
  - lib/evil/client/formatter.rb
210
209
  - lib/evil/client/formatter/form.rb
211
210
  - lib/evil/client/formatter/multipart.rb
@@ -259,7 +258,6 @@ files:
259
258
  - spec/unit/exceptions/name_error_spec.rb
260
259
  - spec/unit/exceptions/response_error_spec.rb
261
260
  - spec/unit/exceptions/type_error_spec.rb
262
- - spec/unit/exceptions/validation_error_spec.rb
263
261
  - spec/unit/formatter/form_spec.rb
264
262
  - spec/unit/formatter/multipart_spec.rb
265
263
  - spec/unit/formatter/part_spec.rb
@@ -333,7 +331,6 @@ test_files:
333
331
  - spec/unit/exceptions/name_error_spec.rb
334
332
  - spec/unit/exceptions/response_error_spec.rb
335
333
  - spec/unit/exceptions/type_error_spec.rb
336
- - spec/unit/exceptions/validation_error_spec.rb
337
334
  - spec/unit/formatter/form_spec.rb
338
335
  - spec/unit/formatter/multipart_spec.rb
339
336
  - spec/unit/formatter/part_spec.rb
@@ -1,27 +0,0 @@
1
- class Evil::Client
2
- #
3
- # Exception to be risen when scope or operation cannot be initialized
4
- # due to some options or their composition are invalid
5
- #
6
- class ValidationError < ArgumentError
7
- private
8
-
9
- def initialize(key, scope = nil, **options)
10
- scope = "evil.client.errors.#{scope}"
11
- .split(".")
12
- .map { |part| __underscore__(part) }
13
-
14
- super key.is_a?(Symbol) ? I18n.t(key, scope: scope, **options) : key
15
- end
16
-
17
- def __underscore__(name)
18
- name.dup.tap do |n|
19
- n.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
20
- n.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
21
- n.gsub!("::", "/")
22
- n.tr!("-", "_")
23
- n.downcase!
24
- end
25
- end
26
- end
27
- end
@@ -1,13 +0,0 @@
1
- RSpec.describe Evil::Client::ValidationError, "#message" do
2
- let(:error) { described_class.new key, scope, options }
3
- let(:key) { :token_present }
4
- let(:scope) { "Test::Api.users.update" }
5
- let(:options) { { id: 3, name: "Andrew" } }
6
-
7
- subject { error.message }
8
-
9
- it "builds a proper error message" do
10
- # see spec/fixtures/locales/en.yml
11
- expect(subject).to eq "To update user id:3 you must provide a token"
12
- end
13
- end