rspec-json_api 1.0.3 → 1.1.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/.ruby-version +1 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +26 -9
- data/README.md +1 -1
- data/lib/extentions/hash.rb +1 -1
- data/lib/rspec/json_api/compare_hash.rb +12 -8
- data/lib/rspec/json_api/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f40d1a16f0eff4c046c4598ace80041df867575e52065a1b1dd298ec9cf98d6
|
|
4
|
+
data.tar.gz: 8aae365879c35374679dac663a490bdb5018a3646f8b30e64836700220aed5fb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a5b5fe0e572b4e1424ebd7e32d1d0178046ee111e1c9e69f09fbae69eda8c273fd98498570c6ab7a4b58c12b214d11bfd8eec701e1b4502770826cd2c1cf724
|
|
7
|
+
data.tar.gz: 82afdf75029cd84a8ae8bd84335a4ef48e5dab5db0682018a79a2f799991fcc1af8c069fd01abd3905fe4ee468e46d28cbc615e0cf4d5c8e80133e10abd309d7
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rspec-json_api (1.0
|
|
4
|
+
rspec-json_api (1.1.0)
|
|
5
5
|
activesupport (>= 6.1.4.1)
|
|
6
6
|
rails (>= 6.1.4.1)
|
|
7
7
|
rspec-rails (>= 5.0.2)
|
|
@@ -71,23 +71,38 @@ GEM
|
|
|
71
71
|
builder (3.2.4)
|
|
72
72
|
concurrent-ruby (1.1.9)
|
|
73
73
|
crass (1.0.6)
|
|
74
|
+
date (3.3.4)
|
|
74
75
|
diff-lcs (1.5.0)
|
|
75
76
|
erubi (1.10.0)
|
|
76
|
-
globalid (1.
|
|
77
|
-
activesupport (>=
|
|
77
|
+
globalid (1.2.1)
|
|
78
|
+
activesupport (>= 6.1)
|
|
78
79
|
i18n (1.9.1)
|
|
79
80
|
concurrent-ruby (~> 1.0)
|
|
80
81
|
loofah (2.13.0)
|
|
81
82
|
crass (~> 1.0.2)
|
|
82
83
|
nokogiri (>= 1.5.9)
|
|
83
|
-
mail (2.
|
|
84
|
+
mail (2.8.1)
|
|
84
85
|
mini_mime (>= 0.1.1)
|
|
86
|
+
net-imap
|
|
87
|
+
net-pop
|
|
88
|
+
net-smtp
|
|
85
89
|
marcel (1.0.2)
|
|
86
90
|
method_source (1.0.0)
|
|
87
|
-
mini_mime (1.1.
|
|
91
|
+
mini_mime (1.1.5)
|
|
92
|
+
mini_portile2 (2.7.1)
|
|
88
93
|
minitest (5.15.0)
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
net-imap (0.4.4)
|
|
95
|
+
date
|
|
96
|
+
net-protocol
|
|
97
|
+
net-pop (0.1.2)
|
|
98
|
+
net-protocol
|
|
99
|
+
net-protocol (0.2.2)
|
|
100
|
+
timeout
|
|
101
|
+
net-smtp (0.4.0)
|
|
102
|
+
net-protocol
|
|
103
|
+
nio4r (2.5.9)
|
|
104
|
+
nokogiri (1.13.1)
|
|
105
|
+
mini_portile2 (~> 2.7.0)
|
|
91
106
|
racc (~> 1.4)
|
|
92
107
|
racc (1.6.0)
|
|
93
108
|
rack (2.2.3)
|
|
@@ -137,7 +152,7 @@ GEM
|
|
|
137
152
|
rspec-mocks (~> 3.10)
|
|
138
153
|
rspec-support (~> 3.10)
|
|
139
154
|
rspec-support (3.10.3)
|
|
140
|
-
sprockets (4.
|
|
155
|
+
sprockets (4.1.1)
|
|
141
156
|
concurrent-ruby (~> 1.0)
|
|
142
157
|
rack (> 1, < 3)
|
|
143
158
|
sprockets-rails (3.4.2)
|
|
@@ -145,14 +160,16 @@ GEM
|
|
|
145
160
|
activesupport (>= 5.2)
|
|
146
161
|
sprockets (>= 3.0.0)
|
|
147
162
|
thor (1.2.1)
|
|
163
|
+
timeout (0.4.1)
|
|
148
164
|
tzinfo (2.0.4)
|
|
149
165
|
concurrent-ruby (~> 1.0)
|
|
150
|
-
websocket-driver (0.7.
|
|
166
|
+
websocket-driver (0.7.6)
|
|
151
167
|
websocket-extensions (>= 0.1.0)
|
|
152
168
|
websocket-extensions (0.1.5)
|
|
153
169
|
zeitwerk (2.5.4)
|
|
154
170
|
|
|
155
171
|
PLATFORMS
|
|
172
|
+
arm64-darwin-22
|
|
156
173
|
x86_64-darwin-20
|
|
157
174
|
|
|
158
175
|
DEPENDENCIES
|
data/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Generate directory tree:
|
|
|
24
24
|
|
|
25
25
|
rails generate rspec:json_api:install
|
|
26
26
|
|
|
27
|
-
Require gem assets in your `
|
|
27
|
+
Require gem assets in your `rails_helper.rb`
|
|
28
28
|
```ruby
|
|
29
29
|
Dir[File.join(__dir__, 'rspec', 'json_api', 'types', '*.rb')].each { |file| require file }
|
|
30
30
|
Dir[File.join(__dir__, 'rspec', 'json_api', 'interfaces', '*.rb')].each { |file| require file }
|
data/lib/extentions/hash.rb
CHANGED
|
@@ -10,9 +10,15 @@ module RSpec
|
|
|
10
10
|
def compare(actual, expected)
|
|
11
11
|
return false if actual.blank? && expected.present?
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
keys = expected.deep_key_paths | actual.deep_key_paths
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
compare_key_paths_and_values(keys, actual, expected)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def compare_key_paths_and_values(keys, actual, expected)
|
|
21
|
+
keys.all? do |key_path|
|
|
16
22
|
actual_value = actual.dig(*key_path)
|
|
17
23
|
expected_value = expected.dig(*key_path)
|
|
18
24
|
|
|
@@ -20,8 +26,6 @@ module RSpec
|
|
|
20
26
|
end
|
|
21
27
|
end
|
|
22
28
|
|
|
23
|
-
private
|
|
24
|
-
|
|
25
29
|
def compare_hash_values(actual_value, expected_value)
|
|
26
30
|
case expected_value
|
|
27
31
|
when Class
|
|
@@ -42,7 +46,7 @@ module RSpec
|
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
def compare_regexp(actual_value, expected_value)
|
|
45
|
-
actual_value =~ expected_value
|
|
49
|
+
actual_value.to_s =~ expected_value
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
def compare_proc(actual_value, expected_value)
|
|
@@ -88,10 +92,10 @@ module RSpec
|
|
|
88
92
|
|
|
89
93
|
actual_value.all? { |elem| compare(elem, interface) }
|
|
90
94
|
else
|
|
91
|
-
return false if actual_value
|
|
95
|
+
return false if actual_value&.size != expected_value&.size
|
|
92
96
|
|
|
93
|
-
|
|
94
|
-
elem.is_a?(Hash) ? compare(
|
|
97
|
+
expected_value.each_with_index.all? do |elem, index|
|
|
98
|
+
elem.is_a?(Hash) ? compare(actual_value[index], elem) : compare_value(actual_value[index], elem)
|
|
95
99
|
end
|
|
96
100
|
end
|
|
97
101
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-json_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michal Gajowiak
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -63,6 +63,7 @@ files:
|
|
|
63
63
|
- ".gitignore"
|
|
64
64
|
- ".rspec"
|
|
65
65
|
- ".rubocop.yml"
|
|
66
|
+
- ".ruby-version"
|
|
66
67
|
- CHANGELOG.md
|
|
67
68
|
- CODE_OF_CONDUCT.md
|
|
68
69
|
- Gemfile
|
|
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
112
113
|
- !ruby/object:Gem::Version
|
|
113
114
|
version: '0'
|
|
114
115
|
requirements: []
|
|
115
|
-
rubygems_version: 3.
|
|
116
|
+
rubygems_version: 3.4.10
|
|
116
117
|
signing_key:
|
|
117
118
|
specification_version: 4
|
|
118
119
|
summary: RSpec extension to test JSON API response.
|