rspec-request_snapshot 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +5 -5
- data/lib/rspec/request_snapshot/handlers/json.rb +23 -6
- data/lib/rspec/request_snapshot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 064a2bd24422bf55dec9a6e2272481a14fbc8819
|
4
|
+
data.tar.gz: ad9e88a9e83e8216135d7b57d6eb7eaefadd00fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6773e770587d2ad04ea6d3e049d0bca8bcc9663473801aebaeb6da9701df471b8e0f3b2fc0ed83147e449c57d8e3d3a5cf6219f027ba6ac186cf9db6a181c991
|
7
|
+
data.tar.gz: 5676af26f46bf00e36b6f4edfe95b2a5490dc9a1e20cce010ee5ea7f06f2a25be9dedeff5aabf14507274a25aafc2c49327840d270be53abe2380db5007a2de4
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-request_snapshot (0.6.
|
4
|
+
rspec-request_snapshot (0.6.2)
|
5
5
|
rspec (~> 3.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -15,15 +15,15 @@ GEM
|
|
15
15
|
rspec-core (~> 3.8.0)
|
16
16
|
rspec-expectations (~> 3.8.0)
|
17
17
|
rspec-mocks (~> 3.8.0)
|
18
|
-
rspec-core (3.8.
|
18
|
+
rspec-core (3.8.1)
|
19
19
|
rspec-support (~> 3.8.0)
|
20
|
-
rspec-expectations (3.8.
|
20
|
+
rspec-expectations (3.8.4)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
22
|
rspec-support (~> 3.8.0)
|
23
|
-
rspec-mocks (3.8.
|
23
|
+
rspec-mocks (3.8.1)
|
24
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
25
25
|
rspec-support (~> 3.8.0)
|
26
|
-
rspec-support (3.8.
|
26
|
+
rspec-support (3.8.2)
|
27
27
|
simplecov (0.16.1)
|
28
28
|
docile (~> 1.1)
|
29
29
|
json (>= 1.8, < 3)
|
@@ -6,7 +6,7 @@ class Rspec::RequestSnapshot::Handlers::JSON < Rspec::RequestSnapshot::Handlers:
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def comparable(str)
|
9
|
-
|
9
|
+
deep_transform_json(JSON.parse(str).dup)
|
10
10
|
end
|
11
11
|
|
12
12
|
def writable(str)
|
@@ -15,7 +15,18 @@ class Rspec::RequestSnapshot::Handlers::JSON < Rspec::RequestSnapshot::Handlers:
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
18
|
+
def deep_transform_json(json)
|
19
|
+
case json
|
20
|
+
when Array
|
21
|
+
deep_transform_array(json)
|
22
|
+
when Hash
|
23
|
+
deep_transform_hash(json)
|
24
|
+
else
|
25
|
+
json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def deep_transform_hash(hash)
|
19
30
|
hash.each_key do |key|
|
20
31
|
if dynamic_attributes.include?(key)
|
21
32
|
handle_dynamic_attribute(hash, key)
|
@@ -23,22 +34,28 @@ class Rspec::RequestSnapshot::Handlers::JSON < Rspec::RequestSnapshot::Handlers:
|
|
23
34
|
end
|
24
35
|
|
25
36
|
if hash[key].is_a?(Hash)
|
26
|
-
|
37
|
+
deep_transform_hash(hash[key])
|
27
38
|
next
|
28
39
|
end
|
29
40
|
|
30
|
-
|
41
|
+
deep_transform_hash_array(hash, key) if hash[key].is_a?(Array)
|
31
42
|
end
|
32
43
|
end
|
33
44
|
|
34
|
-
def
|
45
|
+
def deep_transform_hash_array(hash, key)
|
35
46
|
hash[key].each do |value|
|
36
|
-
|
47
|
+
deep_transform_hash(value) if value.is_a?(Hash)
|
37
48
|
end
|
38
49
|
|
39
50
|
sort_elements(hash, key) if ignore_order.include?(key)
|
40
51
|
end
|
41
52
|
|
53
|
+
def deep_transform_array(array)
|
54
|
+
array.map do |element|
|
55
|
+
deep_transform_json(element)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
42
59
|
def sort_elements(hash, key)
|
43
60
|
hash[key].first.is_a?(Hash) ? hash[key].sort_by! { |e| e.keys.map { |k| e[k] } } : hash[key].sort_by!(&:to_s)
|
44
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-request_snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Campos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|