rspec-document_requests 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rspec/document_requests/dsl.rb +1 -1
- data/lib/rspec/document_requests/explanation.rb +4 -4
- data/lib/rspec/document_requests/request.rb +1 -1
- data/lib/rspec/document_requests/version.rb +1 -1
- data/lib/rspec/document_requests/writers/markdown.rb +8 -8
- 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: bc000344bde08e36293ce8a3baf060288b0302d5
|
4
|
+
data.tar.gz: 39f6f21bca22ecb1fd529b632efee84b6b5e0966
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c77b38455da8936b95352f125609253061cf44dda9685bfd18d4b4dbd44979a6e466604f365cd2ef38b88bc9e5d4e4a741ffd6c9f45d7b69e4bb301878c3deae
|
7
|
+
data.tar.gz: 36accade2ab7448c6de009f1c6ad3be70fb1e1a1367fda065fe94afab04573dc46589fc32a9197d59913fb8e5ec687606047b811dfc3bdf61aa267786e86ce75
|
data/README.md
CHANGED
@@ -102,8 +102,8 @@ RSpec.describe "Session resource", type: :request, doc: true do
|
|
102
102
|
before do
|
103
103
|
explain do # No request explanation
|
104
104
|
request do
|
105
|
-
parameter 'session[username]', "The username", required: true, type:
|
106
|
-
parameter 'session[password]', required: true, type:
|
105
|
+
parameter 'session[username]', "The username", required: true, type: 'string'
|
106
|
+
parameter 'session[password]', required: true, type: 'string' # No explanation
|
107
107
|
header 'Content-Type', ... # you get the point
|
108
108
|
end
|
109
109
|
response do
|
@@ -26,13 +26,13 @@ module RSpec
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def request(&block)
|
29
|
-
|
30
|
-
@request
|
29
|
+
@request.instance_eval(&block) if block_given?
|
30
|
+
@request
|
31
31
|
end
|
32
32
|
|
33
33
|
def response(&block)
|
34
|
-
|
35
|
-
@response
|
34
|
+
@response.instance_eval(&block) if block_given?
|
35
|
+
@response
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -59,7 +59,7 @@ module RSpec
|
|
59
59
|
|
60
60
|
def process_request_parameters(parameters, prefix: nil)
|
61
61
|
@request_parameters = {}
|
62
|
-
process_parameters(
|
62
|
+
process_parameters(parameters, @request_parameters, explanation: @explanation.request.parameters)
|
63
63
|
end
|
64
64
|
|
65
65
|
def process_request_headers(headers)
|
@@ -30,7 +30,7 @@ module RSpec
|
|
30
30
|
|
31
31
|
def request(request, missing_levels:)
|
32
32
|
@file.write <<FILE
|
33
|
-
### Request
|
33
|
+
### Request#{" (#{request.explanation.message})" if request.explanation.message}
|
34
34
|
|
35
35
|
#{request.method} #{request.path}
|
36
36
|
|
@@ -38,7 +38,6 @@ FILE
|
|
38
38
|
|
39
39
|
if request.request_parameters.any?
|
40
40
|
@file.write <<FILE
|
41
|
-
|
42
41
|
#### Parameters
|
43
42
|
|
44
43
|
FILE
|
@@ -47,7 +46,6 @@ FILE
|
|
47
46
|
|
48
47
|
if request.request_headers.any?
|
49
48
|
@file.write <<FILE
|
50
|
-
|
51
49
|
#### Headers
|
52
50
|
|
53
51
|
FILE
|
@@ -55,13 +53,16 @@ FILE
|
|
55
53
|
end
|
56
54
|
|
57
55
|
@file.write <<FILE
|
58
|
-
|
59
56
|
### Response
|
60
57
|
|
61
58
|
#### Status
|
62
59
|
|
63
60
|
#{request.response.status} #{request.response.status_message}
|
64
61
|
|
62
|
+
#### Content-Type
|
63
|
+
|
64
|
+
#{request.response.content_type}
|
65
|
+
|
65
66
|
FILE
|
66
67
|
|
67
68
|
if request.response_parameters and request.response_parameters.any?
|
@@ -73,7 +74,6 @@ FILE
|
|
73
74
|
end
|
74
75
|
|
75
76
|
@file.write <<FILE
|
76
|
-
|
77
77
|
#### Body
|
78
78
|
|
79
79
|
#{request.response.body}
|
@@ -82,7 +82,6 @@ FILE
|
|
82
82
|
|
83
83
|
if request.response_headers.any?
|
84
84
|
@file.write <<FILE
|
85
|
-
|
86
85
|
#### Headers
|
87
86
|
|
88
87
|
FILE
|
@@ -94,13 +93,14 @@ FILE
|
|
94
93
|
|
95
94
|
def parameters_table(parameters)
|
96
95
|
@file.write <<FILE
|
97
|
-
| Name | Type | Required? | Value |
|
98
|
-
|
96
|
+
| Name | Type | Required? | Value | |
|
97
|
+
|------|------|-----------|-------|---|
|
99
98
|
FILE
|
100
99
|
|
101
100
|
parameters.sort.each do |name, parameter|
|
102
101
|
@file.puts "| #{name} | #{parameter.type} | #{"Required" if parameter.required} | #{parameter.value} | #{parameter.message} |"
|
103
102
|
end
|
103
|
+
@file.puts
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|