servus 0.1.3 → 0.1.4
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/.yardopts +6 -0
- data/CHANGELOG.md +7 -0
- data/IDEAS.md +5 -0
- data/READme.md +147 -42
- data/Rakefile +33 -0
- data/builds/servus-0.1.3.gem +0 -0
- data/builds/servus-0.1.4.gem +0 -0
- data/docs/core/1_overview.md +77 -0
- data/docs/core/2_architecture.md +92 -0
- data/docs/core/3_service_objects.md +121 -0
- data/docs/features/1_schema_validation.md +119 -0
- data/docs/features/2_error_handling.md +121 -0
- data/docs/features/3_async_execution.md +81 -0
- data/docs/features/4_logging.md +64 -0
- data/docs/guides/1_common_patterns.md +90 -0
- data/docs/guides/2_migration_guide.md +175 -0
- data/docs/integration/1_configuration.md +51 -0
- data/docs/integration/2_testing.md +164 -0
- data/docs/integration/3_rails_integration.md +99 -0
- data/docs/yard/Servus/Base.html +1645 -0
- data/docs/yard/Servus/Config.html +582 -0
- data/docs/yard/Servus/Extensions/Async/Call.html +400 -0
- data/docs/yard/Servus/Extensions/Async/Errors/AsyncError.html +140 -0
- data/docs/yard/Servus/Extensions/Async/Errors/JobEnqueueError.html +154 -0
- data/docs/yard/Servus/Extensions/Async/Errors/ServiceNotFoundError.html +154 -0
- data/docs/yard/Servus/Extensions/Async/Errors.html +128 -0
- data/docs/yard/Servus/Extensions/Async/Ext.html +119 -0
- data/docs/yard/Servus/Extensions/Async/Job.html +310 -0
- data/docs/yard/Servus/Extensions/Async.html +141 -0
- data/docs/yard/Servus/Extensions.html +117 -0
- data/docs/yard/Servus/Generators/ServiceGenerator.html +261 -0
- data/docs/yard/Servus/Generators.html +115 -0
- data/docs/yard/Servus/Helpers/ControllerHelpers.html +457 -0
- data/docs/yard/Servus/Helpers.html +115 -0
- data/docs/yard/Servus/Railtie.html +134 -0
- data/docs/yard/Servus/Support/Errors/AuthenticationError.html +287 -0
- data/docs/yard/Servus/Support/Errors/BadRequestError.html +283 -0
- data/docs/yard/Servus/Support/Errors/ForbiddenError.html +284 -0
- data/docs/yard/Servus/Support/Errors/InternalServerError.html +283 -0
- data/docs/yard/Servus/Support/Errors/NotFoundError.html +284 -0
- data/docs/yard/Servus/Support/Errors/ServiceError.html +489 -0
- data/docs/yard/Servus/Support/Errors/ServiceUnavailableError.html +290 -0
- data/docs/yard/Servus/Support/Errors/UnauthorizedError.html +200 -0
- data/docs/yard/Servus/Support/Errors/UnprocessableEntityError.html +288 -0
- data/docs/yard/Servus/Support/Errors/ValidationError.html +200 -0
- data/docs/yard/Servus/Support/Errors.html +140 -0
- data/docs/yard/Servus/Support/Logger.html +856 -0
- data/docs/yard/Servus/Support/Rescuer/BlockContext.html +585 -0
- data/docs/yard/Servus/Support/Rescuer/CallOverride.html +257 -0
- data/docs/yard/Servus/Support/Rescuer/ClassMethods.html +343 -0
- data/docs/yard/Servus/Support/Rescuer.html +267 -0
- data/docs/yard/Servus/Support/Response.html +574 -0
- data/docs/yard/Servus/Support/Validator.html +1150 -0
- data/docs/yard/Servus/Support.html +119 -0
- data/docs/yard/Servus/Testing/ExampleBuilders.html +523 -0
- data/docs/yard/Servus/Testing/ExampleExtractor.html +578 -0
- data/docs/yard/Servus/Testing.html +142 -0
- data/docs/yard/Servus.html +343 -0
- data/docs/yard/_index.html +535 -0
- data/docs/yard/class_list.html +54 -0
- data/docs/yard/css/common.css +1 -0
- data/docs/yard/css/full_list.css +58 -0
- data/docs/yard/css/style.css +503 -0
- data/docs/yard/file.1_common_patterns.html +154 -0
- data/docs/yard/file.1_configuration.html +115 -0
- data/docs/yard/file.1_overview.html +142 -0
- data/docs/yard/file.1_schema_validation.html +188 -0
- data/docs/yard/file.2_architecture.html +157 -0
- data/docs/yard/file.2_error_handling.html +190 -0
- data/docs/yard/file.2_migration_guide.html +242 -0
- data/docs/yard/file.2_testing.html +227 -0
- data/docs/yard/file.3_async_execution.html +145 -0
- data/docs/yard/file.3_rails_integration.html +160 -0
- data/docs/yard/file.3_service_objects.html +191 -0
- data/docs/yard/file.4_logging.html +135 -0
- data/docs/yard/file.ErrorHandling.html +190 -0
- data/docs/yard/file.READme.html +674 -0
- data/docs/yard/file.architecture.html +157 -0
- data/docs/yard/file.async_execution.html +145 -0
- data/docs/yard/file.common_patterns.html +154 -0
- data/docs/yard/file.configuration.html +115 -0
- data/docs/yard/file.error_handling.html +190 -0
- data/docs/yard/file.logging.html +135 -0
- data/docs/yard/file.migration_guide.html +242 -0
- data/docs/yard/file.overview.html +142 -0
- data/docs/yard/file.rails_integration.html +160 -0
- data/docs/yard/file.schema_validation.html +188 -0
- data/docs/yard/file.service_objects.html +191 -0
- data/docs/yard/file.testing.html +227 -0
- data/docs/yard/file_list.html +119 -0
- data/docs/yard/frames.html +22 -0
- data/docs/yard/index.html +674 -0
- data/docs/yard/js/app.js +344 -0
- data/docs/yard/js/full_list.js +242 -0
- data/docs/yard/js/jquery.js +4 -0
- data/docs/yard/method_list.html +542 -0
- data/docs/yard/top-level-namespace.html +110 -0
- data/lib/generators/servus/service/service_generator.rb +64 -1
- data/lib/generators/servus/service/templates/service.rb.erb +1 -1
- data/lib/servus/base.rb +258 -57
- data/lib/servus/config.rb +58 -12
- data/lib/servus/extensions/async/call.rb +50 -18
- data/lib/servus/extensions/async/errors.rb +23 -3
- data/lib/servus/extensions/async/ext.rb +10 -2
- data/lib/servus/extensions/async/job.rb +30 -9
- data/lib/servus/helpers/controller_helpers.rb +73 -37
- data/lib/servus/support/errors.rb +135 -45
- data/lib/servus/support/rescuer.rb +189 -36
- data/lib/servus/support/response.rb +49 -7
- data/lib/servus/support/validator.rb +120 -19
- data/lib/servus/testing/example_builders.rb +133 -0
- data/lib/servus/testing/example_extractor.rb +309 -0
- data/lib/servus/testing.rb +17 -0
- data/lib/servus/version.rb +1 -1
- metadata +117 -19
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>
|
|
7
|
+
Module: Servus::Support
|
|
8
|
+
|
|
9
|
+
— Servus | Service Object Framework
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript">
|
|
18
|
+
pathId = "Servus::Support";
|
|
19
|
+
relpath = '../';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div class="nav_wrap">
|
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
|
32
|
+
<div id="resizer"></div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div id="main" tabindex="-1">
|
|
36
|
+
<div id="header">
|
|
37
|
+
<div id="menu">
|
|
38
|
+
|
|
39
|
+
<a href="../_index.html">Index (S)</a> »
|
|
40
|
+
<span class='title'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span>
|
|
41
|
+
»
|
|
42
|
+
<span class="title">Support</span>
|
|
43
|
+
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div id="search">
|
|
47
|
+
|
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
|
49
|
+
href="../class_list.html">
|
|
50
|
+
|
|
51
|
+
<svg width="24" height="24">
|
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
55
|
+
</svg>
|
|
56
|
+
</a>
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
<div class="clear"></div>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div id="content"><h1>Module: Servus::Support
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
</h1>
|
|
67
|
+
<div class="box_info">
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<dl>
|
|
80
|
+
<dt>Defined in:</dt>
|
|
81
|
+
<dd>lib/servus/support/errors.rb<span class="defines">,<br />
|
|
82
|
+
lib/servus/support/logger.rb,<br /> lib/servus/support/rescuer.rb,<br /> lib/servus/support/response.rb,<br /> lib/servus/support/validator.rb</span>
|
|
83
|
+
</dd>
|
|
84
|
+
</dl>
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<h2>Defined Under Namespace</h2>
|
|
89
|
+
<p class="children">
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Errors</a></span>, <span class='object_link'><a href="Support/Rescuer.html" title="Servus::Support::Rescuer (module)">Rescuer</a></span>
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Support/Logger.html" title="Servus::Support::Logger (class)">Logger</a></span>, <span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Response</a></span>, <span class='object_link'><a href="Support/Validator.html" title="Servus::Support::Validator (class)">Validator</a></span>
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
</p>
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div id="footer">
|
|
112
|
+
Generated on Fri Nov 21 00:33:23 2025 by
|
|
113
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
114
|
+
0.9.37 (ruby-3.4.4).
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
</div>
|
|
118
|
+
</body>
|
|
119
|
+
</html>
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>
|
|
7
|
+
Module: Servus::Testing::ExampleBuilders
|
|
8
|
+
|
|
9
|
+
— Servus | Service Object Framework
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript">
|
|
18
|
+
pathId = "Servus::Testing::ExampleBuilders";
|
|
19
|
+
relpath = '../../';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div class="nav_wrap">
|
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
|
32
|
+
<div id="resizer"></div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div id="main" tabindex="-1">
|
|
36
|
+
<div id="header">
|
|
37
|
+
<div id="menu">
|
|
38
|
+
|
|
39
|
+
<a href="../../_index.html">Index (E)</a> »
|
|
40
|
+
<span class='title'><span class='object_link'><a href="../../Servus.html" title="Servus (module)">Servus</a></span></span> » <span class='title'><span class='object_link'><a href="../Testing.html" title="Servus::Testing (module)">Testing</a></span></span>
|
|
41
|
+
»
|
|
42
|
+
<span class="title">ExampleBuilders</span>
|
|
43
|
+
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div id="search">
|
|
47
|
+
|
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
|
49
|
+
href="../../class_list.html">
|
|
50
|
+
|
|
51
|
+
<svg width="24" height="24">
|
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
55
|
+
</svg>
|
|
56
|
+
</a>
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
<div class="clear"></div>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div id="content"><h1>Module: Servus::Testing::ExampleBuilders
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
</h1>
|
|
67
|
+
<div class="box_info">
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<dl>
|
|
80
|
+
<dt>Defined in:</dt>
|
|
81
|
+
<dd>lib/servus/testing/example_builders.rb</dd>
|
|
82
|
+
</dl>
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<h2>Overview</h2><div class="docstring">
|
|
87
|
+
<div class="discussion">
|
|
88
|
+
<p>Provides helper methods for extracting example values from service schemas.</p>
|
|
89
|
+
|
|
90
|
+
<p>This module is designed to be included in test files (RSpec, Minitest, etc.)
|
|
91
|
+
to provide convenient access to schema example values. It's particularly useful
|
|
92
|
+
for generating test fixtures without manually maintaining separate factory files.</p>
|
|
93
|
+
|
|
94
|
+
<p>The <code>servus_</code> prefix on method names prevents naming collisions with other
|
|
95
|
+
testing libraries and makes it clear these are Servus-specific helpers.</p>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="tags">
|
|
101
|
+
|
|
102
|
+
<div class="examples">
|
|
103
|
+
<h4 class="tag_title">Examples:</h4>
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<h5 class="example_title"><div class='inline'><p>Include in RSpec</p>
|
|
107
|
+
</div></h5>
|
|
108
|
+
|
|
109
|
+
<pre class="example code"><code><span class='comment'># spec/spec_helper.rb
|
|
110
|
+
</span><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>servus/testing/example_builders</span><span class='tstring_end'>'</span></span>
|
|
111
|
+
|
|
112
|
+
<span class='const'>RSpec</span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
|
|
113
|
+
<span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="../../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Testing.html" title="Servus::Testing (module)">Testing</a></span></span><span class='op'>::</span><span class='const'>ExampleBuilders</span>
|
|
114
|
+
<span class='kw'>end</span></code></pre>
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
<h5 class="example_title"><div class='inline'><p>Include in Rails console (development)</p>
|
|
118
|
+
</div></h5>
|
|
119
|
+
|
|
120
|
+
<pre class="example code"><code><span class='comment'># config/environments/development.rb
|
|
121
|
+
</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_to_prepare'>to_prepare</span> <span class='kw'>do</span>
|
|
122
|
+
<span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>servus/testing/example_builders</span><span class='tstring_end'>'</span></span>
|
|
123
|
+
|
|
124
|
+
<span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='const'>Rails</span><span class='op'>::</span><span class='const'>Console</span><span class='rparen'>)</span>
|
|
125
|
+
<span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="../../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Testing.html" title="Servus::Testing (module)">Testing</a></span></span><span class='op'>::</span><span class='const'>ExampleBuilders</span>
|
|
126
|
+
<span class='kw'>end</span>
|
|
127
|
+
<span class='kw'>end</span></code></pre>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
<h5 class="example_title"><div class='inline'><p>Use in tests</p>
|
|
131
|
+
</div></h5>
|
|
132
|
+
|
|
133
|
+
<pre class="example code"><code><span class='const'>RSpec</span><span class='period'>.</span><span class='id identifier rubyid_describe'>describe</span> <span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span> <span class='kw'>do</span>
|
|
134
|
+
<span class='id identifier rubyid_it'>it</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>processes payment successfully</span><span class='tstring_end'>'</span></span> <span class='kw'>do</span>
|
|
135
|
+
<span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='id identifier rubyid_servus_arguments_example'>servus_arguments_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='comma'>,</span> <span class='label'>amount:</span> <span class='float'>50.0</span><span class='rparen'>)</span>
|
|
136
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
137
|
+
|
|
138
|
+
<span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_be_success'>be_success</span>
|
|
139
|
+
<span class='kw'>end</span>
|
|
140
|
+
<span class='kw'>end</span></code></pre>
|
|
141
|
+
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
<h2>
|
|
154
|
+
Instance Method Summary
|
|
155
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
156
|
+
</h2>
|
|
157
|
+
|
|
158
|
+
<ul class="summary">
|
|
159
|
+
|
|
160
|
+
<li class="public ">
|
|
161
|
+
<span class="summary_signature">
|
|
162
|
+
|
|
163
|
+
<a href="#servus_arguments_example-instance_method" title="#servus_arguments_example (instance method)">#<strong>servus_arguments_example</strong>(service_class, overrides = {}) ⇒ Hash<Symbol, Object> </a>
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
</span>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
<span class="summary_desc"><div class='inline'><p>Extracts example argument values from a service's schema.</p>
|
|
178
|
+
</div></span>
|
|
179
|
+
|
|
180
|
+
</li>
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
<li class="public ">
|
|
184
|
+
<span class="summary_signature">
|
|
185
|
+
|
|
186
|
+
<a href="#servus_result_example-instance_method" title="#servus_result_example (instance method)">#<strong>servus_result_example</strong>(service_class, overrides = {}) ⇒ Servus::Support::Response </a>
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
</span>
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
<span class="summary_desc"><div class='inline'><p>Extracts example result values from a service's schema.</p>
|
|
201
|
+
</div></span>
|
|
202
|
+
|
|
203
|
+
</li>
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
</ul>
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
<div id="instance_method_details" class="method_details_list">
|
|
212
|
+
<h2>Instance Method Details</h2>
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
<div class="method_details first">
|
|
216
|
+
<h3 class="signature first" id="servus_arguments_example-instance_method">
|
|
217
|
+
|
|
218
|
+
#<strong>servus_arguments_example</strong>(service_class, overrides = {}) ⇒ <tt>Hash<Symbol, Object></tt>
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
</h3><div class="docstring">
|
|
225
|
+
<div class="discussion">
|
|
226
|
+
|
|
227
|
+
<div class="note notetag">
|
|
228
|
+
<strong>Note:</strong>
|
|
229
|
+
<div class='inline'><p>Override keys can be strings or symbols; they'll be converted to symbols</p>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<div class="note notetag">
|
|
234
|
+
<strong>Note:</strong>
|
|
235
|
+
<div class='inline'><p>Returns empty hash if service has no arguments schema defined</p>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
<p>Extracts example argument values from a service's schema.</p>
|
|
240
|
+
|
|
241
|
+
<p>Looks for <code>example</code> or <code>examples</code> keywords in the service's arguments schema
|
|
242
|
+
and returns them as a hash ready to be passed to the service's <code>.call</code> method.</p>
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
<div class="tags">
|
|
248
|
+
|
|
249
|
+
<div class="examples">
|
|
250
|
+
<h4 class="tag_title">Examples:</h4>
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
<h5 class="example_title"><div class='inline'><p>Basic usage</p>
|
|
254
|
+
</div></h5>
|
|
255
|
+
|
|
256
|
+
<pre class="example code"><code><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='id identifier rubyid_servus_arguments_example'>servus_arguments_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='rparen'>)</span>
|
|
257
|
+
<span class='comment'># => { user_id: 123, amount: 100.0, currency: 'USD' }
|
|
258
|
+
</span>
|
|
259
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span></code></pre>
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
<h5 class="example_title"><div class='inline'><p>With overrides</p>
|
|
263
|
+
</div></h5>
|
|
264
|
+
|
|
265
|
+
<pre class="example code"><code><span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='id identifier rubyid_servus_arguments_example'>servus_arguments_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='comma'>,</span> <span class='label'>amount:</span> <span class='float'>50.0</span><span class='comma'>,</span> <span class='label'>currency:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>EUR</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
266
|
+
<span class='comment'># => { user_id: 123, amount: 50.0, currency: 'EUR' }</span></code></pre>
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
<h5 class="example_title"><div class='inline'><p>In RSpec tests</p>
|
|
270
|
+
</div></h5>
|
|
271
|
+
|
|
272
|
+
<pre class="example code"><code><span class='id identifier rubyid_it'>it</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>processes different currencies</span><span class='tstring_end'>'</span></span> <span class='kw'>do</span>
|
|
273
|
+
<span class='qwords_beg'>%w[</span><span class='tstring_content'>USD</span><span class='words_sep'> </span><span class='tstring_content'>EUR</span><span class='words_sep'> </span><span class='tstring_content'>GBP</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_currency'>currency</span><span class='op'>|</span>
|
|
274
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span>
|
|
275
|
+
<span class='op'>**</span><span class='id identifier rubyid_servus_arguments_example'>servus_arguments_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='comma'>,</span> <span class='label'>currency:</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
276
|
+
<span class='rparen'>)</span>
|
|
277
|
+
<span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_be_success'>be_success</span>
|
|
278
|
+
<span class='kw'>end</span>
|
|
279
|
+
<span class='kw'>end</span></code></pre>
|
|
280
|
+
|
|
281
|
+
</div>
|
|
282
|
+
<p class="tag_title">Parameters:</p>
|
|
283
|
+
<ul class="param">
|
|
284
|
+
|
|
285
|
+
<li>
|
|
286
|
+
|
|
287
|
+
<span class='name'>service_class</span>
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
<span class='type'>(<tt>Class</tt>)</span>
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
—
|
|
295
|
+
<div class='inline'><p>The service class to extract examples from</p>
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
</li>
|
|
299
|
+
|
|
300
|
+
<li>
|
|
301
|
+
|
|
302
|
+
<span class='name'>overrides</span>
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
—
|
|
312
|
+
<div class='inline'><p>Optional values to override the schema examples</p>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
</li>
|
|
316
|
+
|
|
317
|
+
</ul>
|
|
318
|
+
|
|
319
|
+
<p class="tag_title">Returns:</p>
|
|
320
|
+
<ul class="return">
|
|
321
|
+
|
|
322
|
+
<li>
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
<span class='type'>(<tt>Hash<Symbol, Object></tt>)</span>
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
—
|
|
330
|
+
<div class='inline'><p>Hash of example argument values with symbolized keys</p>
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
</li>
|
|
334
|
+
|
|
335
|
+
</ul>
|
|
336
|
+
|
|
337
|
+
</div><table class="source_code">
|
|
338
|
+
<tr>
|
|
339
|
+
<td>
|
|
340
|
+
<pre class="lines">
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
75
|
|
344
|
+
76
|
|
345
|
+
77</pre>
|
|
346
|
+
</td>
|
|
347
|
+
<td>
|
|
348
|
+
<pre class="code"><span class="info file"># File 'lib/servus/testing/example_builders.rb', line 75</span>
|
|
349
|
+
|
|
350
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_servus_arguments_example'>servus_arguments_example</span><span class='lparen'>(</span><span class='id identifier rubyid_service_class'>service_class</span><span class='comma'>,</span> <span class='id identifier rubyid_overrides'>overrides</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
351
|
+
<span class='id identifier rubyid_extract_example_from'>extract_example_from</span><span class='lparen'>(</span><span class='id identifier rubyid_service_class'>service_class</span><span class='comma'>,</span> <span class='symbol'>:arguments</span><span class='comma'>,</span> <span class='id identifier rubyid_overrides'>overrides</span><span class='rparen'>)</span>
|
|
352
|
+
<span class='kw'>end</span></pre>
|
|
353
|
+
</td>
|
|
354
|
+
</tr>
|
|
355
|
+
</table>
|
|
356
|
+
</div>
|
|
357
|
+
|
|
358
|
+
<div class="method_details ">
|
|
359
|
+
<h3 class="signature " id="servus_result_example-instance_method">
|
|
360
|
+
|
|
361
|
+
#<strong>servus_result_example</strong>(service_class, overrides = {}) ⇒ <tt><span class='object_link'><a href="../Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
</h3><div class="docstring">
|
|
368
|
+
<div class="discussion">
|
|
369
|
+
|
|
370
|
+
<div class="note notetag">
|
|
371
|
+
<strong>Note:</strong>
|
|
372
|
+
<div class='inline'><p>Override keys can be strings or symbols; they'll be converted to symbols</p>
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
|
|
376
|
+
<div class="note notetag">
|
|
377
|
+
<strong>Note:</strong>
|
|
378
|
+
<div class='inline'><p>Returns empty hash if service has no result schema defined</p>
|
|
379
|
+
</div>
|
|
380
|
+
</div>
|
|
381
|
+
|
|
382
|
+
<p>Extracts example result values from a service's schema.</p>
|
|
383
|
+
|
|
384
|
+
<p>Looks for <code>example</code> or <code>examples</code> keywords in the service's result schema
|
|
385
|
+
and returns them as a hash. Useful for validating service response structure
|
|
386
|
+
and expected data shapes in tests.</p>
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
<div class="tags">
|
|
392
|
+
|
|
393
|
+
<div class="examples">
|
|
394
|
+
<h4 class="tag_title">Examples:</h4>
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
<h5 class="example_title"><div class='inline'><p>Basic usage</p>
|
|
398
|
+
</div></h5>
|
|
399
|
+
|
|
400
|
+
<pre class="example code"><code><span class='id identifier rubyid_expected'>expected</span> <span class='op'>=</span> <span class='id identifier rubyid_servus_result_example'>servus_result_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='rparen'>)</span>
|
|
401
|
+
<span class='comment'># => Servus::Support::Response with data:
|
|
402
|
+
</span><span class='comment'># { transaction_id: 'txn_abc123', status: 'approved', amount_charged: 100.0 }</span></code></pre>
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
<h5 class="example_title"><div class='inline'><p>Validate result structure</p>
|
|
406
|
+
</div></h5>
|
|
407
|
+
|
|
408
|
+
<pre class="example code"><code><span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_servus_arguments_example'>servus_arguments_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
409
|
+
|
|
410
|
+
<span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span>
|
|
411
|
+
<span class='id identifier rubyid_hash_including'>hash_including</span><span class='lparen'>(</span><span class='id identifier rubyid_servus_result_example'>servus_result_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
|
|
412
|
+
<span class='rparen'>)</span></code></pre>
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
<h5 class="example_title"><div class='inline'><p>Check result has expected keys</p>
|
|
416
|
+
</div></h5>
|
|
417
|
+
|
|
418
|
+
<pre class="example code"><code><span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
419
|
+
<span class='id identifier rubyid_expected_keys'>expected_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_servus_result_example'>servus_result_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
|
|
420
|
+
|
|
421
|
+
<span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_match_array'>match_array</span><span class='lparen'>(</span><span class='id identifier rubyid_expected_keys'>expected_keys</span><span class='rparen'>)</span></code></pre>
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
<h5 class="example_title"><div class='inline'><p>With overrides</p>
|
|
425
|
+
</div></h5>
|
|
426
|
+
|
|
427
|
+
<pre class="example code"><code><span class='id identifier rubyid_expected'>expected</span> <span class='op'>=</span> <span class='id identifier rubyid_servus_result_example'>servus_result_example</span><span class='lparen'>(</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='comma'>,</span> <span class='label'>status:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>pending</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span>
|
|
428
|
+
<span class='comment'># => { transaction_id: 'txn_abc123', status: 'pending', amount_charged: 100.0 }</span></code></pre>
|
|
429
|
+
|
|
430
|
+
</div>
|
|
431
|
+
<p class="tag_title">Parameters:</p>
|
|
432
|
+
<ul class="param">
|
|
433
|
+
|
|
434
|
+
<li>
|
|
435
|
+
|
|
436
|
+
<span class='name'>service_class</span>
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
<span class='type'>(<tt>Class</tt>)</span>
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
—
|
|
444
|
+
<div class='inline'><p>The service class to extract examples from</p>
|
|
445
|
+
</div>
|
|
446
|
+
|
|
447
|
+
</li>
|
|
448
|
+
|
|
449
|
+
<li>
|
|
450
|
+
|
|
451
|
+
<span class='name'>overrides</span>
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
—
|
|
461
|
+
<div class='inline'><p>Optional values to override the schema examples</p>
|
|
462
|
+
</div>
|
|
463
|
+
|
|
464
|
+
</li>
|
|
465
|
+
|
|
466
|
+
</ul>
|
|
467
|
+
|
|
468
|
+
<p class="tag_title">Returns:</p>
|
|
469
|
+
<ul class="return">
|
|
470
|
+
|
|
471
|
+
<li>
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
—
|
|
479
|
+
<div class='inline'><p>Response object with example result data</p>
|
|
480
|
+
</div>
|
|
481
|
+
|
|
482
|
+
</li>
|
|
483
|
+
|
|
484
|
+
</ul>
|
|
485
|
+
|
|
486
|
+
</div><table class="source_code">
|
|
487
|
+
<tr>
|
|
488
|
+
<td>
|
|
489
|
+
<pre class="lines">
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
113
|
|
493
|
+
114
|
|
494
|
+
115
|
|
495
|
+
116
|
|
496
|
+
117</pre>
|
|
497
|
+
</td>
|
|
498
|
+
<td>
|
|
499
|
+
<pre class="code"><span class="info file"># File 'lib/servus/testing/example_builders.rb', line 113</span>
|
|
500
|
+
|
|
501
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_servus_result_example'>servus_result_example</span><span class='lparen'>(</span><span class='id identifier rubyid_service_class'>service_class</span><span class='comma'>,</span> <span class='id identifier rubyid_overrides'>overrides</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
502
|
+
<span class='id identifier rubyid_example'>example</span> <span class='op'>=</span> <span class='id identifier rubyid_extract_example_from'>extract_example_from</span><span class='lparen'>(</span><span class='id identifier rubyid_service_class'>service_class</span><span class='comma'>,</span> <span class='symbol'>:result</span><span class='comma'>,</span> <span class='id identifier rubyid_overrides'>overrides</span><span class='rparen'>)</span>
|
|
503
|
+
<span class='comment'># Wrap in a successful Response object
|
|
504
|
+
</span> <span class='const'><span class='object_link'><a href="../../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Support/Response.html" title="Servus::Support::Response (class)">Response</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Support/Response.html#initialize-instance_method" title="Servus::Support::Response#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_example'>example</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
505
|
+
<span class='kw'>end</span></pre>
|
|
506
|
+
</td>
|
|
507
|
+
</tr>
|
|
508
|
+
</table>
|
|
509
|
+
</div>
|
|
510
|
+
|
|
511
|
+
</div>
|
|
512
|
+
|
|
513
|
+
</div>
|
|
514
|
+
|
|
515
|
+
<div id="footer">
|
|
516
|
+
Generated on Fri Nov 21 00:33:23 2025 by
|
|
517
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
518
|
+
0.9.37 (ruby-3.4.4).
|
|
519
|
+
</div>
|
|
520
|
+
|
|
521
|
+
</div>
|
|
522
|
+
</body>
|
|
523
|
+
</html>
|