reqres_rspec 0.0.19 → 0.0.20
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 +4 -4
- data/lib/reqres_rspec/collector.rb +18 -14
- data/lib/reqres_rspec/version.rb +1 -1
- data/lib/reqres_rspec/writers/templates/spec.erb +19 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c69919cded3fc726e8b5f548c0b46788a2fcaa
|
4
|
+
data.tar.gz: 6b70f035c8406224f4ba64fcd041e5f1996b269b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b3d8736b6376b5e31982fa011e36ce023023ad6f00809bddeeb40408df4a670183992115bdb5c714a28ee5d81121eafd1200e4305c63450c387e2b04698ac7
|
7
|
+
data.tar.gz: a359888d091f877c69e8bee6f39c78d86fba3faa08911b32c7bc6f8f547d91317b6d000f7db4002edca3e9e849a850287e0a98a57832824b0fa1a1ac790c1a75
|
@@ -34,6 +34,7 @@ module ReqresRspec
|
|
34
34
|
ORIGINAL_SCRIPT_NAME
|
35
35
|
HTTP_COOKIE
|
36
36
|
HTTP_ORIGIN
|
37
|
+
RAW_POST_DATA
|
37
38
|
]
|
38
39
|
|
39
40
|
def initialize
|
@@ -80,12 +81,12 @@ module ReqresRspec
|
|
80
81
|
content_length: request.content_length,
|
81
82
|
content_type: request.content_type,
|
82
83
|
headers: read_request_headers(request),
|
83
|
-
accept: request.accept
|
84
|
+
accept: request.accept
|
84
85
|
},
|
85
86
|
response: {
|
86
87
|
code: response.status,
|
87
88
|
body: response.body,
|
88
|
-
headers: read_response_headers(response)
|
89
|
+
headers: read_response_headers(response)
|
89
90
|
}
|
90
91
|
}
|
91
92
|
end
|
@@ -186,6 +187,7 @@ module ReqresRspec
|
|
186
187
|
description << line.gsub(/\A\s*#\s*@description/, '').strip
|
187
188
|
comment_lines[(index + 1)..-1].each do |multiline|
|
188
189
|
if !multiline.match /\s*#\s*@param/
|
190
|
+
description << "\n"
|
189
191
|
description << multiline.gsub(/\A\s*#\s*/, '').strip
|
190
192
|
else
|
191
193
|
break
|
@@ -202,38 +204,40 @@ module ReqresRspec
|
|
202
204
|
def get_action_params(controller, action)
|
203
205
|
comment_lines = get_action_comments(controller, action)
|
204
206
|
|
205
|
-
|
207
|
+
comments_raw = []
|
206
208
|
has_param = false
|
207
209
|
comment_lines.each do |line|
|
208
210
|
if line.match /\s*#\s*@param/ # @param id required Integer blah blah
|
209
211
|
has_param = true
|
210
|
-
|
212
|
+
comments_raw << ''
|
211
213
|
end
|
212
214
|
if has_param
|
213
|
-
|
215
|
+
#text_params.last << "\n"
|
216
|
+
line = line.gsub(/\A\s*#\s*@param/, '')
|
214
217
|
line = line.gsub(/\A\s*#\s*/, '').strip
|
215
|
-
|
218
|
+
|
219
|
+
comments_raw.last << "\n" unless comments_raw.last.blank?
|
220
|
+
comments_raw.last << line
|
216
221
|
end
|
217
222
|
end
|
218
223
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
match_data = param.match /(?<name>[a-z0-9A-Z_\[\]]+)?\s*(?<required>required)?\s*(?<type>Integer|Boolean|String|Text|Float|Date|DateTime|File)?\s*(?<description>.*)/
|
224
|
+
comments = []
|
225
|
+
comments_raw.each do |comment|
|
226
|
+
match_data = comment.match /(?<name>[a-z0-9A-Z_\[\]]+)?\s*(?<required>required|optional)?\s*(?<type>Integer|Boolean|String|Text|Float|Date|DateTime|File|Array)?\s*(?<description>.*)/m
|
223
227
|
|
224
228
|
if match_data
|
225
|
-
|
229
|
+
comments << {
|
226
230
|
name: match_data[:name],
|
227
231
|
required: match_data[:required],
|
228
232
|
type: match_data[:type],
|
229
|
-
description: match_data[:description]
|
233
|
+
description: match_data[:description]
|
230
234
|
}
|
231
235
|
else
|
232
|
-
|
236
|
+
comments << { description: comment }
|
233
237
|
end
|
234
238
|
end
|
235
239
|
|
236
|
-
|
240
|
+
comments
|
237
241
|
end
|
238
242
|
end
|
239
243
|
end
|
data/lib/reqres_rspec/version.rb
CHANGED
@@ -154,7 +154,9 @@
|
|
154
154
|
<a id="<%= @index %>"></a><%= @index %>. <%= @record[:title] %>
|
155
155
|
</h3>
|
156
156
|
|
157
|
-
<p
|
157
|
+
<p>
|
158
|
+
<%= @record[:description].gsub("\n", '<br>'.html_safe) %>
|
159
|
+
</p>
|
158
160
|
|
159
161
|
<code><%= @record[:request][:method] %> <%= @record[:request_path] %></code>
|
160
162
|
|
@@ -171,7 +173,7 @@
|
|
171
173
|
<tr>
|
172
174
|
<td><%= param[:name] %> <i class="required"><%= param[:required] %></i></td>
|
173
175
|
<td><%= param[:type] %></td>
|
174
|
-
<td><%= param[:description] %></td>
|
176
|
+
<td><%= param[:description].gsub("\n", '<br>'.html_safe) %></td>
|
175
177
|
</tr>
|
176
178
|
<% end %>
|
177
179
|
</table>
|
@@ -194,13 +196,22 @@
|
|
194
196
|
<h5><a href="http://curl.haxx.se/docs/manpage.html">CURL</a> Example</h5>
|
195
197
|
<code>TODO</code>
|
196
198
|
|
199
|
+
<h5>Body</h5>
|
197
200
|
<% if @record[:request][:body].present? %>
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
201
|
+
<% lines = begin
|
202
|
+
JSON.pretty_generate(
|
203
|
+
JSON.parse(
|
204
|
+
@record[:request][:body]
|
205
|
+
)
|
206
|
+
)
|
207
|
+
rescue
|
208
|
+
@record[:request][:body]
|
209
|
+
end %>
|
210
|
+
<code>
|
211
|
+
<%= CodeRay.scan(lines, :json).div(line_numbers: :table) %>
|
212
|
+
</code>
|
213
|
+
<% else %>
|
214
|
+
<code>empty</code>
|
204
215
|
<% end %>
|
205
216
|
|
206
217
|
<h4>Response</h4>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reqres_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rilian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coderay
|