rspec-document_requests 1.0.0 → 1.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03e9589029b92f3ada8618b326ff040977a76133
|
4
|
+
data.tar.gz: e9716f03981863fd054f918b3a44ef1c81aec23d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb10351bf8ef26ecd1a8553e270391dfcde8d0a057331fefcedcce769cd52b03e4e5dc605978886225848427c2e57195b2cf8521a69293413c0a5484faa1e8eb
|
7
|
+
data.tar.gz: c37df01da4e7339431a5c5431a1cd65fc1a4d76b8a8ee0c8bdd5aa7d6b8511a80490c09dcd7443ee9f8a9f3cd8ac4515fdda9d4cacf8db78b360be61fb5e264c
|
@@ -23,7 +23,6 @@ module RSpec
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
@document_request_explanation = Explanation.new
|
26
|
-
DSL.currently_documented_example = nil
|
27
26
|
|
28
27
|
result
|
29
28
|
end
|
@@ -57,6 +56,7 @@ RSpec.configure do |config|
|
|
57
56
|
|
58
57
|
config.after(:suite) { RSpec::DocumentRequests::Builder.new }
|
59
58
|
config.before { |ex| RSpec::DocumentRequests::DSL.currently_documented_example = ex }
|
59
|
+
config.after { |ex| RSpec::DocumentRequests::DSL.currently_documented_example = nil }
|
60
60
|
end
|
61
61
|
|
62
62
|
config.include RSpec::DocumentRequests::DSL, doc: true
|
@@ -12,7 +12,7 @@ module RSpec
|
|
12
12
|
end
|
13
13
|
|
14
14
|
attr_reader :explanation, :example, :method, :path
|
15
|
-
attr_reader :request_parameters, :request_headers
|
15
|
+
attr_reader :request_body, :request_parameters, :request_headers
|
16
16
|
attr_reader :response, :parsed_response, :response_parameters, :response_headers
|
17
17
|
def initialize(explanation:, example:, method:, path:, request_parameters:, request_headers:, response:)
|
18
18
|
@explanation = explanation
|
@@ -21,8 +21,12 @@ module RSpec
|
|
21
21
|
@path = path
|
22
22
|
@response = response
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
if request_parameters.is_a?(Hash)
|
25
|
+
process_request_parameters(request_parameters)
|
26
|
+
else
|
27
|
+
@request_body = request_parameters
|
28
|
+
end
|
29
|
+
process_request_headers(request_headers || {})
|
26
30
|
process_response_parameters
|
27
31
|
process_response_headers
|
28
32
|
end
|
@@ -36,12 +36,19 @@ module RSpec
|
|
36
36
|
|
37
37
|
FILE
|
38
38
|
|
39
|
-
if request.request_parameters.any?
|
39
|
+
if request.request_parameters and request.request_parameters.any?
|
40
40
|
@file.write <<FILE
|
41
41
|
#### Parameters
|
42
42
|
|
43
43
|
FILE
|
44
44
|
parameters_table(request.request_parameters)
|
45
|
+
elsif request.request_body
|
46
|
+
@file.write <<FILE
|
47
|
+
#### Body
|
48
|
+
|
49
|
+
#{request.request_body}
|
50
|
+
|
51
|
+
FILE
|
45
52
|
end
|
46
53
|
|
47
54
|
if request.request_headers.any?
|
@@ -97,7 +104,7 @@ FILE
|
|
97
104
|
|------|------|-----------|-------|---|
|
98
105
|
FILE
|
99
106
|
|
100
|
-
parameters.
|
107
|
+
parameters.each do |name, parameter|
|
101
108
|
@file.puts "| #{name} | #{parameter.type} | #{"Required" if parameter.required} | #{parameter.value} | #{parameter.message} |"
|
102
109
|
end
|
103
110
|
@file.puts
|