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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e19343ffb0ef2e64ac07c4cac4b0cfea513dfb1
4
- data.tar.gz: db3766715d0b18b7ebfb4f36753f089c981a099e
3
+ metadata.gz: f1a97b0ff3619376580988532aad290aa2257c95
4
+ data.tar.gz: 991b2c60eed65c47dd3206ae7703c9a19a57d2d8
5
5
  SHA512:
6
- metadata.gz: d28f2a33a2c378ec68b302c0391172cda7f2bc12e344abc250f7d42ec952833cdd8e0bf146d6019b965ca0f1ec577e66fcfbdec5d2d44497947a48f284ef4e05
7
- data.tar.gz: 9f13aea9de25ad5b03968f249fb2052cb9b2eb0ba9eb4d2c43b82eaa21b3977dfa29e3112d82e211947b27a0afc15a4f8b3a52cfd678bf768a1424e52794b338
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
- response = Rack::Response.new(data, status, headers)
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!(response)
40
- unless Rack::Mime.match?(response.content_type.to_s, @link.enc_type)
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 "#{@link.enc_type}".}
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 = { "Content-Type" => "text/html" }
39
+ @headers = {}
48
40
  e = assert_raises(Committee::InvalidResponse) { call }
49
41
  message =
50
- %{"Content-Type" response header must be set to "#{@link.enc_type}".}
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.6.5
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-03-03 00:00:00.000000000 Z
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.2.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: