spec_forge 0.4.0 → 0.6.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 +4 -4
- data/.standard.yml +4 -0
- data/CHANGELOG.md +145 -1
- data/README.md +49 -638
- data/flake.lock +3 -3
- data/flake.nix +8 -2
- data/lib/spec_forge/attribute/chainable.rb +208 -20
- data/lib/spec_forge/attribute/factory.rb +141 -12
- data/lib/spec_forge/attribute/faker.rb +64 -15
- data/lib/spec_forge/attribute/global.rb +96 -0
- data/lib/spec_forge/attribute/literal.rb +15 -2
- data/lib/spec_forge/attribute/matcher.rb +188 -13
- data/lib/spec_forge/attribute/parameterized.rb +45 -20
- data/lib/spec_forge/attribute/regex.rb +55 -5
- data/lib/spec_forge/attribute/resolvable.rb +48 -5
- data/lib/spec_forge/attribute/resolvable_array.rb +62 -4
- data/lib/spec_forge/attribute/resolvable_hash.rb +62 -4
- data/lib/spec_forge/attribute/store.rb +65 -0
- data/lib/spec_forge/attribute/transform.rb +33 -5
- data/lib/spec_forge/attribute/variable.rb +37 -6
- data/lib/spec_forge/attribute.rb +168 -66
- data/lib/spec_forge/backtrace_formatter.rb +26 -3
- data/lib/spec_forge/callbacks.rb +79 -0
- data/lib/spec_forge/cli/actions.rb +27 -0
- data/lib/spec_forge/cli/command.rb +78 -24
- data/lib/spec_forge/cli/init.rb +11 -1
- data/lib/spec_forge/cli/new.rb +54 -3
- data/lib/spec_forge/cli/run.rb +20 -0
- data/lib/spec_forge/cli.rb +16 -5
- data/lib/spec_forge/configuration.rb +94 -25
- data/lib/spec_forge/context/callbacks.rb +91 -0
- data/lib/spec_forge/context/global.rb +72 -0
- data/lib/spec_forge/context/store.rb +148 -0
- data/lib/spec_forge/context/variables.rb +91 -0
- data/lib/spec_forge/context.rb +36 -0
- data/lib/spec_forge/core_ext/rspec.rb +24 -4
- data/lib/spec_forge/error.rb +267 -113
- data/lib/spec_forge/factory.rb +33 -14
- data/lib/spec_forge/filter.rb +87 -0
- data/lib/spec_forge/forge.rb +170 -0
- data/lib/spec_forge/http/backend.rb +99 -29
- data/lib/spec_forge/http/client.rb +23 -13
- data/lib/spec_forge/http/request.rb +74 -62
- data/lib/spec_forge/http/verb.rb +79 -0
- data/lib/spec_forge/http.rb +105 -0
- data/lib/spec_forge/loader.rb +254 -0
- data/lib/spec_forge/matchers.rb +130 -0
- data/lib/spec_forge/normalizer/configuration.rb +24 -11
- data/lib/spec_forge/normalizer/constraint.rb +22 -9
- data/lib/spec_forge/normalizer/expectation.rb +31 -12
- data/lib/spec_forge/normalizer/factory.rb +24 -11
- data/lib/spec_forge/normalizer/factory_reference.rb +32 -13
- data/lib/spec_forge/normalizer/global_context.rb +88 -0
- data/lib/spec_forge/normalizer/spec.rb +39 -16
- data/lib/spec_forge/normalizer.rb +255 -41
- data/lib/spec_forge/runner/callbacks.rb +246 -0
- data/lib/spec_forge/runner/debug_proxy.rb +213 -0
- data/lib/spec_forge/runner/listener.rb +54 -0
- data/lib/spec_forge/runner/metadata.rb +58 -0
- data/lib/spec_forge/runner/state.rb +99 -0
- data/lib/spec_forge/runner.rb +133 -119
- data/lib/spec_forge/spec/expectation/constraint.rb +95 -20
- data/lib/spec_forge/spec/expectation.rb +43 -51
- data/lib/spec_forge/spec.rb +83 -96
- data/lib/spec_forge/type.rb +36 -4
- data/lib/spec_forge/version.rb +4 -1
- data/lib/spec_forge.rb +161 -76
- metadata +20 -5
- data/spec_forge/factories/user.yml +0 -4
- data/spec_forge/forge_helper.rb +0 -37
- data/spec_forge/specs/users.yml +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b2d5790d4797a63b8fbad4dd296b9c9beb657b30a98bda5fab8ca7c635abd5a
|
4
|
+
data.tar.gz: b22a8f664dd676846e703f5312383c9c9b1b9cabab52b2cc3c8a8d28830490c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 858e7dfd4546bc34e7dd8f899d99b5cf03d26cfbe9042f238de44566e2981a82bcd06803a0319f6d937d7c509dc3c02e8a962415c8e6fbb8e3c515c693c5e176
|
7
|
+
data.tar.gz: 3b246fda2d4bbbc5ce12fa0f683e27e1cb0e2950fe3b7c03b978f6d88662d1b65b0037b00931fe598415ee3d3c8477f7f76fd3f523547e061f86ac000e617d52
|
data/.standard.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
<!--
|
8
9
|
## [Unreleased]
|
9
10
|
|
10
11
|
### Added
|
@@ -12,6 +13,148 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
12
13
|
### Changed
|
13
14
|
|
14
15
|
### Removed
|
16
|
+
-->
|
17
|
+
|
18
|
+
## [Unreleased]
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- Added new context system for managing shared state between tests
|
23
|
+
- Introduced `SpecForge.context` global accessor for accessing test context
|
24
|
+
- Created `Context` class with modular components:
|
25
|
+
- `Context::Global` for file-level shared variables
|
26
|
+
- `Context::Variables` for managing variables with overlay support
|
27
|
+
- `Context::Store` for storing the results of the tests
|
28
|
+
- Added support for defining and referencing global variables
|
29
|
+
```yaml
|
30
|
+
global:
|
31
|
+
variables:
|
32
|
+
api_version: "v2"
|
33
|
+
environment: "test"
|
34
|
+
|
35
|
+
index_user:
|
36
|
+
path: "/{api_version}/users"
|
37
|
+
query:
|
38
|
+
api_version: "global.variables.api_version"
|
39
|
+
```
|
40
|
+
- Added compound matcher support via `matcher.and` for combining multiple matchers
|
41
|
+
```yaml
|
42
|
+
email:
|
43
|
+
matcher.and:
|
44
|
+
- kind_of.string
|
45
|
+
- /@/
|
46
|
+
- matcher.end_with: ".com"
|
47
|
+
```
|
48
|
+
- Added custom RSpec matcher `have_size` for checking an object's size via `matcher.have_size`
|
49
|
+
- Added new `Loader` class for improved spec file processing
|
50
|
+
- Added new `Filter` class for more flexible test filtering
|
51
|
+
- Added normalizer for global context validation
|
52
|
+
- Added line number tracking for specs and expectations
|
53
|
+
- Added support for defining and referencing callbacks
|
54
|
+
```ruby
|
55
|
+
# Configuration level
|
56
|
+
SpecForge.configure do |config|
|
57
|
+
config.register_callback("callback_name") { |context| }
|
58
|
+
# These are aliases
|
59
|
+
# config.define_callback("callback_name") { |context| }
|
60
|
+
# config.callback("callback_name") { |context| }
|
61
|
+
end
|
62
|
+
|
63
|
+
# Module level (no aliases)
|
64
|
+
SpecForge.register_callback("callback_name") { |context| }
|
65
|
+
```
|
66
|
+
Once defined, callbacks can be referenced in spec files via the global context
|
67
|
+
```yaml
|
68
|
+
global:
|
69
|
+
callbacks:
|
70
|
+
- before: callback_name
|
71
|
+
after: cleanup_database_state
|
72
|
+
```
|
73
|
+
- Added support for storing and retrieving test data via the `store_as` directive and `store` attribute
|
74
|
+
```yaml
|
75
|
+
create_user:
|
76
|
+
path: "/users"
|
77
|
+
method: "post"
|
78
|
+
expectations:
|
79
|
+
- variables:
|
80
|
+
name: "John"
|
81
|
+
email: "john@example.com"
|
82
|
+
store_as: "created_user"
|
83
|
+
expect:
|
84
|
+
status: 200
|
85
|
+
|
86
|
+
show_user:
|
87
|
+
path: "/users/:id"
|
88
|
+
query:
|
89
|
+
id: store.created_user.response.id
|
90
|
+
- expect:
|
91
|
+
status: 200
|
92
|
+
```
|
93
|
+
- Added `UndefinedMatcherError` for clearer error messaging when invalid matchers are used
|
94
|
+
- Enhanced debugging capabilities with improved DebugProxy methods and store access
|
95
|
+
- Added HTTP status descriptions for better error messages
|
96
|
+
- Added support for string values in `query`, `body`, and `variables` attributes
|
97
|
+
- Added print statement when filtering tests for better visibility
|
98
|
+
|
99
|
+
### Changed
|
100
|
+
|
101
|
+
- Renamed `SpecForge.forge` to `SpecForge.forge_path`
|
102
|
+
- Renamed attribute `http_method` to `http_verb` (`http_method` is now an alias)
|
103
|
+
- Refactored attribute resolution methods:
|
104
|
+
- Renamed `Attribute#resolve` to `#resolved` (memoized version)
|
105
|
+
- Renamed `Attribute#resolve_value` to `#resolve` (immediate resolution)
|
106
|
+
- Added `Attribute#resolve_as_matcher` for resolving attributes into RSpec matchers
|
107
|
+
- Refactored variable resolution to use the new context system
|
108
|
+
- Updated `Runner` to properly initialize and manage context between tests
|
109
|
+
- Improved error messages with more contextual information about the execution environment
|
110
|
+
- Updated YARD comments with better API descriptions and examples
|
111
|
+
- Restructured internal architecture for better separation of concerns
|
112
|
+
- Moved all error classes under `SpecForge::Error`
|
113
|
+
- Fixed issue where nesting expanded matchers (such as `matcher.include`) would cause an error
|
114
|
+
- Improved response body validation for hash expectations:
|
115
|
+
- Each root-level key is now checked individually for more precise error messages
|
116
|
+
- Nested hashes still use the `include` matcher for flexibility
|
117
|
+
- Adjusted `Attribute::Matcher` to accept either `matcher` or `matchers` namespace
|
118
|
+
- Changed empty array matcher from using `contain_exactly` to `eq([])`
|
119
|
+
- Changed empty hash matcher from using `include` to `eq({})`
|
120
|
+
- Changed `forge_and` description from "matches all of:" to "match all:"
|
121
|
+
- Improved error handling for chainable attributes with better descriptions for various object types
|
122
|
+
- Limited error backtrace to 50 lines for cleaner output
|
123
|
+
- Enhanced spec loading error messages with more detailed information
|
124
|
+
- Improved RSpec example descriptions for better test output
|
125
|
+
- Added support for overwriting headers at the request level
|
126
|
+
|
127
|
+
## Removed
|
128
|
+
|
129
|
+
- Removed `Configuration.overlay_options`
|
130
|
+
|
131
|
+
## [0.5.0] - 12025-02-28
|
132
|
+
|
133
|
+
### Added
|
134
|
+
|
135
|
+
- Added support for testing array responses via `json`
|
136
|
+
- Added check to block RSpec overwrites from running with internal tests
|
137
|
+
- Added debugging access to `expected_json_class` variable.
|
138
|
+
- Added support for FactoryBot list strategies through the new `size` attribute
|
139
|
+
```yaml
|
140
|
+
variables:
|
141
|
+
users:
|
142
|
+
factory.user:
|
143
|
+
size: 10 # Creates 10 user records
|
144
|
+
```
|
145
|
+
- All FactoryBot list methods now supported:
|
146
|
+
- `create_list` (default)
|
147
|
+
- `build_list`
|
148
|
+
- `build_stubbed_list`
|
149
|
+
- `attributes_for_list`
|
150
|
+
- `build_pair`
|
151
|
+
- `create_pair`
|
152
|
+
- Comprehensive documentation available in the [Factory Lists wiki](https://github.com/itsthedevman/spec_forge/wiki/Factory-Lists)
|
153
|
+
|
154
|
+
### Changed
|
155
|
+
|
156
|
+
- Updated `Constraint` to use `include` for testing Hashes and `contains_exactly` for testing Arrays
|
157
|
+
- Better handling of positional and keyword argument passing for `Matcher` and `Faker` attributes
|
15
158
|
|
16
159
|
## [0.4.0] - 12025-02-22
|
17
160
|
|
@@ -88,7 +231,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
88
231
|
|
89
232
|
- Initial commit
|
90
233
|
|
91
|
-
[unreleased]: https://github.com/itsthedevman/spec_forge/compare/v0.
|
234
|
+
[unreleased]: https://github.com/itsthedevman/spec_forge/compare/v0.5.0...HEAD
|
235
|
+
[0.5.0]: https://github.com/itsthedevman/spec_forge/compare/v0.4.0...v0.5.0
|
92
236
|
[0.4.0]: https://github.com/itsthedevman/spec_forge/compare/v0.3.2...v0.4.0
|
93
237
|
[0.3.2]: https://github.com/itsthedevman/spec_forge/compare/v0.3.0...v0.3.2
|
94
238
|
[0.3.0]: https://github.com/itsthedevman/spec_forge/compare/v0.2.0...v0.3.0
|