reqres_rspec 0.1.3 → 0.1.4

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: 5cb8e704a9372b9368d83a6093c9d9f802168a57
4
- data.tar.gz: 638db754921305a9460e84f7a02507478c5f4654
3
+ metadata.gz: af1fa8a421fe25c73ee8379ca80b33acab8ff382
4
+ data.tar.gz: 3e0618b1ed96673dd43ee51e0b3134e78742a60f
5
5
  SHA512:
6
- metadata.gz: bbd5064b18e130250a53d46ee21a08683d3e27fb3895c7cd3b532ec57c706e12732ff05fe7fbd8797ff311aa22fb293febb2ebce9f2d3e7da97c22c3f5b16b10
7
- data.tar.gz: 20e83cc5274f7279858e637ce2fd1e14d70a481eab18eca72baceaf64dab707887d327c27d834784d23880983d6c2d49864188d279746561ffd78eecc20c2a16
6
+ metadata.gz: 658df28bd196eedfec20e21a2ce442c28c5ba913c9fc109d8ec4324ad50cc6dea342135faeb2ac27d8ce095eda2cb11b25f6a043a17d193aaf5f8b05d0f9b8b1
7
+ data.tar.gz: 300c2f6fb90105b4907ad2bdf7e11b48fde67d8b58db1f5df29d7ecfec974cef5399afad19e762aa86e67a329e648d35591d41c3256d00254ecedbaad72f7aa6
@@ -69,8 +69,8 @@ module ReqresRspec
69
69
  if request_params['controller'] && request_params['action']
70
70
  description = get_action_description(request_params['controller'], request_params['action'])
71
71
  params = get_action_params(request_params['controller'], request_params['action'])
72
- query_parameters = request_params.reject { |p| %w[controller action].include? p }
73
- backend_parameters = request_params.reject { |p| !%w[controller action].include? p }
72
+ query_parameters = request_params.reject { |p| %w[controller action format].include? p }
73
+ backend_parameters = request_params.reject { |p| !%w[controller action format].include? p }
74
74
  end
75
75
  end
76
76
 
@@ -107,6 +107,15 @@ module ReqresRspec
107
107
  headers: read_response_headers(response)
108
108
  }
109
109
  }
110
+
111
+ # cleanup query params
112
+ begin
113
+ body_hash = JSON.parse(self.records.last[:request][:body])
114
+ query_hash = self.records.last[:request][:query_parameters]
115
+ diff = Hash[*((query_hash.size > body_hash.size) ? query_hash.to_a - body_hash.to_a : body_hash.to_a - query_hash.to_a).flatten]
116
+ self.records.last[:request][:query_parameters] = diff
117
+ rescue
118
+ end
110
119
  end
111
120
 
112
121
  def prepare_filename_for(metadata)
@@ -185,7 +194,7 @@ module ReqresRspec
185
194
 
186
195
  action_line = nil
187
196
  lines.each_with_index do |line, index|
188
- if line.match /\s*def #{action}/ # def show
197
+ if line.match(/\s*def #{action}/) # def show
189
198
  action_line = index
190
199
  break
191
200
  end
@@ -197,7 +206,7 @@ module ReqresRspec
197
206
  while action_line > 0 && was_comment
198
207
  action_line -= 1
199
208
 
200
- if lines[action_line].match /\s*#/
209
+ if lines[action_line].match(/\s*#/)
201
210
  comment_lines << lines[action_line].strip
202
211
  else
203
212
  was_comment = false
@@ -219,10 +228,10 @@ module ReqresRspec
219
228
 
220
229
  description = []
221
230
  comment_lines.each_with_index do |line, index|
222
- if line.match /\s*#\s*@description/ # @description blah blah
231
+ if line.match(/\s*#\s*@description/) # @description blah blah
223
232
  description << line.gsub(/\A\s*#\s*@description/, '').strip
224
233
  comment_lines[(index + 1)..-1].each do |multiline|
225
- if !multiline.match /\s*#\s*@param/
234
+ if !multiline.match(/\s*#\s*@param/)
226
235
  description << "\n"
227
236
  description << multiline.gsub(/\A\s*#\s*/, '').strip
228
237
  else
@@ -243,7 +252,7 @@ module ReqresRspec
243
252
  comments_raw = []
244
253
  has_param = false
245
254
  comment_lines.each do |line|
246
- if line.match /\s*#\s*@param/ # @param id required Integer blah blah
255
+ if line.match(/\s*#\s*@param/) # @param id required Integer blah blah
247
256
  has_param = true
248
257
  comments_raw << ''
249
258
  end
@@ -258,7 +267,7 @@ module ReqresRspec
258
267
 
259
268
  comments = []
260
269
  comments_raw.each do |comment|
261
- match_data = comment.match /(?<name>[a-z0-9A-Z_\[\]]+)?\s*(?<required>#{PARAM_IMPORTANCES.join('|')})?\s*(?<type>#{PARAM_TYPES.join('|')})?\s*(?<description>.*)/m
270
+ match_data = comment.match(/(?<name>[a-z0-9A-Z_\[\]]+)?\s*(?<required>#{PARAM_IMPORTANCES.join('|')})?\s*(?<type>#{PARAM_TYPES.join('|')})?\s*(?<description>.*)/m)
262
271
 
263
272
  if match_data
264
273
  comments << {
@@ -197,10 +197,17 @@
197
197
  <code><%= @record[:request][:method] %> <%= @record[:request][:path] %></code>
198
198
 
199
199
  <h5>Query parameters</h5>
200
- <code><%= @record[:request][:query_parameters] if @record[:request][:method] == 'GET' %></code>
200
+ <% if @record[:request][:query_parameters].empty? %>
201
+ <code>empty</code>
202
+ <% else %>
203
+ <% lines = ::JSON.pretty_generate(@record[:request][:query_parameters]) %>
204
+ <code>
205
+ <%= CodeRay.scan(lines, :json).div(line_numbers: :table) %>
206
+ </code>
207
+ <% end %>
201
208
 
202
- <h5><a href="http://curl.haxx.se/docs/manpage.html">CURL</a> Example</h5>
203
- <code>TODO</code>
209
+ <!--<h5><a href="http://curl.haxx.se/docs/manpage.html">CURL</a> Example</h5>
210
+ <code>TODO</code>-->
204
211
 
205
212
  <h5>Body</h5>
206
213
  <% if @record[:request][:body].present? %>
@@ -1,3 +1,3 @@
1
1
  module ReqresRspec
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
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.1.3
4
+ version: 0.1.4
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-18 00:00:00.000000000 Z
11
+ date: 2014-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderay