committee 1.7.0 → 1.7.1

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: f1a97b0ff3619376580988532aad290aa2257c95
4
- data.tar.gz: 991b2c60eed65c47dd3206ae7703c9a19a57d2d8
3
+ metadata.gz: 3e94b1d2b86d37d5a8caf1038b86f586b1abcc0e
4
+ data.tar.gz: 6c8eeb7064f3153067f00a0435a5a05531e054e9
5
5
  SHA512:
6
- metadata.gz: 77ea946d592580572727954316cf802ee5012d442f7f0e2ded8f9e1c2854225f9287f13137451bf2cf1dbd187dadd507fdf1bb5fa9efab55f5fd7b4edc69d67e
7
- data.tar.gz: ba57411ac8dc2110ad4ac17fe1e928f2370ba558b2c3648008369c4e5ebfabc478e4405aa23d9742e69932c7f4708e667e2a8b8593c050c4a50ebfcef2e727a0
6
+ metadata.gz: 409d877ea286153b57ca5b3492c53ea86b2b307777c01f64f84612fc5ce22c7125d3ab9f1ec9baab9ebcacbd27bf6d0f18526e847b5b1d34d5853255ca4c69b5
7
+ data.tar.gz: 04777cf0d9a53e69f9cbc702cd1c6f83c338fbb2e4c1d7e65d40c387e8428fdc16071a2c7397642a2af508b49704fc2234d74c0890d1cb4daa2d3f4aacbea77c
@@ -11,7 +11,8 @@ module Committee
11
11
 
12
12
  def call(status, headers, data)
13
13
  unless status == 204 # 204 No Content
14
- check_content_type!(headers)
14
+ response = Rack::Response.new(data, status, headers)
15
+ check_content_type!(response)
15
16
  end
16
17
 
17
18
  if @link.rel == "instances" && !@link.target_schema
@@ -35,13 +36,10 @@ module Committee
35
36
 
36
37
  private
37
38
 
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
39
+ def check_content_type!(response)
40
+ unless Rack::Mime.match?(response.content_type.to_s, @link.enc_type)
43
41
  raise Committee::InvalidResponse,
44
- %{"Content-Type" response header must be set to "application/json".}
42
+ %{"Content-Type" response header must be set to "#{@link.enc_type}".}
45
43
  end
46
44
  end
47
45
  end
@@ -35,21 +35,24 @@ describe Committee::ResponseValidator do
35
35
  assert_equal message, e.message
36
36
  end
37
37
 
38
- it "detects an invalid response Content-Type" do
38
+ it "detects a blank response Content-Type" do
39
39
  @headers = {}
40
40
  e = assert_raises(Committee::InvalidResponse) { call }
41
41
  message =
42
- %{"Content-Type" response header must be set to "application/json".}
42
+ %{"Content-Type" response header must be set to "#{@link.enc_type}".}
43
43
  assert_equal message, e.message
44
44
  end
45
45
 
46
- it "allows no Content-Type for 204 No Content" do
47
- @status, @headers = 204, {}
48
- call
46
+ it "detects an invalid response Content-Type" do
47
+ @headers = { "Content-Type" => "text/html" }
48
+ e = assert_raises(Committee::InvalidResponse) { call }
49
+ message =
50
+ %{"Content-Type" response header must be set to "#{@link.enc_type}".}
51
+ assert_equal message, e.message
49
52
  end
50
53
 
51
- it "allows application/schema+json in responses as well" do
52
- @headers = { "Content-Type" => "application/schema+json" }
54
+ it "allows no Content-Type for 204 No Content" do
55
+ @status, @headers = 204, {}
53
56
  call
54
57
  end
55
58
 
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.7.0
4
+ version: 1.7.1
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-02-22 00:00:00.000000000 Z
12
+ date: 2015-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_schema