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
|
class Inch::CLI::Command::Output::Console
|
4
4
|
def run_pry
|
@@ -12,16 +12,16 @@ describe ::Inch::CLI::Command::Console do
|
|
12
12
|
@command = ::Inch::CLI::Command::Console
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should output info when run with --help' do
|
16
16
|
out, err = capture_io do
|
17
|
-
assert_raises(SystemExit) { @command.run(
|
17
|
+
assert_raises(SystemExit) { @command.run('--help') }
|
18
18
|
end
|
19
|
-
refute out.empty?,
|
20
|
-
assert_match
|
21
|
-
assert err.empty?,
|
19
|
+
refute out.empty?, 'there should be some output'
|
20
|
+
assert_match(/\bUsage\b.+console/, out)
|
21
|
+
assert err.empty?, 'there should be no errors'
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'should run without args' do
|
25
25
|
_out, _err = capture_io do
|
26
26
|
@prompt = @command.new.run
|
27
27
|
end
|
@@ -33,21 +33,21 @@ describe ::Inch::CLI::Command::Console do
|
|
33
33
|
assert @prompt.objects.empty?
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should run with a definitive object name' do
|
37
37
|
_out, _err = capture_io do
|
38
|
-
@prompt = @command.new.run(
|
38
|
+
@prompt = @command.new.run('Foo::Bar#method_with_full_doc')
|
39
39
|
end
|
40
40
|
assert !@prompt.all.empty?
|
41
|
-
assert !@prompt.ff(
|
42
|
-
assert !@prompt.f(
|
41
|
+
assert !@prompt.ff('Foo::Bar#').empty?
|
42
|
+
assert !@prompt.f('Foo::Bar').nil?
|
43
43
|
assert !@prompt.o.nil?
|
44
44
|
refute @prompt.o.nil?
|
45
45
|
assert_equal 1, @prompt.objects.size
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it 'should run with a partial name' do
|
49
49
|
_out, _err = capture_io do
|
50
|
-
@prompt = @command.new.run(
|
50
|
+
@prompt = @command.new.run('Foo::Bar#')
|
51
51
|
end
|
52
52
|
assert @prompt.respond_to?(:all)
|
53
53
|
assert @prompt.respond_to?(:ff)
|
@@ -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
|
require 'tmpdir'
|
4
4
|
require 'fileutils'
|
@@ -23,40 +23,38 @@ describe ::Inch::CLI::Command::Diff do
|
|
23
23
|
FileUtils.rm_rf @tmp_dir
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should not show any changes' do
|
27
27
|
# this runs `inch diff` on a freshly cloned repo
|
28
28
|
# should not show any changes
|
29
29
|
out, err = capture_io do
|
30
30
|
@command.run
|
31
31
|
end
|
32
|
-
refute out.empty?,
|
33
|
-
assert err.empty?,
|
34
|
-
assert_match
|
35
|
-
|
32
|
+
refute out.empty?, 'there should be some output'
|
33
|
+
assert err.empty?, 'there should be no errors'
|
34
|
+
assert_match(/\bno changes\b/i, out)
|
36
35
|
|
37
36
|
# this runs `inch diff` on two distinct revisions
|
38
37
|
# should show some changes
|
39
38
|
out, err = capture_io do
|
40
39
|
@command.run(@git_rev1, @git_rev2)
|
41
40
|
end
|
42
|
-
refute out.empty?,
|
43
|
-
assert err.empty?,
|
44
|
-
assert_match
|
45
|
-
|
41
|
+
refute out.empty?, 'there should be some output'
|
42
|
+
assert err.empty?, 'there should be no errors'
|
43
|
+
assert_match(/\bshowing changes\b/i, out)
|
46
44
|
|
47
45
|
# we now remove all comments in a single file
|
48
46
|
filename = File.join(@cloned_dir, 'lib/sparkr.rb')
|
49
47
|
content = File.read(filename)
|
50
48
|
content_without_comments = content.gsub(/\s+#(.+)/, '')
|
51
|
-
File.open(filename, 'w') {|f| f.write(content_without_comments) }
|
49
|
+
File.open(filename, 'w') { |f| f.write(content_without_comments) }
|
52
50
|
|
53
51
|
# running the standard `inch diff` again
|
54
52
|
# should now show some changes
|
55
53
|
out, err = capture_io do
|
56
54
|
@command.run
|
57
55
|
end
|
58
|
-
refute out.empty?,
|
59
|
-
assert err.empty?,
|
60
|
-
assert_match
|
56
|
+
refute out.empty?, 'there should be some output'
|
57
|
+
assert err.empty?, 'there should be no errors'
|
58
|
+
assert_match(/\bshowing changes\b/i, out)
|
61
59
|
end
|
62
60
|
end
|
@@ -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::CLI::Command::Inspect do
|
4
4
|
before do
|
@@ -6,62 +6,62 @@ describe ::Inch::CLI::Command::Inspect do
|
|
6
6
|
@command = ::Inch::CLI::Command::Inspect
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'should warn and exit when run without args' do
|
10
10
|
out, err = capture_io do
|
11
11
|
assert_raises(SystemExit) { @command.run }
|
12
12
|
end
|
13
|
-
assert out.empty?,
|
14
|
-
refute err.empty?,
|
13
|
+
assert out.empty?, 'there should be no output'
|
14
|
+
refute err.empty?, 'there should be some error message'
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'should output info when run with --help' do
|
18
18
|
out, err = capture_io do
|
19
|
-
assert_raises(SystemExit) { @command.run(
|
19
|
+
assert_raises(SystemExit) { @command.run('--help') }
|
20
20
|
end
|
21
|
-
refute out.empty?,
|
22
|
-
assert_match
|
23
|
-
assert err.empty?,
|
21
|
+
refute out.empty?, 'there should be some output'
|
22
|
+
assert_match(/\bUsage\b.+inspect/, out)
|
23
|
+
assert err.empty?, 'there should be no errors'
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should output some info when run with a definitive object name' do
|
27
27
|
out, err = capture_io do
|
28
|
-
@command.run(
|
28
|
+
@command.run('Foo::Bar#method_with_full_doc', '--no-color')
|
29
29
|
end
|
30
|
-
refute out.empty?,
|
31
|
-
assert_match
|
30
|
+
refute out.empty?, 'there should be some output'
|
31
|
+
assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
|
32
32
|
refute_match(/\b Foo::Bar#method_without_doc\b/, out)
|
33
|
-
assert err.empty?,
|
33
|
+
assert err.empty?, 'there should be no errors'
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should output some info when run with a definitive object name' do
|
37
37
|
out, err = capture_io do
|
38
|
-
@command.run(
|
38
|
+
@command.run('Foo::Qux')
|
39
39
|
end
|
40
|
-
refute out.empty?,
|
41
|
-
assert err.empty?,
|
40
|
+
refute out.empty?, 'there should be some output'
|
41
|
+
assert err.empty?, 'there should be no errors'
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it 'should output all children info when run with a partial name' do
|
45
45
|
out, err = capture_io do
|
46
|
-
@command.run(
|
46
|
+
@command.run('Foo::Bar#', '--no-color')
|
47
47
|
end
|
48
|
-
refute out.empty?,
|
49
|
-
assert_match
|
50
|
-
assert_match
|
51
|
-
assert err.empty?,
|
48
|
+
refute out.empty?, 'there should be some output'
|
49
|
+
assert_match(/\bFoo::Bar#method_without_doc\b/, out)
|
50
|
+
assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
|
51
|
+
assert err.empty?, 'there should be no errors'
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it 'should output colored information' do
|
55
55
|
out, _err = capture_io do
|
56
|
-
@command.run(
|
56
|
+
@command.run('Foo::Bar#')
|
57
57
|
end
|
58
|
-
refute_equal out.uncolor, out,
|
58
|
+
refute_equal out.uncolor, out, 'should be colored'
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
61
|
+
it 'should output uncolored information when asked' do
|
62
62
|
out, _err = capture_io do
|
63
|
-
@command.run(
|
63
|
+
@command.run('Foo::Bar#', '--no-color')
|
64
64
|
end
|
65
|
-
assert_equal out.uncolor, out,
|
65
|
+
assert_equal out.uncolor, out, 'should not be colored'
|
66
66
|
end
|
67
67
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
2
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../shared/base_list')
|
3
3
|
|
4
4
|
describe ::Inch::CLI::Command::List do
|
5
5
|
before do
|
@@ -9,56 +9,56 @@ describe ::Inch::CLI::Command::List do
|
|
9
9
|
|
10
10
|
include Shared::BaseList
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'should run without args' do
|
13
13
|
out, err = capture_io do
|
14
14
|
@command.run
|
15
15
|
end
|
16
|
-
refute out.empty?,
|
17
|
-
assert err.empty?,
|
18
|
-
assert_match
|
19
|
-
assert_match
|
20
|
-
assert_match
|
21
|
-
assert_match
|
16
|
+
refute out.empty?, 'there should be some output'
|
17
|
+
assert err.empty?, 'there should be no errors'
|
18
|
+
assert_match(/\bFoo\b/, out)
|
19
|
+
assert_match(/\bFoo::Bar\b/, out)
|
20
|
+
assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
|
21
|
+
assert_match(/\bFoo::Bar#method_with_code_example\b/, out)
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'should run with --numbers switch' do
|
25
25
|
out, err = capture_io do
|
26
|
-
@command.run(
|
26
|
+
@command.run('--numbers')
|
27
27
|
end
|
28
|
-
refute out.empty?,
|
29
|
-
assert err.empty?,
|
30
|
-
assert_match
|
31
|
-
assert_match
|
32
|
-
assert_match
|
33
|
-
assert_match
|
28
|
+
refute out.empty?, 'there should be some output'
|
29
|
+
assert err.empty?, 'there should be no errors'
|
30
|
+
assert_match(/\bFoo\b/, out)
|
31
|
+
assert_match(/\bFoo::Bar\b/, out)
|
32
|
+
assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
|
33
|
+
assert_match(/\bFoo::Bar#method_with_code_example\b/, out)
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should run with filelist in args' do
|
37
37
|
out, err = capture_io do
|
38
|
-
@command.run(
|
38
|
+
@command.run('lib/**/*.rb', 'app/**/*.rb')
|
39
39
|
end
|
40
|
-
refute out.empty?,
|
41
|
-
assert err.empty?,
|
42
|
-
assert_match
|
43
|
-
assert_match
|
44
|
-
assert_match
|
45
|
-
assert_match
|
40
|
+
refute out.empty?, 'there should be some output'
|
41
|
+
assert err.empty?, 'there should be no errors'
|
42
|
+
assert_match(/\bFoo\b/, out)
|
43
|
+
assert_match(/\bFoo::Bar\b/, out)
|
44
|
+
assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
|
45
|
+
assert_match(/\bFoo::Bar#method_with_code_example\b/, out)
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it 'should run with non-existing filelist in args' do
|
49
49
|
out, err = capture_io do
|
50
|
-
@command.run(
|
50
|
+
@command.run('app/**/*.rb')
|
51
51
|
end
|
52
|
-
assert out.empty?,
|
53
|
-
assert err.empty?,
|
52
|
+
assert out.empty?, 'there should be no output'
|
53
|
+
assert err.empty?, 'there should be no errors'
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'should output info when run with --help' do
|
57
57
|
out, err = capture_io do
|
58
|
-
assert_raises(SystemExit) { @command.run(
|
58
|
+
assert_raises(SystemExit) { @command.run('--help') }
|
59
59
|
end
|
60
|
-
refute out.empty?,
|
61
|
-
assert_match
|
62
|
-
assert err.empty?,
|
60
|
+
refute out.empty?, 'there should be some output'
|
61
|
+
assert_match(/\bUsage\b.+list/, out)
|
62
|
+
assert err.empty?, 'there should be no errors'
|
63
63
|
end
|
64
64
|
end
|
@@ -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::CLI::Command::Show do
|
4
4
|
before do
|
@@ -6,54 +6,54 @@ describe ::Inch::CLI::Command::Show do
|
|
6
6
|
@command = ::Inch::CLI::Command::Show
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'should warn and exit when run without args' do
|
10
10
|
out, err = capture_io do
|
11
11
|
assert_raises(SystemExit) { @command.run }
|
12
12
|
end
|
13
|
-
assert out.empty?,
|
14
|
-
refute err.empty?,
|
13
|
+
assert out.empty?, 'there should be no output'
|
14
|
+
refute err.empty?, 'there should be some error message'
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'should output info when run with --help' do
|
18
18
|
out, err = capture_io do
|
19
|
-
assert_raises(SystemExit) { @command.run(
|
19
|
+
assert_raises(SystemExit) { @command.run('--help') }
|
20
20
|
end
|
21
|
-
refute out.empty?,
|
22
|
-
assert_match
|
23
|
-
assert err.empty?,
|
21
|
+
refute out.empty?, 'there should be some output'
|
22
|
+
assert_match(/\bUsage\b.+show/, out)
|
23
|
+
assert err.empty?, 'there should be no errors'
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should output some info when run with a definitive object name' do
|
27
27
|
out, err = capture_io do
|
28
|
-
@command.run(
|
28
|
+
@command.run('Foo::Bar#method_with_full_doc', '--no-color')
|
29
29
|
end
|
30
|
-
refute out.empty?,
|
31
|
-
assert_match
|
30
|
+
refute out.empty?, 'there should be some output'
|
31
|
+
assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
|
32
32
|
refute_match(/\b Foo::Bar#method_without_doc\b/, out)
|
33
|
-
assert err.empty?,
|
33
|
+
assert err.empty?, 'there should be no errors'
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should output all children info when run with a partial name' do
|
37
37
|
out, err = capture_io do
|
38
|
-
@command.run(
|
38
|
+
@command.run('Foo::Bar#', '--no-color')
|
39
39
|
end
|
40
|
-
refute out.empty?,
|
41
|
-
assert_match
|
42
|
-
assert_match
|
43
|
-
assert err.empty?,
|
40
|
+
refute out.empty?, 'there should be some output'
|
41
|
+
assert_match(/\bFoo::Bar#method_without_doc\b/, out)
|
42
|
+
assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
|
43
|
+
assert err.empty?, 'there should be no errors'
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it 'should output colored information' do
|
47
47
|
out, _err = capture_io do
|
48
|
-
@command.run(
|
48
|
+
@command.run('Foo::Bar#')
|
49
49
|
end
|
50
|
-
refute_equal out.uncolor, out,
|
50
|
+
refute_equal out.uncolor, out, 'should be colored'
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
53
|
+
it 'should output uncolored information when asked' do
|
54
54
|
out, _err = capture_io do
|
55
|
-
@command.run(
|
55
|
+
@command.run('Foo::Bar#', '--no-color')
|
56
56
|
end
|
57
|
-
assert_equal out.uncolor, out,
|
57
|
+
assert_equal out.uncolor, out, 'should not be colored'
|
58
58
|
end
|
59
59
|
end
|
@@ -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::CLI::Command::Stats do
|
4
4
|
before do
|
@@ -6,52 +6,52 @@ describe ::Inch::CLI::Command::Stats do
|
|
6
6
|
@command = ::Inch::CLI::Command::Stats
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'should run without args' do
|
10
10
|
out, err = capture_io do
|
11
11
|
@command.run
|
12
12
|
end
|
13
|
-
refute out.empty?,
|
14
|
-
assert err.empty?,
|
13
|
+
refute out.empty?, 'there should be some output'
|
14
|
+
assert err.empty?, 'there should be no errors'
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'should run with filelist in args' do
|
18
18
|
out, err = capture_io do
|
19
|
-
@command.run(
|
19
|
+
@command.run('lib/**/*.rb', 'app/**/*.rb')
|
20
20
|
end
|
21
|
-
refute out.empty?,
|
22
|
-
assert err.empty?,
|
21
|
+
refute out.empty?, 'there should be some output'
|
22
|
+
assert err.empty?, 'there should be no errors'
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it 'should run even with non-existing filelist in args' do
|
26
26
|
out, err = capture_io do
|
27
|
-
@command.run(
|
27
|
+
@command.run('app/**/*.rb')
|
28
28
|
end
|
29
|
-
refute out.empty?,
|
30
|
-
assert err.empty?,
|
29
|
+
refute out.empty?, 'there should be some output'
|
30
|
+
assert err.empty?, 'there should be no errors'
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'should output info when run with --format=json' do
|
34
34
|
out, err = capture_io do
|
35
|
-
@command.run(
|
35
|
+
@command.run('--format=json')
|
36
36
|
end
|
37
|
-
refute out.empty?,
|
37
|
+
refute out.empty?, 'there should be some output'
|
38
38
|
assert err.empty?, "there should be no errors: #{err.yellow}"
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it 'should output info when run with --format=yaml' do
|
42
42
|
out, err = capture_io do
|
43
|
-
@command.run(
|
43
|
+
@command.run('--format=yaml')
|
44
44
|
end
|
45
|
-
refute out.empty?,
|
45
|
+
refute out.empty?, 'there should be some output'
|
46
46
|
assert err.empty?, "there should be no errors: #{err.yellow}"
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it 'should output info when run with --help' do
|
50
50
|
out, err = capture_io do
|
51
|
-
assert_raises(SystemExit) { @command.run(
|
51
|
+
assert_raises(SystemExit) { @command.run('--help') }
|
52
52
|
end
|
53
|
-
refute out.empty?,
|
54
|
-
assert_match
|
55
|
-
assert err.empty?,
|
53
|
+
refute out.empty?, 'there should be some output'
|
54
|
+
assert_match(/\bUsage\b.+stats/, out)
|
55
|
+
assert err.empty?, 'there should be no errors'
|
56
56
|
end
|
57
57
|
end
|