spec_forge 0.6.0 → 0.7.1
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/CHANGELOG.md +174 -8
- data/README.md +135 -10
- data/flake.lock +3 -3
- data/flake.nix +3 -3
- data/lib/spec_forge/attribute/factory.rb +1 -1
- data/lib/spec_forge/attribute/transform.rb +1 -1
- data/lib/spec_forge/callbacks.rb +9 -0
- data/lib/spec_forge/cli/docs/generate.rb +72 -0
- data/lib/spec_forge/cli/docs.rb +92 -0
- data/lib/spec_forge/cli/init.rb +39 -7
- data/lib/spec_forge/cli/new.rb +13 -3
- data/lib/spec_forge/cli/run.rb +12 -4
- data/lib/spec_forge/cli/serve.rb +156 -0
- data/lib/spec_forge/cli.rb +14 -6
- data/lib/spec_forge/configuration.rb +13 -9
- data/lib/spec_forge/context/store.rb +23 -40
- data/lib/spec_forge/core_ext/array.rb +27 -0
- data/lib/spec_forge/documentation/builder.rb +383 -0
- data/lib/spec_forge/documentation/document/operation.rb +47 -0
- data/lib/spec_forge/documentation/document/parameter.rb +22 -0
- data/lib/spec_forge/documentation/document/request_body.rb +24 -0
- data/lib/spec_forge/documentation/document/response.rb +39 -0
- data/lib/spec_forge/documentation/document/response_body.rb +27 -0
- data/lib/spec_forge/documentation/document.rb +48 -0
- data/lib/spec_forge/documentation/generators/base.rb +81 -0
- data/lib/spec_forge/documentation/generators/openapi/base.rb +100 -0
- data/lib/spec_forge/documentation/generators/openapi/error_formatter.rb +149 -0
- data/lib/spec_forge/documentation/generators/openapi/v3_0.rb +65 -0
- data/lib/spec_forge/documentation/generators/openapi.rb +59 -0
- data/lib/spec_forge/documentation/generators.rb +17 -0
- data/lib/spec_forge/documentation/loader/cache.rb +138 -0
- data/lib/spec_forge/documentation/loader.rb +159 -0
- data/lib/spec_forge/documentation/openapi/base.rb +33 -0
- data/lib/spec_forge/documentation/openapi/v3_0/example.rb +44 -0
- data/lib/spec_forge/documentation/openapi/v3_0/media_type.rb +42 -0
- data/lib/spec_forge/documentation/openapi/v3_0/operation.rb +175 -0
- data/lib/spec_forge/documentation/openapi/v3_0/response.rb +65 -0
- data/lib/spec_forge/documentation/openapi/v3_0/schema.rb +80 -0
- data/lib/spec_forge/documentation/openapi/v3_0/tag.rb +71 -0
- data/lib/spec_forge/documentation/openapi.rb +23 -0
- data/lib/spec_forge/documentation.rb +27 -0
- data/lib/spec_forge/error.rb +17 -0
- data/lib/spec_forge/factory.rb +2 -2
- data/lib/spec_forge/filter.rb +3 -4
- data/lib/spec_forge/forge.rb +5 -4
- data/lib/spec_forge/http/backend.rb +5 -0
- data/lib/spec_forge/http/request.rb +14 -3
- data/lib/spec_forge/loader.rb +14 -24
- data/lib/spec_forge/normalizer/default.rb +51 -0
- data/lib/spec_forge/normalizer/definition.rb +248 -0
- data/lib/spec_forge/normalizer/validators.rb +99 -0
- data/lib/spec_forge/normalizer.rb +356 -199
- data/lib/spec_forge/normalizers/_shared.yml +76 -0
- data/lib/spec_forge/normalizers/configuration.yml +23 -0
- data/lib/spec_forge/normalizers/constraint.yml +8 -0
- data/lib/spec_forge/normalizers/expectation.yml +47 -0
- data/lib/spec_forge/normalizers/factory.yml +12 -0
- data/lib/spec_forge/normalizers/factory_reference.yml +15 -0
- data/lib/spec_forge/normalizers/global_context.yml +28 -0
- data/lib/spec_forge/normalizers/spec.yml +50 -0
- data/lib/spec_forge/runner/adapter.rb +181 -0
- data/lib/spec_forge/runner/debug_proxy.rb +44 -42
- data/lib/spec_forge/runner/state.rb +4 -5
- data/lib/spec_forge/runner.rb +40 -124
- data/lib/spec_forge/spec/expectation/constraint.rb +13 -5
- data/lib/spec_forge/spec/expectation.rb +7 -3
- data/lib/spec_forge/spec.rb +13 -58
- data/lib/spec_forge/version.rb +1 -1
- data/lib/spec_forge.rb +30 -23
- data/lib/templates/openapi.yml.tt +22 -0
- data/lib/templates/redoc.html.tt +28 -0
- data/lib/templates/swagger.html.tt +59 -0
- metadata +92 -14
- data/lib/spec_forge/normalizer/configuration.rb +0 -90
- data/lib/spec_forge/normalizer/constraint.rb +0 -60
- data/lib/spec_forge/normalizer/expectation.rb +0 -105
- data/lib/spec_forge/normalizer/factory.rb +0 -78
- data/lib/spec_forge/normalizer/factory_reference.rb +0 -85
- data/lib/spec_forge/normalizer/global_context.rb +0 -88
- data/lib/spec_forge/normalizer/spec.rb +0 -97
- /data/lib/templates/{forge_helper.tt → forge_helper.rb.tt} +0 -0
- /data/lib/templates/{new_factory.tt → new_factory.yml.tt} +0 -0
- /data/lib/templates/{new_spec.tt → new_spec.yml.tt} +0 -0
@@ -1,97 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SpecForge
|
4
|
-
class Normalizer
|
5
|
-
#
|
6
|
-
# Normalizes spec hash structure
|
7
|
-
#
|
8
|
-
# Ensures that spec definitions have the correct structure
|
9
|
-
# and default values for all required settings.
|
10
|
-
#
|
11
|
-
class Spec < Normalizer
|
12
|
-
#
|
13
|
-
# Defines the normalized structure for configuration validation
|
14
|
-
#
|
15
|
-
# Specifies validation rules for configuration attributes:
|
16
|
-
# - Enforces specific data types
|
17
|
-
# - Provides default values
|
18
|
-
# - Supports alternative key names
|
19
|
-
#
|
20
|
-
# @return [Hash] Configuration attribute validation rules
|
21
|
-
#
|
22
|
-
STRUCTURE = {
|
23
|
-
# Internal
|
24
|
-
id: Normalizer::SHARED_ATTRIBUTES[:id],
|
25
|
-
name: Normalizer::SHARED_ATTRIBUTES[:name],
|
26
|
-
file_name: {type: String},
|
27
|
-
file_path: {type: String},
|
28
|
-
line_number: Normalizer::SHARED_ATTRIBUTES[:line_number],
|
29
|
-
|
30
|
-
# User defined
|
31
|
-
base_url: Normalizer::SHARED_ATTRIBUTES[:base_url],
|
32
|
-
url: Normalizer::SHARED_ATTRIBUTES[:url],
|
33
|
-
http_verb: Normalizer::SHARED_ATTRIBUTES[:http_verb],
|
34
|
-
headers: Normalizer::SHARED_ATTRIBUTES[:headers],
|
35
|
-
query: Normalizer::SHARED_ATTRIBUTES[:query],
|
36
|
-
body: Normalizer::SHARED_ATTRIBUTES[:body],
|
37
|
-
variables: Normalizer::SHARED_ATTRIBUTES[:variables],
|
38
|
-
debug: Normalizer::SHARED_ATTRIBUTES[:debug],
|
39
|
-
expectations: {type: Array}
|
40
|
-
}.freeze
|
41
|
-
end
|
42
|
-
|
43
|
-
# On Normalizer
|
44
|
-
class << self
|
45
|
-
#
|
46
|
-
# Generates an empty spec hash
|
47
|
-
#
|
48
|
-
# @return [Hash] Default spec hash
|
49
|
-
#
|
50
|
-
def default_spec
|
51
|
-
Spec.default
|
52
|
-
end
|
53
|
-
|
54
|
-
#
|
55
|
-
# Normalizes a spec hash with validation and processes expectations
|
56
|
-
#
|
57
|
-
# @param input [Hash] The hash to normalize
|
58
|
-
# @param label [String] Label for error messages
|
59
|
-
#
|
60
|
-
# @return [Hash] A normalized hash with defaults applied
|
61
|
-
#
|
62
|
-
# @raise [Error::InvalidStructureError] If validation fails
|
63
|
-
#
|
64
|
-
def normalize_spec!(input, label: "spec")
|
65
|
-
raise_errors! do
|
66
|
-
output, errors = normalize_spec(input, label:)
|
67
|
-
|
68
|
-
# Process expectations
|
69
|
-
if (expectations = input[:expectations]) && Type.array?(expectations)
|
70
|
-
expectation_output, expectation_errors = normalize_expectations(expectations)
|
71
|
-
|
72
|
-
output[:expectations] = expectation_output
|
73
|
-
errors += expectation_errors if expectation_errors.size > 0
|
74
|
-
end
|
75
|
-
|
76
|
-
[output, errors]
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
#
|
81
|
-
# Normalize a spec hash
|
82
|
-
#
|
83
|
-
# @param spec [Hash] Spec hash
|
84
|
-
# @param label [String] Label for error messages
|
85
|
-
#
|
86
|
-
# @return [Array] [normalized_hash, errors]
|
87
|
-
#
|
88
|
-
# @private
|
89
|
-
#
|
90
|
-
def normalize_spec(spec, label: "spec")
|
91
|
-
raise Error::InvalidTypeError.new(spec, Hash, for: label) unless Type.hash?(spec)
|
92
|
-
|
93
|
-
Normalizer::Spec.new(label, spec).normalize
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
File without changes
|
File without changes
|
File without changes
|