committee 1.7.2 → 1.7.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: 4db940a56b1cd87d070a6d084aad49a6c3ea75d7
4
- data.tar.gz: 7cec1cdb5da554e7cd9851c8edfaed73e3007d52
3
+ metadata.gz: 08d72b960842e3d882e0f819b9f8464d9a7932dc
4
+ data.tar.gz: 6c6a91b3a7abac8af97f9656772682657bd0ac14
5
5
  SHA512:
6
- metadata.gz: 1593142fbaee0fe7ec0aa232ed517546a4ad5a612d92e7fc370791b164dab2e0529c378d6385a477adf4aa765c4f92249d58ce202bcb963b9e39cb2fb1801053
7
- data.tar.gz: 7e83215c71913202b83d0304baebe3f742b8d74a8d22addef2361d947643bd86b3e838e2f745d4cc0ae62195a16cadb6b2541c9b7f863a048cf0df0de7ce0711
6
+ metadata.gz: 6d9a2d07de3c322de9095c4f60d5c23321ed732c587b78f6b8ce6a5d91be9142e57a186b7b1cda0fe7ae28be3c8667da136744da81c3674baa4b27d22d8a4081
7
+ data.tar.gz: b0776703f87405d4dd0f1b5b770e913820afe8ed6ea1da7cd73841c31e44cc805da9cfa9cdf3dd21ac9c41a1e1f89b2a7dc03a1365899a8f6783ed8e42405f37
@@ -28,7 +28,7 @@ module Committee::Middleware
28
28
  end
29
29
 
30
30
  def validate?(status)
31
- status != 204 and @validate_errors || (200...300).include?(status)
31
+ Committee::ResponseValidator.validate?(status)
32
32
  end
33
33
  end
34
34
  end
@@ -9,6 +9,10 @@ module Committee
9
9
  @validator = JsonSchema::Validator.new(schema)
10
10
  end
11
11
 
12
+ def self.validate?(status)
13
+ status != 204 and @validate_errors || (200...300).include?(status)
14
+ end
15
+
12
16
  def call(status, headers, data)
13
17
  unless status == 204 # 204 No Content
14
18
  response = Rack::Response.new(data, status, headers)
@@ -28,7 +32,7 @@ module Committee
28
32
  return if data == nil
29
33
  end
30
34
 
31
- if !@validator.validate(data)
35
+ if self.class.validate?(status) && !@validator.validate(data)
32
36
  errors = JsonSchema::SchemaError.aggregate(@validator.errors).join("\n")
33
37
  raise InvalidResponse, "Invalid response.\n\n#{errors}"
34
38
  end
@@ -18,8 +18,10 @@ module Committee::Test
18
18
  raise Committee::InvalidResponse.new(response)
19
19
  end
20
20
 
21
- data = MultiJson.decode(last_response.body)
22
- Committee::ResponseValidator.new(link).call(last_response.status, last_response.headers, data)
21
+ if validate_response?(last_response.status)
22
+ data = MultiJson.decode(last_response.body)
23
+ Committee::ResponseValidator.new(link).call(last_response.status, last_response.headers, data)
24
+ end
23
25
  end
24
26
 
25
27
  def assert_schema_content_type
@@ -44,5 +46,9 @@ module Committee::Test
44
46
  def warn_string_deprecated
45
47
  Committee.warn_deprecated("Committee: returning a string from `#schema_contents` is deprecated; please return a deserialized hash instead.")
46
48
  end
49
+
50
+ def validate_response?(status)
51
+ Committee::ResponseValidator.validate?(status)
52
+ end
47
53
  end
48
54
  end
@@ -32,6 +32,11 @@ describe Committee::ResponseValidator do
32
32
  call
33
33
  end
34
34
 
35
+ it "passes through a 204 No Content response" do
36
+ @status, @headers, @data = 204, {}, nil
37
+ call
38
+ end
39
+
35
40
  it "detects an improperly formatted list response" do
36
41
  @link = @list_link
37
42
  @link.target_schema = nil
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.2
4
+ version: 1.7.3
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-19 00:00:00.000000000 Z
12
+ date: 2015-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_schema