reqres_rspec 0.0.20 → 0.0.21

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: 01c69919cded3fc726e8b5f548c0b46788a2fcaa
4
- data.tar.gz: 6b70f035c8406224f4ba64fcd041e5f1996b269b
3
+ metadata.gz: 85c05723ee091bb7320037e073ab67109ca2e22f
4
+ data.tar.gz: ae6d4ebfedfb2d5a5933d2ffb146b61959d9b103
5
5
  SHA512:
6
- metadata.gz: 68b3d8736b6376b5e31982fa011e36ce023023ad6f00809bddeeb40408df4a670183992115bdb5c714a28ee5d81121eafd1200e4305c63450c387e2b04698ac7
7
- data.tar.gz: a359888d091f877c69e8bee6f39c78d86fba3faa08911b32c7bc6f8f547d91317b6d000f7db4002edca3e9e849a850287e0a98a57832824b0fa1a1ac790c1a75
6
+ metadata.gz: 131b3a90632fcf9eba91c05b065d6054d165c1a2884434924516b309a5e52def7f9ca5b1a78303254a1f4259dcb2c40c0c81f28e96938aba511746d98078402a
7
+ data.tar.gz: 6edca5c0fbb7cba3ae34065258f2ee70882ac76f8b5da96b8ff04f153d8af7062a06a69000a863b0f92b73afc000dcfad009edcd64a0b2f67fd971876add7750
data/README.md CHANGED
@@ -62,19 +62,20 @@ Each param text is started with `@param` and first word will be param name, then
62
62
  ### Sample rspec test
63
63
 
64
64
  ```ruby
65
- describe 'Create' do
66
- it 'creates category' do
67
- post :create, category: { name: 'Cookies' }
65
+ context 'With valid params' do
66
+ it 'bakes pie' do
68
67
  ...
69
68
  end
69
+ end
70
70
 
71
- it 'some other example', :skip_reqres do
71
+ context 'With invalid params', :skip_reqres do
72
+ it 'returns errors' do
72
73
  ...
73
74
  end
74
75
  end
75
76
  ```
76
77
 
77
- By default all examples will be added to docs. Example may be excluded from docs with option `:skip_reqres`
78
+ By default all examples will be added to docs. A context of examples (`context` and `describe` blocks)may be excluded from docs with option `:skip_reqres`
78
79
 
79
80
  Doc will use full example description, as a title for each separate spec
80
81
 
@@ -3,6 +3,12 @@ module ReqresRspec
3
3
  # Contains spec values read from rspec example, request and response
4
4
  attr_accessor :records
5
5
 
6
+ # param importances
7
+ PARAM_IMPORTANCES = %w[required optional]
8
+
9
+ # param types
10
+ PARAM_TYPES = %w[Integer Boolean String Text Float Date DateTime File Array]
11
+
6
12
  # response headers contain many unnecessary information,
7
13
  # everything from this list will be stripped
8
14
  EXCLUDE_RESPONSE_HEADER_PATTERNS = %w[
@@ -212,7 +218,6 @@ module ReqresRspec
212
218
  comments_raw << ''
213
219
  end
214
220
  if has_param
215
- #text_params.last << "\n"
216
221
  line = line.gsub(/\A\s*#\s*@param/, '')
217
222
  line = line.gsub(/\A\s*#\s*/, '').strip
218
223
 
@@ -223,7 +228,7 @@ module ReqresRspec
223
228
 
224
229
  comments = []
225
230
  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
231
+ match_data = comment.match /(?<name>[a-z0-9A-Z_\[\]]+)?\s*(?<required>#{PARAM_IMPORTANCES.join('|')})?\s*(?<type>#{PARAM_TYPES.join('|')})?\s*(?<description>.*)/m
227
232
 
228
233
  if match_data
229
234
  comments << {
@@ -1,3 +1,3 @@
1
1
  module ReqresRspec
2
- VERSION = '0.0.20'
2
+ VERSION = '0.0.21'
3
3
  end
@@ -171,7 +171,13 @@
171
171
  </tr>
172
172
  <% @record[:params].each do |param| %>
173
173
  <tr>
174
- <td><%= param[:name] %> <i class="required"><%= param[:required] %></i></td>
174
+ <td>
175
+ <%= param[:name] %>
176
+ <% if param[:required].present? %>
177
+ <br/>
178
+ <i class="required"><%= param[:required] %></i>
179
+ <% end %>
180
+ </td>
175
181
  <td><%= param[:type] %></td>
176
182
  <td><%= param[:description].gsub("\n", '<br>'.html_safe) %></td>
177
183
  </tr>
data/lib/reqres_rspec.rb CHANGED
@@ -11,9 +11,9 @@ if defined?(RSpec) && ENV['REQRES_RSPEC'] == '1'
11
11
  # TODO: remove boilerplate code
12
12
  # TODO: better options
13
13
  meta_data = self.class.example.metadata
14
- if meta_data[:type] == :request
14
+ if meta_data[:type] == :request && !meta_data[:skip_reqres] == true
15
15
  begin
16
- collector.collect(self, self.request, self.response) unless meta_data[:skip_reqres] == true
16
+ collector.collect(self, self.request, self.response)
17
17
  rescue NameError
18
18
  raise $!
19
19
  end
@@ -28,6 +28,4 @@ if defined?(RSpec) && ENV['REQRES_RSPEC'] == '1'
28
28
  end
29
29
  end
30
30
  end
31
- else
32
- puts "\nNOTICE: ReqresRspec is disabled. run `REQRES_RSPEC=1 bundle exec rspec --order=defined`\n"
33
31
  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.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - rilian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-01 00:00:00.000000000 Z
11
+ date: 2014-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderay