tomparse 0.4.2 → 0.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.
@@ -1,217 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Arguments" do
4
-
5
- context "single line argument without heading" do
6
- setup do
7
- @comment = TomParse::TomDoc.new %{
8
- # Duplicate some text an abitrary number of times.
9
- #
10
- # text - The String to be duplicated.
11
- #
12
- # Returns the duplicated String when the count is > 1.
13
- }
14
- end
15
- test "knows args size" do
16
- @comment.args.size.assert == 1
17
- end
18
- test "knows args name" do
19
- @comment.args.first.name.assert == :text
20
- end
21
- test "knows args description" do
22
- @comment.args.first.description.assert == "The String to be duplicated."
23
- end
24
- test "knows args optionality" do
25
- @comment.args.first.refute.optional?
26
- end
27
- test "know description" do
28
- @comment.description == "Duplicate some text an abitrary number of times."
29
- end
30
- end
31
-
32
- context "multi-line argument without heading" do
33
- setup do
34
- @comment = TomParse::TomDoc.new %{
35
- # Duplicate some text an abitrary number of times.
36
- #
37
- # text - The String to be duplicated.
38
- # And its description continues.
39
- #
40
- # Returns the duplicated String when the count is > 1.
41
- }
42
- end
43
- test "knows args size" do
44
- @comment.args.size.assert == 1
45
- end
46
- test "knows args name" do
47
- @comment.args.first.name.assert == :text
48
- end
49
- test "knows args description" do
50
- @comment.args.first.description.assert == "The String to be duplicated. And its description continues."
51
- end
52
- test "knows args optionality" do
53
- @comment.args.first.refute.optional?
54
- end
55
- test "know description" do
56
- @comment.description == "Duplicate some text an abitrary number of times."
57
- end
58
- end
59
-
60
- context "multiple arguments without heading" do
61
- setup do
62
- @comment = TomParse::TomDoc.new %{
63
- # Duplicate some text an abitrary number of times.
64
- #
65
- # text - The String to be duplicated.
66
- # And its description continues.
67
- # num - The Number to be duplicated.
68
- # And it continues too. (optional)
69
- #
70
- # Returns the duplicated String when the count is > 1.
71
- }
72
- end
73
- test "knows args size" do
74
- @comment.args.size.assert == 2
75
- end
76
- test "knows args name" do
77
- @comment.args[0].name.assert == :text
78
- @comment.args[1].name.assert == :num
79
- end
80
- test "knows args description" do
81
- @comment.args[0].description.assert == "The String to be duplicated. And its description continues."
82
- @comment.args[1].description.assert == "The Number to be duplicated. And it continues too. (optional)"
83
- end
84
- test "knows args optionality" do
85
- @comment.args[0].refute.optional?
86
- @comment.args[1].assert.optional?
87
- end
88
- test "know description" do
89
- @comment.description == "Duplicate some text an abitrary number of times."
90
- end
91
- end
92
-
93
- context "single line argument with heading" do
94
- setup do
95
- @comment = TomParse::TomDoc.new %{
96
- # Duplicate some text an abitrary number of times.
97
- #
98
- # Arguments
99
- # text - The String to be duplicated.
100
- #
101
- # Returns the duplicated String when the count is > 1.
102
- }
103
- end
104
- test "knows args size" do
105
- @comment.args.size.assert == 1
106
- end
107
- test "knows args name" do
108
- @comment.args.first.name.assert == :text
109
- end
110
- test "knows args description" do
111
- @comment.args.first.description.assert == "The String to be duplicated."
112
- end
113
- test "knows args optionality" do
114
- @comment.args.first.refute.optional?
115
- end
116
- test "know description" do
117
- @comment.description == "Duplicate some text an abitrary number of times."
118
- end
119
- end
120
-
121
- context "multi-line argument with heading" do
122
- setup do
123
- @comment = TomParse::TomDoc.new %{
124
- # Duplicate some text an abitrary number of times.
125
- #
126
- # Arguments
127
- # text - The String to be duplicated.
128
- # And its description continues.
129
- #
130
- # Returns the duplicated String when the count is > 1.
131
- }
132
- end
133
- test "knows args size" do
134
- @comment.args.size.assert == 1
135
- end
136
- test "knows args name" do
137
- @comment.args.first.name.assert == :text
138
- end
139
- test "knows args description" do
140
- @comment.args.first.description.assert == "The String to be duplicated. And its description continues."
141
- end
142
- test "knows args optionality" do
143
- @comment.args.first.refute.optional?
144
- end
145
- test "know description" do
146
- @comment.description == "Duplicate some text an abitrary number of times."
147
- end
148
- end
149
-
150
- context "multiple arguments without heading" do
151
- setup do
152
- @comment = TomParse::TomDoc.new %{
153
- # Duplicate some text an abitrary number of times.
154
- #
155
- # Arguments
156
- # text - The String to be duplicated.
157
- # And its description continues.
158
- # num - The Number to be duplicated.
159
- # And it continues too. (optional)
160
- #
161
- # Returns the duplicated String when the count is > 1.
162
- }
163
- end
164
- test "knows args size" do
165
- @comment.args.size.assert == 2
166
- end
167
- test "knows args name" do
168
- @comment.args[0].name.assert == :text
169
- @comment.args[1].name.assert == :num
170
- end
171
- test "knows args description" do
172
- @comment.args[0].description.assert == "The String to be duplicated. And its description continues."
173
- @comment.args[1].description.assert == "The Number to be duplicated. And it continues too. (optional)"
174
- end
175
- test "knows args optionality" do
176
- @comment.args[0].refute.optional?
177
- @comment.args[1].assert.optional?
178
- end
179
- test "know description" do
180
- @comment.description == "Duplicate some text an abitrary number of times."
181
- end
182
- end
183
-
184
- context "when description has visibility indicator" do
185
- setup do
186
- @comment = TomParse::TomDoc.new %{
187
- # Public: Duplicate some text an abitrary number of times.
188
- #
189
- # text - The String to be duplicated.
190
- # And its description continues.
191
- # num - The Number to be duplicated.
192
- # And it continues too.
193
- #
194
- # Returns the duplicated String when the count is > 1.
195
- }
196
- end
197
- test "knows args size" do
198
- @comment.args.size.assert == 2
199
- end
200
- test "knows args name" do
201
- @comment.args[0].name.assert == :text
202
- @comment.args[1].name.assert == :num
203
- end
204
- test "knows args description" do
205
- @comment.args[0].description.assert == "The String to be duplicated. And its description continues."
206
- @comment.args[1].description.assert == "The Number to be duplicated. And it continues too."
207
- end
208
- test "knows args optionality" do
209
- @comment.args[0].refute.optional?
210
- @comment.args[1].refute.optional?
211
- end
212
- test "know description" do
213
- @comment.description == "Duplicate some text an abitrary number of times."
214
- end
215
- end
216
-
217
- end
@@ -1,54 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Description" do
4
-
5
- context "description only" do
6
- setup do
7
- @comment = TomParse::TomDoc.new %{
8
- # Has this initial paragraph.
9
- }
10
- end
11
-
12
- test "correctly handles description only" do
13
- @comment.description.assert == "Has this initial paragraph."
14
- end
15
- end
16
-
17
- context "simple description with other things" do
18
- setup do
19
- @comment = TomParse::TomDoc.new %{
20
- # Has this initial paragraph, that continues on to
21
- # a new line.
22
- #
23
- # Examples
24
- #
25
- # foo('bar')
26
- }
27
- end
28
-
29
- test "correctly handles description" do
30
- @comment.description.assert == "Has this initial paragraph, that continues on to\na new line."
31
- end
32
- end
33
-
34
- context "handles multiple paragraph descriptions" do
35
- setup do
36
- @comment = TomParse::TomDoc.new %{
37
- # Has an initial paragraph.
38
- #
39
- # Has another paragraph in the description.
40
- #
41
- # Examples
42
- #
43
- # def multiplex(str, length)
44
- # str * length
45
- # end
46
- }
47
- end
48
-
49
- test "correctly handles multiple paragraphs" do
50
- @comment.description.assert == "Has an initial paragraph.\n\nHas another paragraph in the description."
51
- end
52
- end
53
-
54
- end
@@ -1,124 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Examples" do
4
-
5
- context "plural form one example" do
6
- setup do
7
- @comment = TomParse::TomDoc.new %{
8
- # Duplicate some text an abitrary number of times.
9
- #
10
- # Examples
11
- # multiplex('Tom', 4)
12
- # # => 'TomTomTomTom'
13
- #
14
- # Returns something or another.
15
- }
16
- end
17
-
18
- test "there is one examples" do
19
- @comment.examples.size.assert == 1
20
- end
21
-
22
- test "the example" do
23
- @comment.examples.first.assert == "multiplex('Tom', 4)\n# => 'TomTomTomTom'"
24
- end
25
- end
26
-
27
- context "plural form multiple examples" do
28
- setup do
29
- @comment = TomParse::TomDoc.new %{
30
- # Duplicate some text an abitrary number of times.
31
- #
32
- # Examples
33
- # multiplex('Tom', 4)
34
- # # => 'TomTomTomTom'
35
- #
36
- # multiplex('Bo', 2)
37
- # # => 'BoBo'
38
- #
39
- # Returns something or another.
40
- }
41
- end
42
-
43
- test "there are two examples" do
44
- @comment.examples.size.assert == 2
45
- end
46
-
47
- test "the first example" do
48
- @comment.examples.first.assert == "multiplex('Tom', 4)\n# => 'TomTomTomTom'"
49
- end
50
-
51
- test "the second example" do
52
- @comment.examples.last.assert == "multiplex('Bo', 2)\n# => 'BoBo'"
53
- end
54
- end
55
-
56
- context "singular form" do
57
- setup do
58
- @comment = TomParse::TomDoc.new %{
59
- # Duplicate some text an abitrary number of times.
60
- #
61
- # Example
62
- # answer = multiplex('Tom', 4)
63
- #
64
- # return answer
65
- #
66
- # Returns something or another.
67
- }
68
- end
69
-
70
- test "there is one example" do
71
- @comment.examples.size.assert == 1
72
- end
73
-
74
- test "the example" do
75
- @comment.examples.first.assert == "answer = multiplex('Tom', 4)\n\nreturn answer"
76
- end
77
- end
78
-
79
- context "multiple example clauses" do
80
- setup do
81
- @comment = TomParse::TomDoc.new %{
82
- # Duplicate some text an abitrary number of times.
83
- #
84
- # Examples
85
- # multiplex('Tom', 4)
86
- # # => 'TomTomTomTom'
87
- #
88
- # multiplex('Bo', 2)
89
- # # => 'BoBo'
90
- #
91
- # Example
92
- # answer = multiplex('Tom', 4)
93
- #
94
- # return answer
95
- #
96
- # Returns something or another.
97
- }
98
- end
99
-
100
- test "there are three examples" do
101
- @comment.examples.size.assert == 3
102
- end
103
- end
104
-
105
- context "handles whitespace in examples" do
106
- setup do
107
- @comment = TomParse::TomDoc.new %{
108
- # Duplicate some text an abitrary number of times.
109
- #
110
- # Examples
111
- #
112
- # def multiplex(str, length)
113
- # str * length
114
- # end
115
- }
116
- end
117
-
118
- test "correctly handles whitespace with examples" do
119
- eg = @comment.examples[0].to_s
120
- eg.assert == "def multiplex(str, length)\n str * length\nend"
121
- end
122
- end
123
-
124
- end
@@ -1,42 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Prefixes" do
4
-
5
- context "Internal" do
6
-
7
- setup do
8
- @tomdoc = TomParse::TomDoc.new(<<-END)
9
- # Internal: Some example text.
10
- END
11
- end
12
-
13
- test "internal?" do
14
- @tomdoc.assert.internal?
15
- end
16
-
17
- test "description" do
18
- @tomdoc.description.assert == "Some example text."
19
- end
20
-
21
- end
22
-
23
- context "Public" do
24
-
25
- setup do
26
- @tomdoc = TomParse::TomDoc.new(<<-END)
27
- # Public: Some example text.
28
- END
29
- end
30
-
31
- test "public?" do
32
- @tomdoc.assert.public?
33
- end
34
-
35
- test "description" do
36
- @tomdoc.description.assert == "Some example text."
37
- end
38
-
39
- end
40
-
41
-
42
- end
@@ -1,55 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Signatures" do
4
-
5
- context "singular term" do
6
-
7
- setup do
8
- @comment = TomParse::TomDoc.new %{
9
- # Duplicate some text an abitrary number of times.
10
- #
11
- # Signature
12
- #
13
- # find(name)
14
- # find(name=>pattern)
15
- #
16
- }
17
- end
18
-
19
- test "knows if the method has alternate signatures" do
20
- @comment.signatures.size.assert == 2
21
- @comment.signatures.first.assert == "find(name)"
22
- @comment.signatures.last.assert == "find(name=>pattern)"
23
- end
24
-
25
- end
26
-
27
- context "plural term" do
28
-
29
- setup do
30
- @comment = TomParse::TomDoc.new %{
31
- # Duplicate some text an abitrary number of times.
32
- #
33
- # Signatures
34
- #
35
- # find_by_<field>[_and_<field>...](args)
36
- #
37
- }
38
- end
39
-
40
- test "knows if the method has alternate signatures" do
41
- @comment.signatures.size.assert == 1
42
- @comment.signatures.first.assert == "find_by_<field>[_and_<field>...](args)"
43
- end
44
-
45
- end
46
-
47
- #test "knows the fields associated with signatures" do
48
- # @comment.signature_fields.size.assert == 1
49
- #
50
- # arg = @comment.signature_fields.first
51
- # arg.name.assert == :field
52
- # arg.description.assert == "A field name."
53
- #end
54
-
55
- end
data/test/test_tags.rb DELETED
@@ -1,40 +0,0 @@
1
- require_relative 'helper'
2
-
3
- testcase "Tags" do
4
-
5
- context "TODO" do
6
-
7
- setup do
8
- @tomdoc = TomParse::TomDoc.new(<<-END)
9
- # This is an example of tags.
10
- #
11
- # TODO: Something we have to do.
12
- END
13
- end
14
-
15
- test "tags has todo" do
16
- @tomdoc.tags.size.assert == 1
17
- @tomdoc.tags.assert.include? ['TODO', 'Something we have to do.']
18
- end
19
-
20
- end
21
-
22
- context "FOO" do
23
-
24
- setup do
25
- @tomdoc = TomParse::TomDoc.new(<<-END)
26
- # This is an example of tags.
27
- #
28
- # Foo: They can be anything really.
29
- END
30
- end
31
-
32
- test "tags has foo" do
33
- @tomdoc.tags.size.assert == 1
34
- @tomdoc.tags.assert.include? ['Foo', 'They can be anything really.']
35
- end
36
-
37
- end
38
-
39
-
40
- end