servactory 2.5.0.rc1 → 2.5.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +0 -3
- 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/version.rb +1 -1
- data/lib/servactory.rb +1 -0
- metadata +21 -2
@@ -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
|
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.rc3
|
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-23 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,6 +322,19 @@ 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
|