inch 0.5.0.rc5 → 0.5.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -6
- data/.rubocop_todo.yml +40 -34
- data/Gemfile +3 -3
- data/Rakefile +10 -6
- data/bin/inch +5 -5
- data/config/base.rb +4 -4
- data/config/nodejs.rb +44 -1
- data/config/ruby.rb +1 -1
- data/inch.gemspec +17 -17
- data/lib/inch.rb +13 -13
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +1 -1
- data/lib/inch/api/diff.rb +1 -1
- data/lib/inch/api/options/suggest.rb +1 -1
- data/lib/inch/api/suggest.rb +1 -1
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +5 -3
- data/lib/inch/cli/command/base_list.rb +0 -1
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +6 -6
- data/lib/inch/cli/command/inspect.rb +5 -5
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +17 -15
- data/lib/inch/cli/command/options/base_list.rb +17 -17
- data/lib/inch/cli/command/options/base_object.rb +1 -1
- data/lib/inch/cli/command/options/console.rb +13 -13
- data/lib/inch/cli/command/options/diff.rb +19 -19
- data/lib/inch/cli/command/options/inspect.rb +5 -5
- data/lib/inch/cli/command/options/list.rb +7 -7
- data/lib/inch/cli/command/options/show.rb +5 -5
- data/lib/inch/cli/command/options/stats.rb +2 -2
- data/lib/inch/cli/command/options/suggest.rb +12 -12
- data/lib/inch/cli/command/output/base.rb +1 -1
- data/lib/inch/cli/command/output/diff.rb +9 -9
- data/lib/inch/cli/command/output/inspect.rb +13 -13
- data/lib/inch/cli/command/output/list.rb +1 -1
- data/lib/inch/cli/command/output/show.rb +4 -4
- data/lib/inch/cli/command/output/stats.rb +14 -14
- data/lib/inch/cli/command/output/suggest.rb +14 -14
- data/lib/inch/cli/command/show.rb +4 -4
- data/lib/inch/cli/command/stats.rb +4 -4
- data/lib/inch/cli/command/suggest.rb +4 -4
- data/lib/inch/cli/command_parser.rb +4 -4
- data/lib/inch/cli/sparkline_helper.rb +1 -1
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +1 -1
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/provider.rb +3 -3
- data/lib/inch/code_object/proxy.rb +3 -4
- data/lib/inch/codebase.rb +5 -5
- data/lib/inch/codebase/object.rb +2 -1
- data/lib/inch/codebase/serializer.rb +2 -2
- data/lib/inch/config.rb +6 -6
- data/lib/inch/config/codebase.rb +5 -5
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +8 -8
- data/lib/inch/evaluation/proxy.rb +2 -3
- data/lib/inch/evaluation/role.rb +1 -1
- data/lib/inch/language/elixir/code_object/base.rb +6 -4
- data/lib/inch/language/elixir/evaluation/base.rb +2 -1
- data/lib/inch/language/elixir/evaluation/function_object.rb +1 -1
- data/lib/inch/language/elixir/import.rb +14 -14
- data/lib/inch/language/elixir/provider/reader.rb +1 -1
- data/lib/inch/language/elixir/provider/reader/docstring.rb +13 -0
- data/lib/inch/language/elixir/provider/reader/object.rb +5 -5
- data/lib/inch/language/elixir/provider/reader/object/base.rb +13 -5
- data/lib/inch/language/elixir/provider/reader/object/function_object.rb +1 -1
- data/lib/inch/language/elixir/provider/reader/parser.rb +21 -7
- data/lib/inch/language/elixir/roles/base.rb +3 -3
- data/lib/inch/language/elixir/roles/function.rb +2 -1
- data/lib/inch/language/elixir/roles/object.rb +1 -1
- data/lib/inch/language/nodejs/code_object/base.rb +199 -0
- data/lib/inch/language/nodejs/code_object/function_object.rb +74 -0
- data/lib/inch/language/nodejs/code_object/member_object.rb +11 -0
- data/lib/inch/language/nodejs/code_object/module_object.rb +23 -0
- data/lib/inch/language/nodejs/evaluation/base.rb +29 -0
- data/lib/inch/language/nodejs/evaluation/function_object.rb +31 -0
- data/lib/inch/language/nodejs/evaluation/member_object.rb +11 -0
- data/lib/inch/language/nodejs/evaluation/module_object.rb +27 -0
- data/lib/inch/language/nodejs/import.rb +17 -1
- data/lib/inch/language/nodejs/provider/jsdoc.rb +1 -1
- data/lib/inch/language/nodejs/provider/jsdoc/docstring.rb +13 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object.rb +16 -8
- data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +82 -45
- data/lib/inch/language/nodejs/provider/jsdoc/object/function_object.rb +18 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object/member_object.rb +15 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object/module_object.rb +22 -0
- data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +9 -10
- data/lib/inch/language/nodejs/roles/base.rb +32 -0
- data/lib/inch/language/nodejs/roles/function.rb +113 -0
- data/lib/inch/language/nodejs/roles/member.rb +13 -0
- data/lib/inch/language/nodejs/roles/module.rb +64 -0
- data/lib/inch/language/nodejs/roles/object.rb +76 -0
- data/lib/inch/language/ruby/code_object/base.rb +6 -4
- data/lib/inch/language/ruby/evaluation/base.rb +2 -1
- data/lib/inch/language/ruby/evaluation/method_object.rb +2 -1
- data/lib/inch/language/ruby/import.rb +24 -24
- data/lib/inch/language/ruby/provider/yard.rb +10 -10
- data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +2 -2
- data/lib/inch/language/ruby/provider/yard/object.rb +9 -9
- data/lib/inch/language/ruby/provider/yard/object/base.rb +25 -28
- data/lib/inch/language/ruby/provider/yard/object/method_object.rb +4 -3
- data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +4 -3
- data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +2 -2
- data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +2 -1
- data/lib/inch/language/ruby/provider/yard/parser.rb +2 -2
- data/lib/inch/language/ruby/roles/base.rb +1 -1
- data/lib/inch/language/ruby/roles/method.rb +2 -1
- data/lib/inch/language/ruby/roles/method_parameter.rb +1 -1
- data/lib/inch/language/ruby/roles/missing.rb +2 -2
- data/lib/inch/language/ruby/roles/object.rb +6 -6
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +5 -5
- data/lib/inch/utils/code_location.rb +12 -0
- data/lib/inch/utils/read_write_methods.rb +2 -2
- data/lib/inch/utils/ui.rb +8 -8
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/elixir/simple/all.json +321 -0
- data/test/integration/api/compare/codebases.rb +6 -6
- data/test/integration/cli/command/console_test.rb +13 -13
- data/test/integration/cli/command/diff_test.rb +12 -14
- data/test/integration/cli/command/inspect_test.rb +30 -30
- data/test/integration/cli/command/list_test.rb +34 -34
- data/test/integration/cli/command/show_test.rb +26 -26
- data/test/integration/cli/command/stats_test.rb +23 -23
- data/test/integration/cli/command/suggest_test.rb +58 -49
- data/test/integration/stats_options_test.rb +9 -9
- data/test/integration/visibility_options_test.rb +49 -45
- data/test/shared/base_list.rb +41 -41
- data/test/test_helper.rb +18 -10
- data/test/unit/api/filter_test.rb +9 -9
- data/test/unit/api/get_test.rb +6 -6
- data/test/unit/api/list_test.rb +3 -3
- data/test/unit/api/options/base_test.rb +6 -6
- data/test/unit/api/stats_test.rb +3 -3
- data/test/unit/api/suggest_test.rb +4 -4
- data/test/unit/cli/arguments_test.rb +25 -25
- data/test/unit/cli/command/base_test.rb +3 -3
- data/test/unit/cli/command/options/base_list_test.rb +14 -14
- data/test/unit/cli/command/options/base_object_test.rb +6 -6
- data/test/unit/cli/command/options/base_test.rb +3 -3
- data/test/unit/cli/command_parser_test.rb +29 -29
- data/test/unit/cli/trace_helper_test.rb +2 -2
- data/test/unit/cli/yardopts_helper_test.rb +35 -35
- data/test/unit/code_object/converter_test.rb +3 -3
- data/test/unit/code_object/provider_test.rb +2 -2
- data/test/unit/code_object/proxy_test.rb +11 -11
- data/test/unit/codebase/objects_test.rb +8 -8
- data/test/unit/codebase/proxy_test.rb +5 -5
- data/test/unit/config/codebase_test.rb +3 -3
- data/test/unit/config_test.rb +4 -4
- data/test/unit/evaluation/role_test.rb +8 -8
- data/test/unit/language/elixir/code_object/function_object_test.rb +35 -0
- data/test/unit/language/ruby/code_object/method_object_test.rb +128 -126
- data/test/unit/language/ruby/provider/yard/docstring_test.rb +27 -23
- data/test/unit/language/ruby/provider/yard/nodoc_helper_test.rb +21 -20
- data/test/unit/language/ruby/provider/yard/object/method_object_test.rb +20 -17
- data/test/unit/language/ruby/provider/yard_test.rb +4 -4
- data/test/unit/utils/buffered_ui_test.rb +20 -20
- data/test/unit/utils/ui_test.rb +20 -20
- data/test/unit/utils/weighted_list_test.rb +7 -7
- metadata +25 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::Language::Ruby::Provider::YARD::Docstring do
|
4
4
|
let(:described_class) { ::Inch::Language::Ruby::Provider::YARD::Docstring }
|
@@ -7,7 +7,7 @@ describe ::Inch::Language::Ruby::Provider::YARD::Docstring do
|
|
7
7
|
# loose TomDoc compatibility
|
8
8
|
#
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'should notice things in tomdoc style docs' do
|
11
11
|
text = <<-DOC
|
12
12
|
Internal: Detects the Language of the blob.
|
13
13
|
|
@@ -32,7 +32,7 @@ Returns Language or nil.
|
|
32
32
|
assert docstring.describes_return?
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it 'should notice things in tomdoc style docs 2' do
|
36
36
|
text = <<-DOC
|
37
37
|
Public: Look up Language by one of its aliases.
|
38
38
|
|
@@ -55,7 +55,7 @@ Returns the Lexer or nil if none was found.
|
|
55
55
|
assert docstring.describes_return?
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'should notice multi-line returns in tomdoc style docs' do
|
59
59
|
text = <<-DOC
|
60
60
|
Public: Look up Language by one of its aliases.
|
61
61
|
|
@@ -67,7 +67,7 @@ Returns the Lexer or nil
|
|
67
67
|
assert docstring.describes_return?
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
70
|
+
it 'should notice multi-line returns in tomdoc style docs 2' do
|
71
71
|
text = <<-DOC
|
72
72
|
Public: Look up Language by one of its aliases.
|
73
73
|
|
@@ -80,7 +80,7 @@ Returns the Lexer or nil
|
|
80
80
|
assert docstring.describes_return?
|
81
81
|
end
|
82
82
|
|
83
|
-
it
|
83
|
+
it 'should notice things in tomdoc style docs 3' do
|
84
84
|
text = <<-DOC
|
85
85
|
Public: Look up Language by one of its aliases.
|
86
86
|
|
@@ -140,8 +140,8 @@ returns nothing
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should understand 'Returns ...' with a visibility modifier in front of" \
|
143
|
-
|
144
|
-
text =
|
143
|
+
' it' do
|
144
|
+
text = 'Public: Returns the Integer color.'
|
145
145
|
docstring = described_class.new(text)
|
146
146
|
assert docstring.mentions_return?
|
147
147
|
assert docstring.describes_return?
|
@@ -151,7 +151,7 @@ returns nothing
|
|
151
151
|
# PARAMETER MENTIONS
|
152
152
|
#
|
153
153
|
|
154
|
-
it
|
154
|
+
it 'should work 2' do
|
155
155
|
text = <<-DOC
|
156
156
|
Just because format_html is mentioned here, does not mean
|
157
157
|
the first parameter is mentioned.
|
@@ -161,7 +161,7 @@ the first parameter is mentioned.
|
|
161
161
|
refute docstring.contains_code_example?
|
162
162
|
end
|
163
163
|
|
164
|
-
it
|
164
|
+
it 'should work 2 if correct' do
|
165
165
|
text = <<-DOC
|
166
166
|
Just because format is mentioned here, does not mean
|
167
167
|
the first parameter is meant.
|
@@ -175,7 +175,7 @@ the first parameter is meant.
|
|
175
175
|
# CODE EXAMPLES
|
176
176
|
#
|
177
177
|
|
178
|
-
it
|
178
|
+
it 'should work 3' do
|
179
179
|
text = <<-DOC
|
180
180
|
An example of a method using RDoc rather than YARD.
|
181
181
|
|
@@ -190,7 +190,8 @@ A string in the specified format.
|
|
190
190
|
refute docstring.contains_code_example?
|
191
191
|
end
|
192
192
|
|
193
|
-
it
|
193
|
+
it 'should work with code example' do
|
194
|
+
# rubocop:disable Metrics/LineLength
|
194
195
|
text = <<-DOC
|
195
196
|
Another example.
|
196
197
|
|
@@ -201,6 +202,7 @@ Params:
|
|
201
202
|
+param2+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
202
203
|
+param3+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
203
204
|
DOC
|
205
|
+
# rubocop:enable Metrics/LineLength
|
204
206
|
docstring = described_class.new(text)
|
205
207
|
assert docstring.contains_code_example?
|
206
208
|
assert docstring.mentions_parameter?(:param1)
|
@@ -211,23 +213,25 @@ Params:
|
|
211
213
|
assert docstring.describes_parameter?(:param3)
|
212
214
|
end
|
213
215
|
|
214
|
-
it
|
216
|
+
it 'should recognize several parameter notations' do
|
217
|
+
# rubocop:disable Metrics/LineLength
|
215
218
|
text = <<-DOC
|
216
219
|
Params:
|
217
220
|
+param1<String>+:: param1 line string to be executed by the system
|
218
221
|
+param2<String,nil>+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
219
222
|
+param3<String|Class>+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
220
223
|
DOC
|
224
|
+
# rubocop:enable Metrics/LineLength
|
221
225
|
docstring = described_class.new(text)
|
222
|
-
assert docstring.mentions_parameter?(:param1),
|
223
|
-
assert docstring.mentions_parameter?(:param2),
|
224
|
-
assert docstring.mentions_parameter?(:param3),
|
225
|
-
assert docstring.describes_parameter?(:param1),
|
226
|
-
assert docstring.describes_parameter?(:param2),
|
227
|
-
assert docstring.describes_parameter?(:param3),
|
226
|
+
assert docstring.mentions_parameter?(:param1), 'should mention param1'
|
227
|
+
assert docstring.mentions_parameter?(:param2), 'should mention param2'
|
228
|
+
assert docstring.mentions_parameter?(:param3), 'should mention param3'
|
229
|
+
assert docstring.describes_parameter?(:param1), 'should describe param1'
|
230
|
+
assert docstring.describes_parameter?(:param2), 'should describe param2'
|
231
|
+
assert docstring.describes_parameter?(:param3), 'should describe param3'
|
228
232
|
end
|
229
233
|
|
230
|
-
it
|
234
|
+
it 'should work with code example 2' do
|
231
235
|
text = <<-DOC
|
232
236
|
Just because format_html is mentioned here, does not mean
|
233
237
|
the first parameter is mentioned.
|
@@ -240,7 +244,7 @@ the first parameter is mentioned.
|
|
240
244
|
assert_equal 1, docstring.code_examples.size
|
241
245
|
end
|
242
246
|
|
243
|
-
it
|
247
|
+
it 'should work with code example 3' do
|
244
248
|
text = <<-DOC
|
245
249
|
An example of a method using RDoc rather than YARD.
|
246
250
|
|
@@ -260,7 +264,7 @@ A string in the specified format.
|
|
260
264
|
assert docstring.describes_parameter?(:param1)
|
261
265
|
end
|
262
266
|
|
263
|
-
it
|
267
|
+
it 'should work with multiple code examples' do
|
264
268
|
text = <<-DOC
|
265
269
|
An example of a method using RDoc rather than YARD.
|
266
270
|
|
@@ -281,6 +285,6 @@ A string in the specified format.
|
|
281
285
|
docstring = described_class.new(text)
|
282
286
|
assert docstring.contains_code_example?
|
283
287
|
assert_equal 2, docstring.code_examples.size
|
284
|
-
assert docstring.code_examples.last.index(
|
288
|
+
assert docstring.code_examples.last.index('create_index! 2')
|
285
289
|
end
|
286
290
|
end
|
@@ -1,38 +1,39 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::Language::Ruby::Provider::YARD::NodocHelper do
|
4
4
|
before do
|
5
5
|
@config = Inch::Config.codebase
|
6
|
-
@provider = ::Inch::Language::Ruby::Provider::YARD.parse(
|
6
|
+
@provider = ::Inch::Language::Ruby::Provider::YARD.parse(
|
7
|
+
fixture_path(:ruby, :simple), @config)
|
7
8
|
@objects = @provider.objects
|
8
9
|
end
|
9
10
|
|
10
|
-
it
|
11
|
+
it 'should return true for explicitly or implicitly tagged objects' do
|
11
12
|
[
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
'Foo::Qux',
|
14
|
+
'Foo::Qux#method_with_implicit_nodoc',
|
15
|
+
'Foo::Qux::Quux#method_with_private_tag',
|
16
|
+
'Foo::Qux::Quux#method_with_explicit_nodoc',
|
17
|
+
'Foo::Qux::Quux::PRIVATE_VALUE',
|
18
|
+
'Foo::HiddenClass',
|
19
|
+
'Foo::HiddenClass::EvenMoreHiddenClass',
|
20
|
+
'Foo::HiddenClass::EvenMoreHiddenClass#method_with_implicit_nodoc',
|
21
|
+
'Foo::HiddenClassViaTag',
|
22
|
+
'Foo::HiddenClassViaTag#some_value'
|
22
23
|
].each do |query|
|
23
24
|
m = @objects.find { |o| o.fullname == query }
|
24
25
|
assert m.nodoc?, "nodoc? should return true for #{query}"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
it
|
29
|
+
it 'should return false for other objects' do
|
29
30
|
[
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
'Foo::Qux::Quux#method_without_nodoc',
|
32
|
+
'Foo::Qux::Quux::PUBLIC_VALUE',
|
33
|
+
'Foo::Qux::DOCCED_VALUE',
|
34
|
+
'Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass',
|
35
|
+
'Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass' \
|
36
|
+
'#method_with_implicit_doc'
|
36
37
|
].each do |query|
|
37
38
|
m = @objects.find { |o| o.fullname == query }
|
38
39
|
refute m.nodoc?, "nodoc? should return false for #{query}"
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) +
|
2
|
+
'/../../../../../../test_helper')
|
2
3
|
|
3
4
|
describe ::Inch::Language::Ruby::Provider::YARD::Parser do
|
4
5
|
before do
|
@@ -8,18 +9,19 @@ describe ::Inch::Language::Ruby::Provider::YARD::Parser do
|
|
8
9
|
@objects = @parser.objects
|
9
10
|
end
|
10
11
|
|
11
|
-
it
|
12
|
+
it 'should work for Overloading#params_also_in_overloads' do
|
12
13
|
m = @objects.find do |o|
|
13
|
-
o.fullname ==
|
14
|
+
o.fullname == 'Overloading#params_also_in_overloads'
|
14
15
|
end
|
15
16
|
|
16
17
|
assert m.has_code_example?
|
17
18
|
|
18
19
|
assert_equal 3, m.signatures.size
|
19
|
-
|
20
|
+
# at this moment, this counts all parameters in all overloaded signatures
|
21
|
+
assert_equal 2, m.parameters.size
|
20
22
|
|
21
23
|
signature = m.signatures[0]
|
22
|
-
assert_equal
|
24
|
+
assert_equal 'params_also_in_overloads(user_options = {})',
|
23
25
|
signature.signature
|
24
26
|
assert_equal 1, signature.parameters.size
|
25
27
|
refute signature.parameter(:user_options).nil?
|
@@ -27,62 +29,63 @@ describe ::Inch::Language::Ruby::Provider::YARD::Parser do
|
|
27
29
|
assert signature.has_doc?
|
28
30
|
|
29
31
|
signature = m.signatures[1]
|
30
|
-
assert_equal
|
32
|
+
assert_equal 'params_also_in_overloads()', signature.signature
|
31
33
|
assert signature.parameters.empty?,
|
32
34
|
"Should have been empty: #{signature.parameters.inspect}"
|
33
35
|
assert signature.has_code_example?
|
34
36
|
refute signature.has_doc?
|
35
37
|
|
36
38
|
signature = m.signatures[2]
|
37
|
-
assert_equal
|
39
|
+
assert_equal 'params_also_in_overloads(transaction_id)', signature.signature
|
38
40
|
assert_equal 1, signature.parameters.size
|
39
41
|
refute signature.parameter(:transaction_id).nil?
|
40
42
|
assert signature.has_code_example?
|
41
43
|
refute signature.has_doc?
|
42
44
|
end
|
43
45
|
|
44
|
-
it
|
46
|
+
it 'should work for Overloading#params_only_in_overloads' do
|
45
47
|
m = @objects.find do |o|
|
46
|
-
o.fullname ==
|
48
|
+
o.fullname == 'Overloading#params_only_in_overloads'
|
47
49
|
end
|
48
50
|
|
49
51
|
assert m.has_code_example?
|
50
52
|
|
51
53
|
assert_equal 3, m.signatures.size
|
52
|
-
|
54
|
+
# at this moment, this counts all parameters in all overloaded signatures
|
55
|
+
assert_equal 2, m.parameters.size
|
53
56
|
|
54
57
|
signature = m.signatures[0]
|
55
|
-
assert_equal
|
58
|
+
assert_equal 'params_only_in_overloads()', signature.signature
|
56
59
|
assert signature.parameters.empty?,
|
57
60
|
"Should have been empty: #{signature.parameters.inspect}"
|
58
61
|
assert signature.has_code_example?
|
59
62
|
refute signature.has_doc?
|
60
63
|
|
61
64
|
signature = m.signatures[1]
|
62
|
-
assert_equal
|
65
|
+
assert_equal 'params_only_in_overloads(transaction_id)', signature.signature
|
63
66
|
assert_equal 1, signature.parameters.size
|
64
67
|
refute signature.parameter(:transaction_id).nil?
|
65
68
|
assert signature.has_code_example?
|
66
69
|
refute signature.has_doc?
|
67
70
|
|
68
71
|
signature = m.signatures[2]
|
69
|
-
assert_equal
|
72
|
+
assert_equal 'params_only_in_overloads(user_options)', signature.signature
|
70
73
|
assert_equal 1, signature.parameters.size
|
71
74
|
refute signature.parameter(:user_options).nil?
|
72
75
|
assert signature.has_code_example?
|
73
76
|
# assert signature.has_doc?
|
74
77
|
end
|
75
78
|
|
76
|
-
it
|
79
|
+
it 'should work' do
|
77
80
|
m = @objects.find do |o|
|
78
|
-
o.fullname ==
|
81
|
+
o.fullname == 'Foo::Bar#method_with_unstructured_doc'
|
79
82
|
end
|
80
83
|
assert_equal 1, m.signatures.size
|
81
84
|
assert_equal 1, m.parameters.size
|
82
85
|
end
|
83
86
|
|
84
|
-
it
|
85
|
-
m = @objects.find { |o| o.fullname ==
|
87
|
+
it 'should work 2' do
|
88
|
+
m = @objects.find { |o| o.fullname == 'Foo#method_with_splat_parameter' }
|
86
89
|
assert_equal 1, m.signatures.size
|
87
90
|
assert_equal 1, m.parameters.size
|
88
91
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::Language::Ruby::Provider::YARD do
|
4
4
|
let(:described_class) { ::Inch::Language::Ruby::Provider::YARD }
|
5
5
|
let(:config) { ::Inch::Config.codebase }
|
6
6
|
|
7
|
-
it
|
7
|
+
it 'should parse' do
|
8
8
|
provider = described_class.parse(fixture_path(:ruby, :simple), config)
|
9
9
|
assert !provider.objects.empty?
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
13
|
-
fullname =
|
12
|
+
it 'should parse too different codebases' do
|
13
|
+
fullname = 'Foo#b'
|
14
14
|
|
15
15
|
provider1 = described_class.parse(fixture_path(:ruby, :diff1), config)
|
16
16
|
object1 = provider1.objects.find { |o| o.fullname == fullname }
|
@@ -1,48 +1,48 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
2
|
require 'inch/utils/buffered_ui'
|
3
3
|
|
4
4
|
describe ::Inch::Utils::BufferedUI do
|
5
5
|
let(:described_class) { ::Inch::Utils::BufferedUI }
|
6
|
-
it
|
6
|
+
it 'should trace' do
|
7
7
|
out, err = capture_io do
|
8
8
|
@instance = described_class.new
|
9
|
-
@instance.trace(
|
9
|
+
@instance.trace('Test')
|
10
10
|
end
|
11
|
-
assert out.empty?,
|
12
|
-
assert err.empty?,
|
11
|
+
assert out.empty?, 'there should be output'
|
12
|
+
assert err.empty?, 'there should be no errors'
|
13
13
|
refute @instance.buffer.empty?
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'should trace header' do
|
17
17
|
out, err = capture_io do
|
18
18
|
@instance = described_class.new
|
19
|
-
@instance.header(
|
19
|
+
@instance.header('Test', :red)
|
20
20
|
end
|
21
|
-
assert out.empty?,
|
22
|
-
assert err.empty?,
|
21
|
+
assert out.empty?, 'there should be output'
|
22
|
+
assert err.empty?, 'there should be no errors'
|
23
23
|
refute @instance.buffer.empty?
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
27
|
-
ENV[
|
26
|
+
it 'should trace debug if ENV variable is set' do
|
27
|
+
ENV['DEBUG'] = '1'
|
28
28
|
out, err = capture_io do
|
29
29
|
@instance = described_class.new
|
30
|
-
@instance.debug(
|
30
|
+
@instance.debug('Test')
|
31
31
|
end
|
32
|
-
ENV[
|
33
|
-
assert out.empty?,
|
34
|
-
assert err.empty?,
|
32
|
+
ENV['DEBUG'] = nil
|
33
|
+
assert out.empty?, 'there should be output'
|
34
|
+
assert err.empty?, 'there should be no errors'
|
35
35
|
refute @instance.buffer.empty?
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
39
|
-
refute ENV[
|
38
|
+
it 'should not trace debug if ENV variable is set' do
|
39
|
+
refute ENV['DEBUG']
|
40
40
|
out, err = capture_io do
|
41
41
|
@instance = described_class.new
|
42
|
-
@instance.debug(
|
42
|
+
@instance.debug('Test')
|
43
43
|
end
|
44
|
-
assert out.empty?,
|
45
|
-
assert err.empty?,
|
44
|
+
assert out.empty?, 'there should be no output'
|
45
|
+
assert err.empty?, 'there should be no errors'
|
46
46
|
assert @instance.buffer.empty?
|
47
47
|
end
|
48
48
|
end
|
data/test/unit/utils/ui_test.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::Utils::UI do
|
4
|
-
it
|
4
|
+
it 'should trace' do
|
5
5
|
out, err = capture_io do
|
6
6
|
@instance = ::Inch::Utils::UI.new
|
7
|
-
@instance.trace(
|
7
|
+
@instance.trace('Test')
|
8
8
|
end
|
9
|
-
refute out.empty?,
|
10
|
-
assert err.empty?,
|
9
|
+
refute out.empty?, 'there should be output'
|
10
|
+
assert err.empty?, 'there should be no errors'
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it 'should trace header' do
|
14
14
|
out, err = capture_io do
|
15
15
|
@instance = ::Inch::Utils::UI.new
|
16
|
-
@instance.header(
|
16
|
+
@instance.header('Test', :red)
|
17
17
|
end
|
18
|
-
refute out.empty?,
|
19
|
-
assert err.empty?,
|
18
|
+
refute out.empty?, 'there should be output'
|
19
|
+
assert err.empty?, 'there should be no errors'
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
ENV[
|
22
|
+
it 'should trace debug if ENV variable is set' do
|
23
|
+
ENV['DEBUG'] = '1'
|
24
24
|
out, err = capture_io do
|
25
25
|
@instance = ::Inch::Utils::UI.new
|
26
|
-
@instance.debug(
|
26
|
+
@instance.debug('Test')
|
27
27
|
end
|
28
|
-
ENV[
|
29
|
-
refute out.empty?,
|
30
|
-
assert err.empty?,
|
28
|
+
ENV['DEBUG'] = nil
|
29
|
+
refute out.empty?, 'there should be output'
|
30
|
+
assert err.empty?, 'there should be no errors'
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
34
|
-
refute ENV[
|
33
|
+
it 'should not trace debug if ENV variable is set' do
|
34
|
+
refute ENV['DEBUG']
|
35
35
|
out, err = capture_io do
|
36
36
|
@instance = ::Inch::Utils::UI.new
|
37
|
-
@instance.debug(
|
37
|
+
@instance.debug('Test')
|
38
38
|
end
|
39
|
-
assert out.empty?,
|
40
|
-
assert err.empty?,
|
39
|
+
assert out.empty?, 'there should be no output'
|
40
|
+
assert err.empty?, 'there should be no errors'
|
41
41
|
end
|
42
42
|
end
|