rspec-json_api 1.4.0 → 1.5.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/.gitattributes +28 -0
- data/.github/workflows/main.yml +45 -20
- data/.gitignore +6 -0
- data/.rubocop.yml +41 -50
- data/CHANGELOG.md +55 -28
- data/Gemfile +14 -14
- data/Gemfile.lock +182 -262
- data/README.md +319 -319
- data/gemfiles/rails_6_1.gemfile +7 -0
- data/gemfiles/rails_7_1.gemfile +7 -0
- data/gemfiles/rails_7_2.gemfile +7 -0
- data/gemfiles/rails_8_0.gemfile +7 -0
- data/gemfiles/rails_8_1.gemfile +7 -0
- data/lib/generators/rspec/json_api/interface/interface_generator.rb +3 -1
- data/lib/generators/rspec/json_api/type/type_generator.rb +25 -23
- data/lib/rspec/json_api/constraints.rb +56 -0
- data/lib/rspec/json_api/matchers/match_json_schema.rb +14 -11
- data/lib/rspec/json_api/schema_match.rb +135 -0
- data/lib/rspec/json_api/traversal.rb +49 -0
- data/lib/rspec/json_api/types/uuid.rb +1 -1
- data/lib/rspec/json_api/version.rb +7 -7
- data/lib/rspec/json_api.rb +23 -25
- data/rspec-json_api.gemspec +42 -38
- metadata +13 -13
- data/lib/extensions/array.rb +0 -8
- data/lib/extensions/hash.rb +0 -36
- data/lib/generators/rspec/json_api/interface/templates/interface.erb +0 -9
- data/lib/rspec/json_api/compare_array.rb +0 -39
- data/lib/rspec/json_api/compare_hash.rb +0 -114
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6be977d812080cea5feea8a9c9a0a429196c43c06b2aa64e0e742a44e0eb66fd
|
|
4
|
+
data.tar.gz: 77d21174747915fb1c33607eb331e4cfbd8ae9ed9dfa13936bd1cf2436de41af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea7471b8cb4ed9e871917ec51f61426931c765f2c0c46f4bd0c2c5291b3af1fecd855646847897608eace564f734337d34290551b7fca82181b37f9a2eb856da
|
|
7
|
+
data.tar.gz: ef41fe2e7c32dfc6b605cfce7f847ef48a7c0f84878c32ca72178923a0f53e6f556541ef5d28cddb1cd795dc061be7016fa7970266ef369b3f0c693ffb41d9e7
|
data/.gitattributes
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Set default line ending behavior for all files
|
|
2
|
+
* text=lf
|
|
3
|
+
|
|
4
|
+
# Explicitly declare text files you want to always be normalized and converted
|
|
5
|
+
# to native line endings on checkout.
|
|
6
|
+
*.rb text=lf
|
|
7
|
+
*.rake text=lf
|
|
8
|
+
*.gemspec text=lf
|
|
9
|
+
Gemfile text=lf
|
|
10
|
+
Gemfile.lock text=lf
|
|
11
|
+
Rakefile text=lf
|
|
12
|
+
*.md text=lf
|
|
13
|
+
*.yml text=lf
|
|
14
|
+
*.yaml text=lf
|
|
15
|
+
*.json text=lf
|
|
16
|
+
*.txt text=lf
|
|
17
|
+
*.sh text=lf
|
|
18
|
+
|
|
19
|
+
# Denote all files that are truly binary and should not be modified.
|
|
20
|
+
*.png binary
|
|
21
|
+
*.jpg binary
|
|
22
|
+
*.jpeg binary
|
|
23
|
+
*.gif binary
|
|
24
|
+
*.ico binary
|
|
25
|
+
*.pdf binary
|
|
26
|
+
*.zip binary
|
|
27
|
+
*.tar binary
|
|
28
|
+
*.gz binary
|
data/.github/workflows/main.yml
CHANGED
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
name: Ruby
|
|
2
|
-
|
|
3
|
-
on: [push,pull_request]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
name: "rspec — Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}"
|
|
9
|
+
strategy:
|
|
10
|
+
fail-fast: false
|
|
11
|
+
matrix:
|
|
12
|
+
# Covers the supported range from the floor (Ruby 3.2 / Rails 6.1) to
|
|
13
|
+
# the current ceiling (Ruby 3.4 / Rails 8.1). Curated pairs avoid
|
|
14
|
+
# Ruby/Rails combinations that are not mutually supported.
|
|
15
|
+
include:
|
|
16
|
+
- { ruby: "3.2", gemfile: rails_6_1 }
|
|
17
|
+
- { ruby: "3.2", gemfile: rails_7_1 }
|
|
18
|
+
- { ruby: "3.3", gemfile: rails_7_2 }
|
|
19
|
+
- { ruby: "3.3", gemfile: rails_8_0 }
|
|
20
|
+
- { ruby: "3.4", gemfile: rails_8_0 }
|
|
21
|
+
- { ruby: "3.4", gemfile: rails_8_1 }
|
|
22
|
+
env:
|
|
23
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- name: Set up Ruby
|
|
27
|
+
uses: ruby/setup-ruby@v1
|
|
28
|
+
with:
|
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
|
30
|
+
bundler-cache: true
|
|
31
|
+
- name: Run rspec
|
|
32
|
+
run: bundle exec rspec
|
|
33
|
+
|
|
34
|
+
lint:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
name: rubocop
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v4
|
|
39
|
+
- name: Set up Ruby
|
|
40
|
+
uses: ruby/setup-ruby@v1
|
|
41
|
+
with:
|
|
42
|
+
ruby-version: "3.2"
|
|
43
|
+
bundler-cache: true
|
|
44
|
+
- name: Run rubocop
|
|
45
|
+
run: bundle exec rubocop
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,50 +1,41 @@
|
|
|
1
|
-
AllCops
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Metrics/
|
|
29
|
-
Exclude:
|
|
30
|
-
- "
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Enabled: false
|
|
43
|
-
|
|
44
|
-
Naming/PredicatePrefix:
|
|
45
|
-
Exclude:
|
|
46
|
-
- "lib/rspec/json_api/matchers.rb"
|
|
47
|
-
|
|
48
|
-
Naming/PredicateMethod:
|
|
49
|
-
Exclude:
|
|
50
|
-
- "lib/rspec/json_api/compare_hash.rb"
|
|
1
|
+
# Append to (rather than replace) RuboCop's default AllCops/Exclude, so the
|
|
2
|
+
# defaults such as vendor/**/* stay excluded. Without this, CI installs gems
|
|
3
|
+
# into vendor/bundle (bundler-cache) and RuboCop would lint third-party gems.
|
|
4
|
+
inherit_mode:
|
|
5
|
+
merge:
|
|
6
|
+
- Exclude
|
|
7
|
+
|
|
8
|
+
AllCops:
|
|
9
|
+
TargetRubyVersion: 3.2
|
|
10
|
+
NewCops: enable
|
|
11
|
+
SuggestExtensions: false
|
|
12
|
+
Exclude:
|
|
13
|
+
- "README.md"
|
|
14
|
+
- "vendor/**/*"
|
|
15
|
+
- "gemfiles/vendor/**/*"
|
|
16
|
+
|
|
17
|
+
Style/StringLiterals:
|
|
18
|
+
Enabled: true
|
|
19
|
+
EnforcedStyle: double_quotes
|
|
20
|
+
|
|
21
|
+
Style/StringLiteralsInInterpolation:
|
|
22
|
+
Enabled: true
|
|
23
|
+
EnforcedStyle: double_quotes
|
|
24
|
+
|
|
25
|
+
Layout/LineLength:
|
|
26
|
+
Max: 120
|
|
27
|
+
|
|
28
|
+
Metrics/BlockLength:
|
|
29
|
+
Exclude:
|
|
30
|
+
- "spec/**/*_spec.rb"
|
|
31
|
+
|
|
32
|
+
Style/Documentation:
|
|
33
|
+
Enabled: false
|
|
34
|
+
|
|
35
|
+
Naming/PredicatePrefix:
|
|
36
|
+
Exclude:
|
|
37
|
+
- "lib/rspec/json_api/matchers.rb"
|
|
38
|
+
|
|
39
|
+
Naming/PredicateMethod:
|
|
40
|
+
Exclude:
|
|
41
|
+
- "lib/rspec/json_api/schema_match.rb"
|
data/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,55 @@
|
|
|
1
|
-
## [Unreleased]
|
|
2
|
-
|
|
3
|
-
## [1.
|
|
4
|
-
|
|
5
|
-
###
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [1.5.0] - 2026-06-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- CI compatibility matrix across Ruby 3.2–3.4 and Rails 6.1, 7.1, 7.2, 8.0 and 8.1 (`gemfiles/` + GitHub Actions matrix), so the advertised version support is actually tested.
|
|
7
|
+
- `RSpec::JsonApi::Constraints` module encapsulating the schema `Proc` options DSL.
|
|
8
|
+
- `RSpec::JsonApi::SchemaMatch` as the single comparison entry point, and `RSpec::JsonApi::Traversal` for the internal structural helpers.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Depend on `railties` instead of the full `rails` meta-gem; the gem only uses ActiveSupport core extensions and `Rails::Generators`. Drops the dependency graph from 87 to 65 gems. The `>= 6.1.4.1` floor is unchanged.
|
|
12
|
+
- Unified array and hash comparison behind `SchemaMatch`; removed the duplicate `CompareArray` and `CompareHash` modules.
|
|
13
|
+
- Stopped monkey-patching core `Hash`/`Array`; `deep_keys`, `deep_key_paths`, `deep_sort` and `sanitize!` moved into the internal `Traversal` module.
|
|
14
|
+
- The failure diff is now built lazily, only when a match fails.
|
|
15
|
+
- An unsupported schema `Proc` option now raises `ArgumentError` instead of being silently ignored.
|
|
16
|
+
- Generators emit `# frozen_string_literal: true` and freeze the generated interface hash.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- Require `uri` so the built-in types load on Ruby 4.0 (previously raised `NameError` on load).
|
|
20
|
+
- Anchor the `UUID` type with `\A...\z` so multiline strings no longer pass validation.
|
|
21
|
+
- Rescue invalid JSON in `match_json_schema` instead of raising `JSON::ParserError`.
|
|
22
|
+
- Avoid a `TypeError` when a schema expects a nested object but the actual value is a scalar.
|
|
23
|
+
- Enforce key structure for interface-array elements; an element with an extra null-valued key no longer matches.
|
|
24
|
+
- Reset the memoized diff at the start of `matches?` so a reused matcher reflects the current actual value.
|
|
25
|
+
- Use `Regexp#match?` for regex comparison so it returns a Boolean instead of a match index.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
- Dead/broken `interface.erb` generator template.
|
|
29
|
+
|
|
30
|
+
## [1.4.0] - 2026-01-23
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
- Updated Ruby version requirement from `>= 3.0.0` to `>= 3.2.0` (required for Rails 8.1 compatibility)
|
|
34
|
+
- Maintained Rails compatibility: supports Rails `>= 6.1.4.1` including Rails 8.1
|
|
35
|
+
- Maintained ActiveSupport compatibility: supports ActiveSupport `>= 6.1.4.1` including Rails 8.1
|
|
36
|
+
- Maintained RSpec Rails compatibility: supports RSpec Rails `>= 5.0.2` (tested with Rails 8.1)
|
|
37
|
+
- Updated Bundler from 2.2.19 to 4.0.4 (latest version as of January 2026)
|
|
38
|
+
- Updated RuboCop to `~> 1.65` and updated TargetRubyVersion to 3.2
|
|
39
|
+
- Updated Rake to `~> 13.2`
|
|
40
|
+
- Updated Diffy to `~> 3.4`
|
|
41
|
+
- Updated all transitive dependencies to latest compatible versions
|
|
42
|
+
- Verified compatibility with Rails 8.1.2 while maintaining support for older Rails versions
|
|
43
|
+
- Added `rubygems_mfa_required` metadata for enhanced security
|
|
44
|
+
- Updated GitHub Actions CI workflow to use Ruby 3.2.2 and Bundler 4.0.4
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
- Fixed RuboCop style violations (trailing commas, empty literals, symbol proc usage)
|
|
48
|
+
- Fixed module function style (changed `extend self` to `module_function`)
|
|
49
|
+
- Fixed line endings in Gemfile (CRLF to LF)
|
|
50
|
+
- Fixed CI workflow bundler version mismatch
|
|
51
|
+
- Fixed README typos and improved code examples consistency
|
|
52
|
+
|
|
53
|
+
## [0.1.0] - 2021-08-24
|
|
54
|
+
|
|
55
|
+
- Initial release
|
data/Gemfile
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Bundler version: 4.0.4 (see Gemfile.lock BUNDLED WITH section)
|
|
4
|
-
source "https://rubygems.org"
|
|
5
|
-
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
6
|
-
|
|
7
|
-
# Specify your gem's dependencies in rspec-json_api.gemspec
|
|
8
|
-
gemspec
|
|
9
|
-
|
|
10
|
-
gem "activesupport", ">= 6.1.4.1"
|
|
11
|
-
gem "diffy", "~> 3.4"
|
|
12
|
-
gem "rake", "~> 13.2"
|
|
13
|
-
gem "rspec-rails", ">= 5.0.2"
|
|
14
|
-
gem "rubocop", "~> 1.65"
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Bundler version: 4.0.4 (see Gemfile.lock BUNDLED WITH section)
|
|
4
|
+
source "https://rubygems.org"
|
|
5
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
6
|
+
|
|
7
|
+
# Specify your gem's dependencies in rspec-json_api.gemspec
|
|
8
|
+
gemspec
|
|
9
|
+
|
|
10
|
+
gem "activesupport", ">= 6.1.4.1"
|
|
11
|
+
gem "diffy", "~> 3.4"
|
|
12
|
+
gem "rake", "~> 13.2"
|
|
13
|
+
gem "rspec-rails", ">= 5.0.2"
|
|
14
|
+
gem "rubocop", "~> 1.65"
|