committee 1.6.5 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/committee/response_validator.rb +7 -5
- data/test/response_validator_test.rb +7 -10
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1a97b0ff3619376580988532aad290aa2257c95
|
4
|
+
data.tar.gz: 991b2c60eed65c47dd3206ae7703c9a19a57d2d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ea946d592580572727954316cf802ee5012d442f7f0e2ded8f9e1c2854225f9287f13137451bf2cf1dbd187dadd507fdf1bb5fa9efab55f5fd7b4edc69d67e
|
7
|
+
data.tar.gz: ba57411ac8dc2110ad4ac17fe1e928f2370ba558b2c3648008369c4e5ebfabc478e4405aa23d9742e69932c7f4708e667e2a8b8593c050c4a50ebfcef2e727a0
|
@@ -11,8 +11,7 @@ module Committee
|
|
11
11
|
|
12
12
|
def call(status, headers, data)
|
13
13
|
unless status == 204 # 204 No Content
|
14
|
-
|
15
|
-
check_content_type!(response)
|
14
|
+
check_content_type!(headers)
|
16
15
|
end
|
17
16
|
|
18
17
|
if @link.rel == "instances" && !@link.target_schema
|
@@ -36,10 +35,13 @@ module Committee
|
|
36
35
|
|
37
36
|
private
|
38
37
|
|
39
|
-
def check_content_type!(
|
40
|
-
|
38
|
+
def check_content_type!(headers)
|
39
|
+
match = [%r{application/json}, %r{application/schema\+json}].any? { |m|
|
40
|
+
headers["Content-Type"] =~ m
|
41
|
+
}
|
42
|
+
unless match
|
41
43
|
raise Committee::InvalidResponse,
|
42
|
-
%{"Content-Type" response header must be set to "
|
44
|
+
%{"Content-Type" response header must be set to "application/json".}
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -35,19 +35,11 @@ describe Committee::ResponseValidator do
|
|
35
35
|
assert_equal message, e.message
|
36
36
|
end
|
37
37
|
|
38
|
-
it "detects a blank response Content-Type" do
|
39
|
-
@headers = {}
|
40
|
-
e = assert_raises(Committee::InvalidResponse) { call }
|
41
|
-
message =
|
42
|
-
%{"Content-Type" response header must be set to "#{@link.enc_type}".}
|
43
|
-
assert_equal message, e.message
|
44
|
-
end
|
45
|
-
|
46
38
|
it "detects an invalid response Content-Type" do
|
47
|
-
@headers = {
|
39
|
+
@headers = {}
|
48
40
|
e = assert_raises(Committee::InvalidResponse) { call }
|
49
41
|
message =
|
50
|
-
%{"Content-Type" response header must be set to "
|
42
|
+
%{"Content-Type" response header must be set to "application/json".}
|
51
43
|
assert_equal message, e.message
|
52
44
|
end
|
53
45
|
|
@@ -56,6 +48,11 @@ describe Committee::ResponseValidator do
|
|
56
48
|
call
|
57
49
|
end
|
58
50
|
|
51
|
+
it "allows application/schema+json in responses as well" do
|
52
|
+
@headers = { "Content-Type" => "application/schema+json" }
|
53
|
+
call
|
54
|
+
end
|
55
|
+
|
59
56
|
it "raises errors generated by json_schema" do
|
60
57
|
@data.merge!("name" => "%@!")
|
61
58
|
e = assert_raises(Committee::InvalidResponse) { call }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: committee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_schema
|
@@ -161,9 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.4.5
|
165
165
|
signing_key:
|
166
166
|
specification_version: 4
|
167
167
|
summary: A collection of Rack middleware to support JSON Schema.
|
168
168
|
test_files: []
|
169
|
-
has_rdoc:
|