servactory 2.5.0.rc2 → 2.5.0.rc4
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/README.md +1 -1
- data/lib/generators/servactory/install_generator.rb +21 -0
- data/lib/generators/servactory/rspec_generator.rb +88 -0
- data/lib/generators/servactory/service_generator.rb +49 -0
- data/lib/generators/servactory/templates/services/application_service/base.rb +60 -0
- data/lib/generators/servactory/templates/services/application_service/exceptions.rb +11 -0
- data/lib/generators/servactory/templates/services/application_service/result.rb +5 -0
- data/lib/servactory/context/workspace/internals.rb +1 -1
- data/lib/servactory/info/dsl.rb +56 -4
- data/lib/servactory/maintenance/attributes/options/registrar.rb +1 -1
- data/lib/servactory/result.rb +1 -1
- data/lib/servactory/test_kit/rspec/helpers.rb +95 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/consists_of_matcher.rb +121 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/inclusion_matcher.rb +70 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/must_matcher.rb +61 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/types_matcher.rb +72 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matcher.rb +203 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/default_matcher.rb +67 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/optional_matcher.rb +63 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/required_matcher.rb +78 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +233 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_internal_matcher.rb +148 -0
- data/lib/servactory/test_kit/rspec/matchers.rb +295 -0
- data/lib/servactory/test_kit/utils/faker.rb +78 -0
- data/lib/servactory/tool_kit/dynamic_options/format.rb +16 -12
- data/lib/servactory/version.rb +1 -1
- data/lib/servactory.rb +1 -0
- metadata +26 -7
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module TestKit
|
5
|
+
module Utils
|
6
|
+
module Faker
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def fetch_value_for(class_or_name, of: :string) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
10
|
+
class_for_fake = Servactory::Utils.constantize_class(class_or_name)
|
11
|
+
of = of.to_sym
|
12
|
+
|
13
|
+
faker = {
|
14
|
+
Symbol => method(:fake_symbol),
|
15
|
+
String => method(:fake_string),
|
16
|
+
Integer => method(:fake_integer),
|
17
|
+
Float => method(:fake_float),
|
18
|
+
Range => method(:fake_range),
|
19
|
+
Array => -> { fake_array(of) },
|
20
|
+
Hash => -> { fake_hash(of) },
|
21
|
+
TrueClass => method(:fake_true_class),
|
22
|
+
FalseClass => method(:fake_false_class),
|
23
|
+
NilClass => method(:fake_nil_class)
|
24
|
+
}
|
25
|
+
|
26
|
+
fake_klass = faker[class_for_fake] || -> { unsupported_faker(class_for_fake) }
|
27
|
+
fake_klass.call
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fake_symbol
|
33
|
+
:fake
|
34
|
+
end
|
35
|
+
|
36
|
+
def fake_string
|
37
|
+
"fake"
|
38
|
+
end
|
39
|
+
|
40
|
+
def fake_integer
|
41
|
+
123
|
42
|
+
end
|
43
|
+
|
44
|
+
def fake_float
|
45
|
+
12.3
|
46
|
+
end
|
47
|
+
|
48
|
+
def fake_range
|
49
|
+
1..3
|
50
|
+
end
|
51
|
+
|
52
|
+
def fake_array(of)
|
53
|
+
of == :integer ? [1, 2, 3] : ["fake"]
|
54
|
+
end
|
55
|
+
|
56
|
+
def fake_hash(of)
|
57
|
+
of == :integer ? { fake: 1 } : { fake: :yes }
|
58
|
+
end
|
59
|
+
|
60
|
+
def fake_true_class
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
def fake_false_class
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
def fake_nil_class
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def unsupported_faker(class_for_fake)
|
73
|
+
class_for_fake.respond_to?(:new) ? class_for_fake.new : class_for_fake
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -3,16 +3,24 @@
|
|
3
3
|
module Servactory
|
4
4
|
module ToolKit
|
5
5
|
module DynamicOptions
|
6
|
-
class Format < Must
|
6
|
+
class Format < Must # rubocop:disable Metrics/ClassLength
|
7
7
|
DEFAULT_FORMATS = {
|
8
|
-
|
9
|
-
pattern: /^
|
10
|
-
validator: ->(value:) {
|
8
|
+
uuid: {
|
9
|
+
pattern: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
10
|
+
validator: ->(value:) { value.present? }
|
11
11
|
},
|
12
12
|
email: {
|
13
13
|
pattern: URI::MailTo::EMAIL_REGEXP,
|
14
14
|
validator: ->(value:) { value.present? }
|
15
15
|
},
|
16
|
+
password: {
|
17
|
+
# NOTE: Pattern 4 » https://dev.to/rasaf_ibrahim/write-regex-password-validation-like-a-pro-5175
|
18
|
+
# Password must contain one digit from 1 to 9, one lowercase letter, one
|
19
|
+
# uppercase letter, and one underscore, and it must be 8-16 characters long.
|
20
|
+
# Usage of any other special character and usage of space is optional.
|
21
|
+
pattern: /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,16}$/,
|
22
|
+
validator: ->(value:) { value.present? }
|
23
|
+
},
|
16
24
|
date: {
|
17
25
|
pattern: nil,
|
18
26
|
validator: lambda do |value:|
|
@@ -29,14 +37,6 @@ module Servactory
|
|
29
37
|
false
|
30
38
|
end
|
31
39
|
},
|
32
|
-
password: {
|
33
|
-
# NOTE: Pattern 4 » https://dev.to/rasaf_ibrahim/write-regex-password-validation-like-a-pro-5175
|
34
|
-
# Password must contain one digit from 1 to 9, one lowercase letter, one
|
35
|
-
# uppercase letter, and one underscore, and it must be 8-16 characters long.
|
36
|
-
# Usage of any other special character and usage of space is optional.
|
37
|
-
pattern: /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,16}$/,
|
38
|
-
validator: ->(value:) { value.present? }
|
39
|
-
},
|
40
40
|
time: {
|
41
41
|
pattern: nil,
|
42
42
|
validator: lambda do |value:|
|
@@ -44,6 +44,10 @@ module Servactory
|
|
44
44
|
rescue ArgumentError
|
45
45
|
false
|
46
46
|
end
|
47
|
+
},
|
48
|
+
boolean: {
|
49
|
+
pattern: /^(true|false|0|1)$/i,
|
50
|
+
validator: ->(value:) { %w[true 1].include?(value&.downcase) }
|
47
51
|
}
|
48
52
|
}.freeze
|
49
53
|
private_constant :DEFAULT_FORMATS
|
data/lib/servactory/version.rb
CHANGED
data/lib/servactory.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.0.
|
4
|
+
version: 2.5.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -237,6 +237,12 @@ files:
|
|
237
237
|
- Rakefile
|
238
238
|
- config/locales/en.yml
|
239
239
|
- config/locales/ru.yml
|
240
|
+
- lib/generators/servactory/install_generator.rb
|
241
|
+
- lib/generators/servactory/rspec_generator.rb
|
242
|
+
- lib/generators/servactory/service_generator.rb
|
243
|
+
- lib/generators/servactory/templates/services/application_service/base.rb
|
244
|
+
- lib/generators/servactory/templates/services/application_service/exceptions.rb
|
245
|
+
- lib/generators/servactory/templates/services/application_service/result.rb
|
240
246
|
- lib/servactory.rb
|
241
247
|
- lib/servactory/actions/action.rb
|
242
248
|
- lib/servactory/actions/aliases/collection.rb
|
@@ -316,21 +322,34 @@ files:
|
|
316
322
|
- lib/servactory/result.rb
|
317
323
|
- lib/servactory/test_kit/fake_type.rb
|
318
324
|
- lib/servactory/test_kit/result.rb
|
325
|
+
- lib/servactory/test_kit/rspec/helpers.rb
|
326
|
+
- lib/servactory/test_kit/rspec/matchers.rb
|
327
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/consists_of_matcher.rb
|
328
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/inclusion_matcher.rb
|
329
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/must_matcher.rb
|
330
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/types_matcher.rb
|
331
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_input_matcher.rb
|
332
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/default_matcher.rb
|
333
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/optional_matcher.rb
|
334
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/required_matcher.rb
|
335
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb
|
336
|
+
- lib/servactory/test_kit/rspec/matchers/have_service_internal_matcher.rb
|
337
|
+
- lib/servactory/test_kit/utils/faker.rb
|
319
338
|
- lib/servactory/tool_kit/dynamic_options/format.rb
|
320
339
|
- lib/servactory/tool_kit/dynamic_options/max.rb
|
321
340
|
- lib/servactory/tool_kit/dynamic_options/min.rb
|
322
341
|
- lib/servactory/tool_kit/dynamic_options/must.rb
|
323
342
|
- lib/servactory/utils.rb
|
324
343
|
- lib/servactory/version.rb
|
325
|
-
homepage: https://github.com/
|
344
|
+
homepage: https://github.com/servactory/servactory
|
326
345
|
licenses:
|
327
346
|
- MIT
|
328
347
|
metadata:
|
329
|
-
homepage_uri: https://github.com/
|
348
|
+
homepage_uri: https://github.com/servactory/servactory
|
330
349
|
documentation_uri: https://servactory.com
|
331
|
-
source_code_uri: https://github.com/
|
332
|
-
bug_tracker_uri: https://github.com/
|
333
|
-
changelog_uri: https://github.com/
|
350
|
+
source_code_uri: https://github.com/servactory/servactory
|
351
|
+
bug_tracker_uri: https://github.com/servactory/servactory/issues
|
352
|
+
changelog_uri: https://github.com/servactory/servactory/blob/master/CHANGELOG.md
|
334
353
|
rubygems_mfa_required: 'true'
|
335
354
|
post_install_message:
|
336
355
|
rdoc_options: []
|