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 +4 -4
- data/README.md +14 -5
- data/config/locales/en.yml +2 -2
- data/lib/rspec_generate_doc/decorators/action.rb +1 -1
- data/lib/rspec_generate_doc/decorators/parameter.rb +3 -2
- data/lib/rspec_generate_doc/generate_file.rb +3 -2
- data/lib/rspec_generate_doc/library_hooks/doc.rb +1 -1
- data/lib/rspec_generate_doc/templates/slate.md.erb +5 -1
- data/lib/rspec_generate_doc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c49369c2b7339e0f05b9715b4310cbe5981f542
|
4
|
+
data.tar.gz: a2513fc805ea6ce5cb8528bfbf0575094e7c326f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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 -
|
54
|
-
|
55
|
-
|
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
|
data/config/locales/en.yml
CHANGED
@@ -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[:
|
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']
|
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
|
-
|
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
|
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.
|
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 =
|
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 -%>
|