resteze 0.3.0 → 0.3.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 +31 -0
- data/README.md +2 -0
- data/lib/resteze/testing/minitest/configuration.rb +18 -0
- data/lib/resteze/testing/minitest/object.rb +58 -0
- data/lib/resteze/testing/minitest.rb +10 -0
- data/lib/resteze/testing/rspec/configure.rb +16 -0
- data/lib/resteze/testing/rspec/object.rb +49 -0
- data/lib/resteze/testing/rspec.rb +10 -0
- data/lib/resteze/version.rb +1 -1
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4be8c1254251ae0e6d2fb624d9ebbfff5ddc309d903ffe1ded346d816b4a3cf0
|
4
|
+
data.tar.gz: b49908651339547627e4a46b13944d9029ce06bea3a1a189fc63538b7fb54cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d318326b40178c6bbcfb949908e37742d56c74c1e366ec4522c217bc5886b21f2884536b94d814f17e1c2ab7262a5820df0b43ed481302f5b6bcc6071af2e64d
|
7
|
+
data.tar.gz: 62db4cc4bc2edf0761b258ef64b7e4edf42faea613099c3ab7091434c0d4fea100bcca33604e910e0943c07a242f807f6165f06d9e94195aba10f9deb6381d47
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## [0.3.1]
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Minitest and RSpec testing helpers for resources and configuration.
|
10
|
+
|
11
|
+
## [0.3.0]
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Initial implementation of Resteze, a framework for building REST API client gems.
|
16
|
+
- Support for defining API resources, requests, and responses.
|
17
|
+
- Configuration management for API clients.
|
18
|
+
- Integration with Faraday, Hashie, and ActiveSupport.
|
19
|
+
- Middleware for error handling and request transformation.
|
20
|
+
- Serialization and deserialization of API responses.
|
21
|
+
- Thread-safe client management.
|
22
|
+
- Flexible resource paths and property mapping.
|
23
|
+
|
24
|
+
## [0.1.0] - 2025-08-12
|
25
|
+
|
26
|
+
### Added
|
27
|
+
|
28
|
+
- First public release.
|
29
|
+
- Documentation and usage examples.
|
30
|
+
- CI workflow for RuboCop and tests across Ruby 3.2–3.4.4.
|
31
|
+
- Code coverage reporting integration.
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
</div>
|
4
4
|
|
5
5
|
[](https://github.com/rwx-services/resteze/actions/workflows/ci.yml)
|
6
|
+
[](https://badge.fury.io/rb/resteze)
|
7
|
+
[](https://coveralls.io/github/rwx-services/resteze?branch=main)
|
6
8
|
|
7
9
|
---
|
8
10
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Resteze
|
2
|
+
module Testing
|
3
|
+
module Configuration
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
# Assert that a config property is supported and can be assigned
|
7
|
+
def assert_config_property(property, value = nil, subject: nil)
|
8
|
+
subject ||= (defined?(@subject) && @subject) || subject()
|
9
|
+
original_value = subject.send(property)
|
10
|
+
|
11
|
+
assert_equal value, subject.send(property), "config property #{property} value did not match expectation"
|
12
|
+
ensure
|
13
|
+
# Make sure to set the original value at the end
|
14
|
+
subject.send("#{property}=", original_value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Resteze
|
2
|
+
module Testing
|
3
|
+
module Minitest
|
4
|
+
module Object
|
5
|
+
include ActiveSupport::Concern
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
# rubocop:disable Metrics/AbcSize
|
10
|
+
# rubocop:disable Naming/PredicatePrefix
|
11
|
+
def has_property(name, **options)
|
12
|
+
assert subject.property?(name.to_sym), "Expected #{subject} to have property: #{name}"
|
13
|
+
assert_property_default(name, options[:default]) if options.key?(:default)
|
14
|
+
assert_property_translation(name, options[:from]) if options.key?(:from)
|
15
|
+
assert_property_transformed(name, transformed: options[:transformed]) if options.key?(:transformed)
|
16
|
+
assert_property_required(name, required: options[:required]) if options.key?(:required)
|
17
|
+
end
|
18
|
+
# rubocop:enable Metrics/AbcSize
|
19
|
+
# rubocop:enable Naming/PredicatePrefix
|
20
|
+
|
21
|
+
def assert_property_transformed(name, transformed: true)
|
22
|
+
translation = subject.translations_hash.dig(subject.translations.key(name.to_sym), name.to_sym)
|
23
|
+
transformation_defined = translation.is_a?(Proc) || subject.transformation_exists?(name.to_sym)
|
24
|
+
|
25
|
+
if transformed
|
26
|
+
assert transformation_defined, "Expected #{subject} to transform property: #{name}"
|
27
|
+
else
|
28
|
+
refute transformation_defined, "Expected #{subject} not to transform property: #{name}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def assert_property_required(name, required: true)
|
33
|
+
if required
|
34
|
+
assert subject.required?(name.to_sym), "Expected #{subject} to require property: #{name}"
|
35
|
+
else
|
36
|
+
refute subject.required?(name.to_sym), "Expected #{subject} not to require property: #{name}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def assert_property_translation(name, from)
|
41
|
+
assert_equal(
|
42
|
+
from.to_sym,
|
43
|
+
subject.translations.key(name.to_sym),
|
44
|
+
"Expected #{subject} to map property #{name} from #{from}"
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def assert_property_default(name, default)
|
49
|
+
assert_equal(
|
50
|
+
default,
|
51
|
+
subject.defaults[name.to_sym],
|
52
|
+
"Expected #{subject} to have default for property #{name}"
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Resteze
|
2
|
+
module Testing
|
3
|
+
module Configuration
|
4
|
+
# Assert that a config property is supported and can be assigned
|
5
|
+
def assert_config_property(property, value = nil, subject: nil)
|
6
|
+
subject ||= (defined?(@subject) && @subject) || self.subject
|
7
|
+
original_value = subject.send(property)
|
8
|
+
|
9
|
+
expect(subject.send(property)).to eq(value), "config property #{property} value did not match expectation"
|
10
|
+
ensure
|
11
|
+
# Make sure to set the original value at the end
|
12
|
+
subject.send("#{property}=", original_value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Resteze
|
2
|
+
module Testing
|
3
|
+
module RSpec
|
4
|
+
module Object
|
5
|
+
extend RSpec::Matchers
|
6
|
+
|
7
|
+
# rubocop:disable Metrics/AbcSize
|
8
|
+
# rubocop:disable Naming/PredicatePrefix
|
9
|
+
def has_property(name, **options)
|
10
|
+
expect(subject.property?(name.to_sym)).to be(true), "Expected #{subject} to have property: #{name}"
|
11
|
+
assert_property_default(name, options[:default]) if options.key?(:default)
|
12
|
+
assert_property_translation(name, options[:from]) if options.key?(:from)
|
13
|
+
assert_property_transformed(name, transformed: options[:transformed]) if options.key?(:transformed)
|
14
|
+
assert_property_required(name, required: options[:required]) if options.key?(:required)
|
15
|
+
end
|
16
|
+
# rubocop:enable Naming/PredicatePrefix
|
17
|
+
|
18
|
+
def assert_property_transformed(name, transformed: true)
|
19
|
+
translation = subject.translations_hash.dig(subject.translations.key(name.to_sym), name.to_sym)
|
20
|
+
transformation_defined = translation.is_a?(Proc) || subject.transformation_exists?(name.to_sym)
|
21
|
+
|
22
|
+
if transformed
|
23
|
+
expect(transformation_defined).to be(true), "Expected #{subject} to transform property: #{name}"
|
24
|
+
else
|
25
|
+
expect(transformation_defined).to be(false), "Expected #{subject} not to transform property: #{name}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
# rubocop:enable Metrics/AbcSize
|
29
|
+
|
30
|
+
def assert_property_required(name, required: true)
|
31
|
+
if required
|
32
|
+
expect(subject.required?(name.to_sym)).to be(true), "Expected #{subject} to require property: #{name}"
|
33
|
+
else
|
34
|
+
expect(subject.required?(name.to_sym)).to be(false), "Expected #{subject} not to require property: #{name}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def assert_property_translation(name, from)
|
39
|
+
expect(subject.translations.key(name.to_sym)).to eq(from.to_sym),
|
40
|
+
"Expected #{subject} to map property #{name} from #{from}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def assert_property_default(name, default)
|
44
|
+
expect(subject.defaults[name.to_sym]).to eq(default), "Expected #{subject} to have default for property #{name}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/resteze/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resteze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JD Hendrickson
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- ".rubocop"
|
76
76
|
- ".rubocop.yml"
|
77
77
|
- ".ruby-version"
|
78
|
+
- CHANGELOG.md
|
78
79
|
- Guardfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|
@@ -93,6 +94,12 @@ files:
|
|
93
94
|
- lib/resteze/request.rb
|
94
95
|
- lib/resteze/response.rb
|
95
96
|
- lib/resteze/save.rb
|
97
|
+
- lib/resteze/testing/minitest.rb
|
98
|
+
- lib/resteze/testing/minitest/configuration.rb
|
99
|
+
- lib/resteze/testing/minitest/object.rb
|
100
|
+
- lib/resteze/testing/rspec.rb
|
101
|
+
- lib/resteze/testing/rspec/configure.rb
|
102
|
+
- lib/resteze/testing/rspec/object.rb
|
96
103
|
- lib/resteze/util.rb
|
97
104
|
- lib/resteze/version.rb
|
98
105
|
- sig/resteze.rbs
|