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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ae933f710a7d0f2d94ede0720c9a23cdfc03fc8
4
- data.tar.gz: 5642b23a4cdb3b15dfb684a56efd01b93f9c1e73
3
+ metadata.gz: 01c69919cded3fc726e8b5f548c0b46788a2fcaa
4
+ data.tar.gz: 6b70f035c8406224f4ba64fcd041e5f1996b269b
5
5
  SHA512:
6
- metadata.gz: dc223b883e456fcb6d1a195df35920b8003f00517c0934d37c12553c6880c16a755b61868e2b5d3b28e312ce3a6321098091bd620023c14ead2f5cd62a314ec2
7
- data.tar.gz: b30f31e8fc315f6b96cf335a731c5ee096629d3c9ac315dd25d75338a5377b9b7374f2956c6ac8f5bf2e503bb1eab8cd3570c57c4e71bd3fd37a80fe7300b762
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
- text_params = []
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
- text_params << ''
212
+ comments_raw << ''
211
213
  end
212
214
  if has_param
213
- line = line.gsub(/\A\s*#\s*@param/, '').strip
215
+ #text_params.last << "\n"
216
+ line = line.gsub(/\A\s*#\s*@param/, '')
214
217
  line = line.gsub(/\A\s*#\s*/, '').strip
215
- text_params.last << line
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
- params = []
220
-
221
- text_params.each do |param|
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
- params << {
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
- params << { description: param }
236
+ comments << { description: comment }
233
237
  end
234
238
  end
235
239
 
236
- params
240
+ comments
237
241
  end
238
242
  end
239
243
  end
@@ -1,3 +1,3 @@
1
1
  module ReqresRspec
2
- VERSION = '0.0.19'
2
+ VERSION = '0.0.20'
3
3
  end
@@ -154,7 +154,9 @@
154
154
  <a id="<%= @index %>"></a><%= @index %>. <%= @record[:title] %>
155
155
  </h3>
156
156
 
157
- <p><%= @record[:description] %></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
- <h5>Body</h5>
199
- <ol>
200
- <% @record[:request][:body].split("\n").each do |line| %>
201
- <li style="word-break:&;"><%= line %></li>
202
- <% end %>
203
- </ol>
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.19
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-07-31 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderay