rack-spec 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/rack/spec/response_validation.rb +15 -1
- data/lib/rack/spec/version.rb +1 -1
- data/spec/rack/spec_spec.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3052bec055e4531609acc4f509cf2109088495d7
|
4
|
+
data.tar.gz: cfeeb3b1b98f02388affd0445fe3f26fcb0aeafe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72ed9fed21dac59c45ce32cd123a26a1b6b970f8814f749704092e6f72b7ac7712924748bfb23566eeb439fd6ea4fec79d400bbee8e68edd4cd3fea5f3ea84ce
|
7
|
+
data.tar.gz: 830a617bad45287beba0865e2d8e1288e199a0a5eba055261a4aae3931fdf61d3bcab4ce3667aae7477d39ef6ed5d8d292cc0bfee5aea02a0a79231cfd9699a7
|
data/CHANGELOG.md
CHANGED
@@ -46,7 +46,21 @@ module Rack
|
|
46
46
|
|
47
47
|
# @return [true, false] True if given data is valid to the JSON schema
|
48
48
|
def valid?
|
49
|
-
!has_link_for_current_action? || validator.validate(
|
49
|
+
!has_link_for_current_action? || validator.validate(example_item)
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Hash] Choose an item from response data, to be validated
|
53
|
+
def example_item
|
54
|
+
if has_list_data?
|
55
|
+
data.first
|
56
|
+
else
|
57
|
+
data
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [true, false] True if response is intended to be list data
|
62
|
+
def has_list_data?
|
63
|
+
link.rel == "instances" && !link.target_schema
|
50
64
|
end
|
51
65
|
|
52
66
|
# @return [Array, Hash] Response body data, decoded from JSON
|
data/lib/rack/spec/version.rb
CHANGED
data/spec/rack/spec_spec.rb
CHANGED