apivore 1.4.3 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzM4N2M0MGU5M2Q3ZjYyMTlkY2NkMDBjY2IwODU3MjU0M2M1MjkzMQ==
4
+ NzY1YjcxZTU5MWMzN2Q4OWM5YWIzNzIxZDc0NTgzODcwODNkYmUzMw==
5
5
  data.tar.gz: !binary |-
6
- YzhhNzY1NTliNTUyM2I0YTBmM2IwYzk5YjY5YWVhN2JhNGY3N2JiMA==
6
+ ODIzZDFiNzczOWYzYTIxZmUyMDY5ZTlmNDNmNjY0YzZhYTIwMzgxNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWIwN2E4N2RlZTM1YmY4N2U4MGQ0ZGQ4OTMzNzJjMzQwYTIxZWJkMDk0YzYx
10
- YmU5ODYxMWZjMzExMGRiODkyOGFjZmIxMTY1ODcwMDBjNWI1Njc1NTdiMmVm
11
- NTI4ZjFiYWQxOTM3NzY5NzFkM2M3Y2IyMTk5N2NhY2ExNTlhMjY=
9
+ NGI1NzE3ODA3NzIzMWMyMmJhMjE4NTU2ZDNlYTNhNzczOWQ4MjJhZTU0MDZk
10
+ ZDAwMzA4NjBkNjVjN2ZiYTZjNzYyMmI3ZGQxYjExNjZmOWZmZDE2NzA2NGZh
11
+ ODUwYTJjNzMyY2YxZjEzNDhjM2IyOGRhY2ZmNzk1N2U0YTljMmE=
12
12
  data.tar.gz: !binary |-
13
- MTk3Njk0MTI0MjA5ZDI0ZGQ4ZjJiYmIwMjRjYmJjNjU4YWRhMmEyMGI4NWYz
14
- MjMwMWYyNWJhMmZlMThlNmJjYWVlZWUzOTk0YzFlYzRiNWUwNGVkMTJmNmNm
15
- Mzg2YTgwNWYzZWNjMDI0YjVjNGZiNWYxMjIyODkxYWY4ODUxNTE=
13
+ ODhiMGUzODZjZDkzY2VmNjlkYzMwNjVhM2UwMDc4N2Y2YTQ1MzViMWI3M2E4
14
+ YmYwZDUyMGU4NDhkYjkwNzRhZjY1NGRkYzk1M2I2OThiZmUwY2E2YzlhNzY4
15
+ ZTk5ZDkxMjE5MjQzNWRkYmY0ZTk5Y2ZiZWM1NmJhNWFiNjY3MzI=
@@ -18,6 +18,10 @@ module Apivore
18
18
  mappings[path][method].has_key?(code.to_s)
19
19
  end
20
20
 
21
+ def response_codes_for_path(path, method)
22
+ mappings[path][method].keys.join(", ")
23
+ end
24
+
21
25
  def has_matching_document_for(path, method, code, body)
22
26
  JSON::Validator.fully_validate(
23
27
  swagger, body, fragment: fragment(path, method, code)
@@ -45,7 +49,11 @@ module Apivore
45
49
  @swagger.base_path
46
50
  end
47
51
 
48
- attr_reader :swagger_path, :untested_mappings, :swagger
52
+ def response=(response)
53
+ @response = response
54
+ end
55
+
56
+ attr_reader :response, :swagger, :swagger_path, :untested_mappings
49
57
 
50
58
  private
51
59
 
@@ -24,7 +24,13 @@ module Apivore
24
24
  params['_data'] || {},
25
25
  params['_headers'] || {}
26
26
  )
27
+ swagger_checker.response = response
27
28
  post_checks(swagger_checker)
29
+
30
+ if has_errors? && response.body.length > 0
31
+ errors << "\nResponse body:\n #{JSON.pretty_generate(JSON.parse(response.body))}"
32
+ end
33
+
28
34
  swagger_checker.remove_tested_end_point_response(
29
35
  path, method, expected_response_code
30
36
  )
@@ -50,7 +56,6 @@ module Apivore
50
56
  path + (data['_query_string'] ? "?#{data['_query_string']}" : '')
51
57
  end
52
58
 
53
-
54
59
  def pre_checks(swagger_checker)
55
60
  check_request_path(swagger_checker)
56
61
  end
@@ -70,7 +75,8 @@ module Apivore
70
75
  elsif !swagger_checker.has_response_code_for_path?(path, method, expected_response_code)
71
76
  errors << "Swagger doc: #{swagger_checker.swagger_path} does not have"\
72
77
  " a documented response code of #{expected_response_code} at path"\
73
- " #{method} #{path}"
78
+ " #{method} #{path}. "\
79
+ "\n Available response codes: #{swagger_checker.response_codes_for_path(path, method)}"
74
80
  elsif method == "get" && swagger_checker.fragment(path, method, expected_response_code).nil?
75
81
  errors << "Swagger doc: #{swagger_checker.swagger_path} missing"\
76
82
  " response model for get request with #{path} for code"\
@@ -81,7 +87,7 @@ module Apivore
81
87
  def check_status_code
82
88
  if response.status != expected_response_code
83
89
  errors << "Path #{path} did not respond with expected status code."\
84
- " Expected #{expected_response_code} got #{response.status}"
90
+ " Expected #{expected_response_code} got #{response.status}"\
85
91
  end
86
92
  end
87
93
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apivore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Horn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  requirements: []
192
192
  rubyforge_project:
193
- rubygems_version: 2.4.5
193
+ rubygems_version: 2.5.1
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Tests your API against its Swagger 2.0 spec