rspec_generate_doc 0.2.4 → 0.2.5

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: 9c78c2b5388bf0e0fbd7a4375d0e025c88416f5f
4
- data.tar.gz: 918962276786293057bd1ce6d10d3742a30181d1
3
+ metadata.gz: 0c49369c2b7339e0f05b9715b4310cbe5981f542
4
+ data.tar.gz: a2513fc805ea6ce5cb8528bfbf0575094e7c326f
5
5
  SHA512:
6
- metadata.gz: 92e709b48ba9296ebfdd12540f1d66776d183350d09f5fc68e4e5866e5ff5536cce673be513106fad83197c529a7da204f321efc2897a1ea0edf8f3b84f9f5a8
7
- data.tar.gz: 7b202a2a9ac5c58feac09c0f87b57a002941c8abc11c9b4ebdaac2b260c53ce6c039be6c34325cbbef593ebd7955d1648b3ee30e2da560c25f237f848538942b
6
+ metadata.gz: db03b1d90c4f16d56fe690f0a9c9ca61a348a3204014e00002a7a72bd69b8515f2bc7cd160d3abfb87cd2487e087a4c4f4ac0efed7db680e31dffb923529ece3
7
+ data.tar.gz: 73fd24165e5a3856cd203729c68b5f07b04f30878cd9c31af33d6877f100b9a52f20d17fdde9f40c75526b21bb74423ab9393e11d3282ef3647c3154bc369e96
data/README.md CHANGED
@@ -43,16 +43,17 @@ Example use
43
43
  ...
44
44
  let(:api_params) do
45
45
  {
46
- id: { description: 'user id', required: true },
47
- email: { description: 'user email', required: false }
46
+ id: { name: 'alternative id name', description: 'user id', required: true },
47
+ email: { description: 'user email', required: 'if not id' }
48
48
  }
49
49
  end
50
50
  ...
51
51
  ```
52
52
  *keys description:*
53
- id | email - parameter in result
54
- description - description parameter. Default parent key name
55
- required - is parameter required? Default false
53
+ id | email - Parameter name.
54
+ name - Parameter name. Default parameter key name.
55
+ description - description parameter. Default parameter key name.
56
+ required - is parameter required? If the value type is boolean it will be translated to default language. If the value type is string then return it value.
56
57
 
57
58
  *skip add to api description*
58
59
 
@@ -65,6 +66,14 @@ context 'this case will be skipped' do
65
66
  end
66
67
  ...
67
68
  ```
69
+
70
+ *alternative name to file and menu*
71
+ ``` ruby
72
+ require 'rails_helper'
73
+
74
+ RSpec.describe UserController, type: :controller, api_name: 'alternative_name' do
75
+ ...
76
+ ```
68
77
  **result**
69
78
 
70
79
  After tests completed file *_user_controller.md* will be created in docs folder. In format to Slate
@@ -3,5 +3,5 @@ en:
3
3
  parameter: Parameter
4
4
  required: Required
5
5
  description: Description
6
- required_yes: Yes
7
- required_no: No
6
+ required_yes: 'Yes'
7
+ required_no: 'No'
@@ -8,7 +8,7 @@ module RspecGenerateDoc
8
8
  @name = (data[:name] || '').split('#').join(' ')
9
9
  @response = data[:response]
10
10
  @params = to_params(data[:api_params])
11
- @options = OpenStruct.new(data[:opntions] || {})
11
+ @options = OpenStruct.new(data[:options] || {})
12
12
  end
13
13
 
14
14
  def request_method
@@ -5,13 +5,14 @@ module RspecGenerateDoc
5
5
 
6
6
  def initialize(data = {})
7
7
  @name = data[:name] || data['name']
8
- @required = data[:required] || data['required'] || false
8
+ @required = data[:required] || data['required']
9
9
  @description = data[:description] || data['description'] || name || ''
10
10
  @options = OpenStruct.new(data[:options] || data['options'] || {})
11
11
  end
12
12
 
13
13
  def required_human
14
- description ? I18n.t(:required_yes, scope: :rspec_api_docs) : I18n.t(:required_no, scope: :rspec_api_docs)
14
+ return required unless !!required == required
15
+ required ? I18n.t(:required_yes, scope: :rspec_api_docs) : I18n.t(:required_no, scope: :rspec_api_docs)
15
16
  end
16
17
  end
17
18
  end
@@ -19,7 +19,8 @@ module RspecGenerateDoc
19
19
 
20
20
  def create_file_by_template
21
21
  file = File.open(file_path, 'w+')
22
- file.write ERB.new(File.binread(configuration.template_file), nil, '-').result(binding).to_s.force_encoding('utf-8')
22
+ file.write ERB.new(File.binread(configuration.template_file), nil, '-').result(binding).to_s
23
+ .force_encoding('utf-8')
23
24
  file.close
24
25
  end
25
26
 
@@ -30,7 +31,7 @@ module RspecGenerateDoc
30
31
  end
31
32
 
32
33
  def parent_name
33
- @parent_name ||= parent.downcase.split('::').join('_')
34
+ @parent_name ||= parent.split('::').join('_').underscore
34
35
  end
35
36
 
36
37
  def template_name
@@ -32,7 +32,7 @@ module RspecGenerateDoc
32
32
 
33
33
  config.after(:context) do
34
34
  next if @is_incorrect_type
35
- parent = try(:parent_name) || @parent_name || self.class.top_level_description
35
+ parent = self.class.metadata[:api_name].to_s || self.class.top_level_description
36
36
  RspecGenerateDoc::GenarateFIle.new(parent: parent, actions: @actions).create_file_by_template
37
37
  end
38
38
  end
@@ -7,7 +7,8 @@
7
7
  <%= action.request_method %> <%= action.request_fullpath %> HTTP/1.1
8
8
  Host: <%= action.host %>
9
9
  User-Agent: ExampleClient/1.0.0
10
- ``
10
+ ```
11
+
11
12
  ```http
12
13
  HTTP/1.1 <%= action.status %> <%= action.status_message %>
13
14
  <% if action.content_type? -%>
@@ -15,8 +16,11 @@ Content-Type: <%= action.content_type %>
15
16
  <% end -%>
16
17
  <%= action.body %>
17
18
  ```
19
+
20
+ <% if action.params.any? -%>
18
21
  <%= I18n.t(:parameter, scope: :rspec_api_docs) %> | <%= I18n.t(:required, scope: :rspec_api_docs) %> | <%= I18n.t(:description, scope: :rspec_api_docs) %>
19
22
  -------- | ------- | -------
23
+ <% end -%>
20
24
  <% action.params.each do |parametr| -%>
21
25
  <%= parametr.name %> | <%= parametr.required_human %> | <%= parametr.description %>
22
26
  <% end -%>
@@ -1,3 +1,3 @@
1
1
  module RspecGenerateDoc
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_generate_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kutyavin