puppet-strings 2.4.0 → 2.5.0
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/CHANGELOG.md +30 -2
- data/lib/puppet-strings.rb +2 -2
- data/lib/puppet-strings/markdown.rb +1 -1
- data/lib/puppet-strings/markdown/base.rb +6 -0
- data/lib/puppet-strings/markdown/data_type.rb +16 -0
- data/lib/puppet-strings/markdown/resource_type.rb +19 -2
- data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +4 -4
- data/lib/puppet-strings/markdown/templates/data_type.erb +11 -4
- data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
- data/lib/puppet-strings/markdown/templates/function.erb +2 -1
- data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
- data/lib/puppet-strings/markdown/templates/resource_type.erb +12 -12
- data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
- data/lib/puppet-strings/version.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/data_type.rb +26 -6
- data/lib/puppet-strings/yard/code_objects/type.rb +46 -5
- data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +190 -43
- data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +6 -0
- data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +1 -1
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +9 -1
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +3 -1
- metadata +4 -46
- data/CODEOWNERS +0 -1
- data/Gemfile +0 -53
- data/HISTORY.md +0 -218
- data/JSON.md +0 -832
- data/Rakefile +0 -160
- data/codecov.yml +0 -3
- data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
- data/spec/acceptance/emit_json_options_spec.rb +0 -69
- data/spec/acceptance/generate_markdown_spec.rb +0 -47
- data/spec/acceptance/running_strings_generate_spec.rb +0 -88
- data/spec/fixtures/acceptance/modules/test/functions/add.pp +0 -9
- data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +0 -5
- data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +0 -2
- data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +0 -9
- data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +0 -15
- data/spec/fixtures/acceptance/modules/test/manifests/init.pp +0 -31
- data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +0 -27
- data/spec/fixtures/acceptance/modules/test/metadata.json +0 -10
- data/spec/fixtures/acceptance/modules/test/types/elephant.pp +0 -2
- data/spec/fixtures/unit/markdown/output.md +0 -561
- data/spec/fixtures/unit/markdown/output_with_data_types.md +0 -606
- data/spec/fixtures/unit/markdown/output_with_plan.md +0 -595
- data/spec/spec_helper.rb +0 -49
- data/spec/spec_helper_acceptance.rb +0 -58
- data/spec/spec_helper_acceptance_local.rb +0 -10
- data/spec/unit/puppet-strings/describe_spec.rb +0 -141
- data/spec/unit/puppet-strings/json_spec.rb +0 -302
- data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
- data/spec/unit/puppet-strings/markdown_spec.rb +0 -374
- data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +0 -92
- data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +0 -116
- data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
- data/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +0 -65
- data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +0 -231
- data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +0 -315
- data/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +0 -309
- data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -746
- data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -158
- data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -235
- data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -311
- data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -72
- data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +0 -56
- data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +0 -251
- data/spec/unit/puppet-strings/yard/util_spec.rb +0 -48
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'puppet-strings/yard'
|
3
|
-
|
4
|
-
describe PuppetStrings::Yard::Parsers::JSON::Parser do
|
5
|
-
subject { PuppetStrings::Yard::Parsers::JSON::Parser.new(source, file) }
|
6
|
-
let(:file) { 'test.json' }
|
7
|
-
|
8
|
-
describe 'initialization of the parser' do
|
9
|
-
let(:source) { '{}' }
|
10
|
-
|
11
|
-
it 'should store the original source' do
|
12
|
-
expect(subject.source).to eq(source)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should store the original file name' do
|
16
|
-
expect(subject.file).to eq(file)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should have no relevant statements' do
|
20
|
-
subject.parse
|
21
|
-
|
22
|
-
expect(subject.enumerator.empty?).to be_truthy
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'parsing invalid JSON' do
|
27
|
-
let(:source) { <<SOURCE
|
28
|
-
class foo {
|
29
|
-
SOURCE
|
30
|
-
}
|
31
|
-
|
32
|
-
it 'should raise an exception' do
|
33
|
-
expect{ subject.parse }.to output(/\[error\]: Failed to parse test.json/).to_stdout_from_any_process
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
describe 'parsing valid task metadata JSON' do
|
39
|
-
let(:source) { <<SOURCE
|
40
|
-
{
|
41
|
-
"description": "Allows you to backup your database to local file.",
|
42
|
-
"input_method": "stdin",
|
43
|
-
"parameters": {
|
44
|
-
"database": {
|
45
|
-
"description": "Database to connect to",
|
46
|
-
"type": "Optional[String[1]]"
|
47
|
-
},
|
48
|
-
"user": {
|
49
|
-
"description": "The user",
|
50
|
-
"type": "Optional[String[1]]"
|
51
|
-
},
|
52
|
-
"password": {
|
53
|
-
"description": "The password",
|
54
|
-
"type": "Optional[String[1]]"
|
55
|
-
},
|
56
|
-
"sql": {
|
57
|
-
"description": "Path to file you want backup to",
|
58
|
-
"type": "String[1]"
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
SOURCE
|
63
|
-
}
|
64
|
-
it 'should parse the JSON and extract a TaskStatement' do
|
65
|
-
subject.parse
|
66
|
-
|
67
|
-
expect(subject.enumerator.size).to eq(1)
|
68
|
-
statement = subject.enumerator.first
|
69
|
-
expect(statement).to be_instance_of(PuppetStrings::Yard::Parsers::JSON::TaskStatement)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PuppetStrings::Yard::Parsers::JSON::TaskStatement do
|
4
|
-
let(:source) { <<-SOURCE
|
5
|
-
{
|
6
|
-
"description": "Allows you to backup your database to local file.",
|
7
|
-
"input_method": "stdin",
|
8
|
-
"parameters": {
|
9
|
-
"database": {
|
10
|
-
"description": "Database to connect to",
|
11
|
-
"type": "Optional[String[1]]"
|
12
|
-
},
|
13
|
-
"user": {
|
14
|
-
"description": "The user",
|
15
|
-
"type": "Optional[String[1]]"
|
16
|
-
},
|
17
|
-
"password": {
|
18
|
-
"description": "The password",
|
19
|
-
"type": "Optional[String[1]]"
|
20
|
-
},
|
21
|
-
"sql": {
|
22
|
-
"description": "Path to file you want backup to",
|
23
|
-
"type": "String[1]"
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
SOURCE
|
28
|
-
}
|
29
|
-
let(:json) { JSON.parse(source) }
|
30
|
-
subject { PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, source, "test.json") }
|
31
|
-
describe '#comments' do
|
32
|
-
it 'returns docstring' do
|
33
|
-
expect(subject.comments).to eq "Allows you to backup your database to local file."
|
34
|
-
end
|
35
|
-
end
|
36
|
-
describe '#parameters' do
|
37
|
-
context 'with params' do
|
38
|
-
it 'returns params' do
|
39
|
-
expect(subject.parameters.size > 0).to be true
|
40
|
-
end
|
41
|
-
end
|
42
|
-
context 'no params' do
|
43
|
-
let(:source) { <<-SOURCE
|
44
|
-
{
|
45
|
-
"description": "Allows you to backup your database to local file.",
|
46
|
-
"input_method": "stdin"
|
47
|
-
}
|
48
|
-
SOURCE
|
49
|
-
}
|
50
|
-
it 'returns an empty hash' do
|
51
|
-
expect(subject.parameters).to eq({})
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,251 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'puppet-strings/yard'
|
3
|
-
|
4
|
-
describe PuppetStrings::Yard::Parsers::Puppet::Parser do
|
5
|
-
subject { PuppetStrings::Yard::Parsers::Puppet::Parser.new(source, file) }
|
6
|
-
let(:file) { 'test.pp' }
|
7
|
-
|
8
|
-
describe 'initialization of the parser' do
|
9
|
-
let(:source) { 'notice hi' }
|
10
|
-
|
11
|
-
it 'should store the original source' do
|
12
|
-
expect(subject.source).to eq(source)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should store the original file name' do
|
16
|
-
expect(subject.file).to eq(file)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should have no relevant statements' do
|
20
|
-
subject.parse
|
21
|
-
expect(subject.enumerator.empty?).to be_truthy
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'parsing invalid Puppet source code' do
|
26
|
-
let(:source) { <<SOURCE
|
27
|
-
class foo {
|
28
|
-
SOURCE
|
29
|
-
}
|
30
|
-
|
31
|
-
it 'should raise an exception' do
|
32
|
-
expect{ subject.parse }.to output(/\[error\]: Failed to parse test.pp: Syntax error at end of (file|input)/).to_stdout_from_any_process
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'parsing class definitions' do
|
37
|
-
let(:source) { <<SOURCE
|
38
|
-
notice hello
|
39
|
-
# A simple foo class.
|
40
|
-
# @param param1 First param.
|
41
|
-
# @param param2 Second param.
|
42
|
-
# @param param3 Third param.
|
43
|
-
class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
|
44
|
-
file { '/tmp/foo':
|
45
|
-
ensure => present
|
46
|
-
}
|
47
|
-
}
|
48
|
-
SOURCE
|
49
|
-
}
|
50
|
-
|
51
|
-
it 'should only return the class statement' do
|
52
|
-
subject.parse
|
53
|
-
expect(subject.enumerator.size).to eq(1)
|
54
|
-
statement = subject.enumerator.first
|
55
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::ClassStatement)
|
56
|
-
expect(statement.source).to eq("class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {\n file { '/tmp/foo':\n ensure => present\n }\n}")
|
57
|
-
expect(statement.file).to eq(file)
|
58
|
-
expect(statement.line).to eq(6)
|
59
|
-
expect(statement.docstring).to eq('A simple foo class.')
|
60
|
-
expect(statement.name).to eq('foo')
|
61
|
-
expect(statement.parent_class).to eq('foo::bar')
|
62
|
-
expect(statement.parameters.size).to eq(3)
|
63
|
-
expect(statement.parameters[0].name).to eq('param1')
|
64
|
-
expect(statement.parameters[0].type).to eq('Integer')
|
65
|
-
expect(statement.parameters[0].value).to be_nil
|
66
|
-
expect(statement.parameters[1].name).to eq('param2')
|
67
|
-
expect(statement.parameters[1].type).to be_nil
|
68
|
-
expect(statement.parameters[1].value).to be_nil
|
69
|
-
expect(statement.parameters[2].name).to eq('param3')
|
70
|
-
expect(statement.parameters[2].type).to eq('String')
|
71
|
-
expect(statement.parameters[2].value).to eq('hi')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe 'parsing nested class definitions' do
|
76
|
-
let(:source) { <<SOURCE
|
77
|
-
class foo {
|
78
|
-
class bar {
|
79
|
-
}
|
80
|
-
}
|
81
|
-
SOURCE
|
82
|
-
}
|
83
|
-
|
84
|
-
it 'should parse both class statements' do
|
85
|
-
subject.parse
|
86
|
-
expect(subject.enumerator.size).to eq(2)
|
87
|
-
statement = subject.enumerator[0]
|
88
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::ClassStatement)
|
89
|
-
expect(statement.name).to eq('foo::bar')
|
90
|
-
expect(statement.parameters.size).to eq(0)
|
91
|
-
statement = subject.enumerator[1]
|
92
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::ClassStatement)
|
93
|
-
expect(statement.name).to eq('foo')
|
94
|
-
expect(statement.parameters.size).to eq(0)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe 'parsing defined types' do
|
99
|
-
let(:source) { <<SOURCE
|
100
|
-
notice hello
|
101
|
-
# A simple foo defined type.
|
102
|
-
# @param param1 First param.
|
103
|
-
# @param param2 Second param.
|
104
|
-
# @param param3 Third param.
|
105
|
-
define foo(Integer $param1, $param2, String $param3 = hi) {
|
106
|
-
file { '/tmp/foo':
|
107
|
-
ensure => present
|
108
|
-
}
|
109
|
-
}
|
110
|
-
SOURCE
|
111
|
-
}
|
112
|
-
|
113
|
-
it 'should parse the defined type statement' do
|
114
|
-
subject.parse
|
115
|
-
expect(subject.enumerator.size).to eq(1)
|
116
|
-
statement = subject.enumerator.first
|
117
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::DefinedTypeStatement)
|
118
|
-
expect(statement.name).to eq('foo')
|
119
|
-
expect(statement.source).to eq("define foo(Integer $param1, $param2, String $param3 = hi) {\n file { '/tmp/foo':\n ensure => present\n }\n}")
|
120
|
-
expect(statement.file).to eq(file)
|
121
|
-
expect(statement.line).to eq(6)
|
122
|
-
expect(statement.docstring).to eq('A simple foo defined type.')
|
123
|
-
expect(statement.parameters.size).to eq(3)
|
124
|
-
expect(statement.parameters[0].name).to eq('param1')
|
125
|
-
expect(statement.parameters[0].type).to eq('Integer')
|
126
|
-
expect(statement.parameters[0].value).to be_nil
|
127
|
-
expect(statement.parameters[1].name).to eq('param2')
|
128
|
-
expect(statement.parameters[1].type).to be_nil
|
129
|
-
expect(statement.parameters[1].value).to be_nil
|
130
|
-
expect(statement.parameters[2].name).to eq('param3')
|
131
|
-
expect(statement.parameters[2].type).to eq('String')
|
132
|
-
expect(statement.parameters[2].value).to eq('hi')
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe 'parsing puppet functions', if: TEST_PUPPET_FUNCTIONS do
|
137
|
-
let(:source) { <<SOURCE
|
138
|
-
notice hello
|
139
|
-
# A simple foo function.
|
140
|
-
# @param param1 First param.
|
141
|
-
# @param param2 Second param.
|
142
|
-
# @param param3 Third param.
|
143
|
-
function foo(Integer $param1, $param2, String $param3 = hi) {
|
144
|
-
notice world
|
145
|
-
}
|
146
|
-
SOURCE
|
147
|
-
}
|
148
|
-
|
149
|
-
it 'should parse the puppet function statement' do
|
150
|
-
subject.parse
|
151
|
-
expect(subject.enumerator.size).to eq(1)
|
152
|
-
statement = subject.enumerator.first
|
153
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::FunctionStatement)
|
154
|
-
expect(statement.name).to eq('foo')
|
155
|
-
expect(statement.source).to eq("function foo(Integer $param1, $param2, String $param3 = hi) {\n notice world\n}")
|
156
|
-
expect(statement.file).to eq(file)
|
157
|
-
expect(statement.line).to eq(6)
|
158
|
-
expect(statement.docstring).to eq('A simple foo function.')
|
159
|
-
expect(statement.parameters.size).to eq(3)
|
160
|
-
expect(statement.parameters[0].name).to eq('param1')
|
161
|
-
expect(statement.parameters[0].type).to eq('Integer')
|
162
|
-
expect(statement.parameters[0].value).to be_nil
|
163
|
-
expect(statement.parameters[1].name).to eq('param2')
|
164
|
-
expect(statement.parameters[1].type).to be_nil
|
165
|
-
expect(statement.parameters[1].value).to be_nil
|
166
|
-
expect(statement.parameters[2].name).to eq('param3')
|
167
|
-
expect(statement.parameters[2].type).to eq('String')
|
168
|
-
expect(statement.parameters[2].value).to eq('hi')
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe 'parsing puppet functions with return type in defintion', if: TEST_FUNCTION_RETURN_TYPE do
|
173
|
-
let(:source) { <<SOURCE
|
174
|
-
# A simple foo function.
|
175
|
-
# @return Returns a string
|
176
|
-
function foo() >> String {
|
177
|
-
notice world
|
178
|
-
}
|
179
|
-
SOURCE
|
180
|
-
}
|
181
|
-
|
182
|
-
it 'should parse the puppet function statement' do
|
183
|
-
subject.parse
|
184
|
-
expect(subject.enumerator.size).to eq(1)
|
185
|
-
statement = subject.enumerator.first
|
186
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::FunctionStatement)
|
187
|
-
expect(statement.type).to eq('String')
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe 'parsing puppet functions with complex return types in defintion', if: TEST_FUNCTION_RETURN_TYPE do
|
192
|
-
let(:source) { <<SOURCE
|
193
|
-
# A simple foo function.
|
194
|
-
# @return Returns a struct with a hash including one key which must be an integer between 1 and 10.
|
195
|
-
function foo() >> Struct[{'a' => Integer[1, 10]}] {
|
196
|
-
notice world
|
197
|
-
}
|
198
|
-
SOURCE
|
199
|
-
}
|
200
|
-
|
201
|
-
it 'should parse the puppet function statement' do
|
202
|
-
subject.parse
|
203
|
-
expect(subject.enumerator.size).to eq(1)
|
204
|
-
statement = subject.enumerator.first
|
205
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::FunctionStatement)
|
206
|
-
expect(statement.type).to eq("Struct\[{'a' => Integer[1, 10]}\]")
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe 'parsing type alias definitions', if: TEST_PUPPET_DATATYPES do
|
211
|
-
context 'given a type alias on a single line' do
|
212
|
-
let(:source) { <<-SOURCE
|
213
|
-
# A simple foo type.
|
214
|
-
type Module::Typename = Variant[Stdlib::Windowspath, Stdlib::Unixpath]
|
215
|
-
SOURCE
|
216
|
-
}
|
217
|
-
|
218
|
-
it 'should parse the puppet type statement' do
|
219
|
-
subject.parse
|
220
|
-
expect(subject.enumerator.size).to eq(1)
|
221
|
-
statement = subject.enumerator.first
|
222
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::DataTypeAliasStatement)
|
223
|
-
expect(statement.docstring).to eq('A simple foo type.')
|
224
|
-
expect(statement.name).to eq('Module::Typename')
|
225
|
-
expect(statement.alias_of).to eq('Variant[Stdlib::Windowspath, Stdlib::Unixpath]')
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
context 'given a type alias over multiple lines' do
|
230
|
-
let(:source) { <<-SOURCE
|
231
|
-
# A multiline foo type
|
232
|
-
# with long docs
|
233
|
-
type OptionsWithoutName = Struct[{
|
234
|
-
value_type => Optional[ValueType],
|
235
|
-
merge => Optional[MergeType]
|
236
|
-
}]
|
237
|
-
SOURCE
|
238
|
-
}
|
239
|
-
|
240
|
-
it 'should parse the puppet type statement' do
|
241
|
-
subject.parse
|
242
|
-
expect(subject.enumerator.size).to eq(1)
|
243
|
-
statement = subject.enumerator.first
|
244
|
-
expect(statement).to be_a(PuppetStrings::Yard::Parsers::Puppet::DataTypeAliasStatement)
|
245
|
-
expect(statement.docstring).to eq("A multiline foo type\nwith long docs")
|
246
|
-
expect(statement.name).to eq('OptionsWithoutName')
|
247
|
-
expect(statement.alias_of).to eq("Struct[{\n value_type => Optional[ValueType],\n merge => Optional[MergeType]\n}]")
|
248
|
-
end
|
249
|
-
end
|
250
|
-
end
|
251
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'puppet-strings/yard'
|
3
|
-
|
4
|
-
describe PuppetStrings::Yard::Util do
|
5
|
-
subject {PuppetStrings::Yard::Util}
|
6
|
-
|
7
|
-
describe 'scrub_string' do
|
8
|
-
it 'should remove `%Q` and its brackets from a string ' do
|
9
|
-
str = "%Q{this is a test string}"
|
10
|
-
expect(subject.scrub_string(str)).to eq('this is a test string')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should remove `%q` and its brackets from a string' do
|
14
|
-
str = "%q{this is a test string}"
|
15
|
-
expect(subject.scrub_string(str)).to eq('this is a test string')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should not affect newlines when %Q notation is used' do
|
19
|
-
str = <<-STR
|
20
|
-
%Q{this is
|
21
|
-
a test string}
|
22
|
-
STR
|
23
|
-
expect(subject.scrub_string(str)).to eq("this is\na test string")
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should not affect a string which does not use %Q notation' do
|
27
|
-
str = "this is a test string"
|
28
|
-
expect(subject.scrub_string(str)).to eq('this is a test string')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'github_to_yard_links' do
|
33
|
-
it 'converts a link correctly' do
|
34
|
-
str = '<a href="#module-description">'
|
35
|
-
expect(subject.github_to_yard_links(str)).to eq('<a href="#label-Module+description">')
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'leaves other links with hashes alone' do
|
39
|
-
str = '<a href="www.github.com/blah/document.html#module-description">'
|
40
|
-
expect(subject.github_to_yard_links(str)).to eq(str)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'leaves plain text alone' do
|
44
|
-
str = '<a href="#module-description"> module-description'
|
45
|
-
expect(subject.github_to_yard_links(str)).to eq('<a href="#label-Module+description"> module-description')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|