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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e30bacadb0a6825eea17ad9ab5dfbd2fa8ace16
4
- data.tar.gz: 583d602a06414ccbe915c724c2b35ba961c5dfb1
3
+ metadata.gz: 3052bec055e4531609acc4f509cf2109088495d7
4
+ data.tar.gz: cfeeb3b1b98f02388affd0445fe3f26fcb0aeafe
5
5
  SHA512:
6
- metadata.gz: e74b5eb5fe9e52d278aab9b4ce560576e3349d3bca7e4360cfbcdbad5eb4a2f43117f3867f08eb7473d5b7369a316bae7885703650569db5dbe89ff28ffa9673
7
- data.tar.gz: 6e0c5a3a2b268bec4473d52d9f81682fd21782f5333b3d43c8b61c1b1d62d43084e5b1be460bfe76c88d55e877ced9918ca9a49f5a71bf5f1c99f881844bc8dd
6
+ metadata.gz: 72ed9fed21dac59c45ce32cd123a26a1b6b970f8814f749704092e6f72b7ac7712924748bfb23566eeb439fd6ea4fec79d400bbee8e68edd4cd3fea5f3ea84ce
7
+ data.tar.gz: 830a617bad45287beba0865e2d8e1288e199a0a5eba055261a4aae3931fdf61d3bcab4ce3667aae7477d39ef6ed5d8d292cc0bfee5aea02a0a79231cfd9699a7
@@ -1,3 +1,6 @@
1
+ ## v0.1.3
2
+ * Array response support of Rack::Spec::ResponseValidation
3
+
1
4
  ## v0.1.2
2
5
  * Change Content-Type validation policy
3
6
  * Add Rack::Spec::ResponseValidation
@@ -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(data)
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
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Spec
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -22,7 +22,11 @@ describe Rack::Spec do
22
22
  end
23
23
 
24
24
  let(:response_body) do
25
- response_data.to_json
25
+ if verb == :get
26
+ [response_data].to_json
27
+ else
28
+ response_data.to_json
29
+ end
26
30
  end
27
31
 
28
32
  let(:response_data) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura