rspec_api_docs 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec_api_docs.rb +6 -12
- data/lib/rspec_api_docs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63116ee00221ca9def40076d11bd15af14f8d6eb
|
4
|
+
data.tar.gz: be505206040db12af2821dc6538aaa3090d7f712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf680eb8b1a95e7a8d9c9ebe43792ab27ad95665d4c3ecb1f4cd5e34899c81942fdad8ae8835fd3ba84d05698bf18023d09fb5360a5befffab0d5a96ef2cba6
|
7
|
+
data.tar.gz: 4033b945fc522108743a89fb62ac082dea47e1ef415d418bc94c7c7dd8554a8f1d11aaeaaea3ab42ce16507e3e5551e55c192b16e44e2a9ebc9273f0790366be
|
data/lib/rspec_api_docs.rb
CHANGED
@@ -5,8 +5,10 @@ require "rspec_api_docs/helper"
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.before(:suite) do
|
7
7
|
next unless RspecApiDocs::Helper.running_api_specs?(config)
|
8
|
-
|
9
8
|
file = RspecApiDocs::Helper.file
|
9
|
+
|
10
|
+
# Delete and re-create the file each time
|
11
|
+
File.delete(file) if File.exists?(file)
|
10
12
|
File.new(file, "w+") unless File.exists?(file)
|
11
13
|
end
|
12
14
|
|
@@ -17,21 +19,13 @@ RSpec.configure do |config|
|
|
17
19
|
next unless request && request.try(:symbolized_path_parameters)
|
18
20
|
|
19
21
|
if response
|
20
|
-
example_group = example.metadata[:example_group]
|
21
|
-
example_groups = []
|
22
|
-
|
23
|
-
while example_group
|
24
|
-
example_groups << example_group
|
25
|
-
example_group = example_group[:example_group]
|
26
|
-
end
|
27
|
-
|
28
22
|
file_name = request.symbolized_path_parameters[:controller].gsub(/\//, '_').gsub('api_', '')
|
29
23
|
|
30
24
|
id_symbol = request.symbolized_path_parameters.keys.find{|k| k.match /id/}
|
31
25
|
optional_param = request.symbolized_path_parameters[id_symbol] ? "/{:#{id_symbol}}" : ""
|
32
26
|
action = "#{request.request_method} #{request.symbolized_path_parameters[:controller]}#{optional_param}"
|
33
27
|
|
34
|
-
file = RspecApiDocs::
|
28
|
+
file = RspecApiDocs::Helper.file
|
35
29
|
|
36
30
|
collection = action.match(/(POST|GET|PATCH|DELETE) (portal\/api|api)\/v\d*\/(.*)/)[3]
|
37
31
|
version_and_collection = action.match(/(POST|GET|PATCH|DELETE) (portal\/api|api)(.*)/)[3]
|
@@ -62,8 +56,8 @@ RSpec.configure do |config|
|
|
62
56
|
f.write "+ Request #{request.content_type}\n\n"
|
63
57
|
|
64
58
|
# Request Body
|
65
|
-
if request_body.present
|
66
|
-
f.write "+ Body\n\n".indent(4)
|
59
|
+
if request_body.present?
|
60
|
+
f.write "+ Body\n\n".indent(4)
|
67
61
|
f.write "#{JSON.pretty_generate(JSON.parse(JSON.pretty_generate(request_body)))}\n\n".indent(authorization_header ? 12 : 8)
|
68
62
|
end
|
69
63
|
end
|