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
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require 'simplecov'
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'bundler'
|
7
7
|
Bundler.require
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require 'inch'
|
9
|
+
require 'inch/cli'
|
10
10
|
|
11
11
|
def assert_roles(object, expected, unexpected)
|
12
12
|
roles = object.roles.map(&:class)
|
@@ -29,7 +29,7 @@ def find_roles(object, role_class, object_name = nil)
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def fixture_path(language, name)
|
32
|
-
File.join(File.dirname(__FILE__),
|
32
|
+
File.join(File.dirname(__FILE__), 'fixtures', language.to_s, name.to_s)
|
33
33
|
end
|
34
34
|
|
35
35
|
module Inch
|
@@ -43,13 +43,21 @@ module Inch
|
|
43
43
|
|
44
44
|
def object_provider(language, name)
|
45
45
|
self.object_providers ||= {}
|
46
|
-
self.object_providers[name] ||=
|
46
|
+
self.object_providers[name] ||=
|
47
|
+
::Inch::CodeObject::Provider.parse(fixture_path(language, name))
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
def test_codebase(name)
|
53
|
-
codebase = Inch::Test.codebase(
|
53
|
+
def test_codebase(language, name)
|
54
|
+
codebase = Inch::Test.codebase(language, name)
|
54
55
|
codebase
|
55
56
|
end
|
57
|
+
|
58
|
+
def fresh_codebase(language, name, read_dump_file = nil)
|
59
|
+
dir = fixture_path(language, name)
|
60
|
+
config = Inch::Config.for(language, dir).codebase
|
61
|
+
config.read_dump_file = read_dump_file
|
62
|
+
::Inch::Codebase.parse(dir, config)
|
63
|
+
end
|
@@ -1,48 +1,48 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::API::Filter do
|
4
4
|
before do
|
5
|
-
@codebase = test_codebase(:simple)
|
5
|
+
@codebase = test_codebase(:ruby, :simple)
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should work' do
|
9
9
|
@options = {}
|
10
10
|
@context = ::Inch::API::Filter.new @codebase, @options
|
11
11
|
refute @context.objects.empty?
|
12
12
|
refute @context.grade_lists.empty?
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should work with option: visibility == :public' do
|
16
16
|
@options = { visibility: [:public] }
|
17
17
|
@context = ::Inch::API::Filter.new @codebase, @options
|
18
18
|
assert @context.objects.all? { |o| o.public? }
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
21
|
+
it 'should work with option: visibility == :protected' do
|
22
22
|
@options = { visibility: [:protected] }
|
23
23
|
@context = ::Inch::API::Filter.new @codebase, @options
|
24
24
|
assert @context.objects.all? { |o| o.protected? }
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'should work with option: visibility == :private' do
|
28
28
|
@options = { visibility: [:private] }
|
29
29
|
@context = ::Inch::API::Filter.new @codebase, @options
|
30
30
|
assert @context.objects.all? { |o| o.private? || o.tagged_as_private? }
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'should work with option: namespaces == :only' do
|
34
34
|
@options = { namespaces: :only }
|
35
35
|
@context = ::Inch::API::Filter.new @codebase, @options
|
36
36
|
assert @context.objects.all? { |o| o.namespace? }
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it 'should work with option: undocumented == :only' do
|
40
40
|
@options = { undocumented: :only }
|
41
41
|
@context = ::Inch::API::Filter.new @codebase, @options
|
42
42
|
assert @context.objects.all? { |o| o.undocumented? }
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'should work with option: depth == 2' do
|
46
46
|
@options = { depth: 2 }
|
47
47
|
@context = ::Inch::API::Filter.new @codebase, @options
|
48
48
|
refute @context.objects.any? { |o| o.depth > 2 }
|
data/test/unit/api/get_test.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::API::Get do
|
4
4
|
before do
|
5
|
-
@codebase = test_codebase(:simple)
|
5
|
+
@codebase = test_codebase(:ruby, :simple)
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
@object_names = [
|
8
|
+
it 'should work' do
|
9
|
+
@object_names = ['Foo', 'Foo::Bar']
|
10
10
|
@context = ::Inch::API::Get.new @codebase, @object_names
|
11
11
|
assert_equal 2, @context.objects.size
|
12
12
|
refute @context.object.nil?
|
13
13
|
refute @context.grade_lists.empty?
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
@object_names = [
|
16
|
+
it 'should work with wildcard' do
|
17
|
+
@object_names = ['Foo', 'Foo::Bar#']
|
18
18
|
@context = ::Inch::API::Get.new @codebase, @object_names
|
19
19
|
assert @context.objects.size > 2
|
20
20
|
end
|
data/test/unit/api/list_test.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::API::List do
|
4
4
|
before do
|
5
|
-
@codebase = test_codebase(:simple)
|
5
|
+
@codebase = test_codebase(:ruby, :simple)
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should work' do
|
9
9
|
@options = {}
|
10
10
|
@context = ::Inch::API::List.new @codebase, @options
|
11
11
|
refute @context.objects.empty?
|
@@ -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::API::Options::Base do
|
4
4
|
class APIOptionsTest < ::Inch::API::Options::Base
|
@@ -7,20 +7,20 @@ describe ::Inch::API::Options::Base do
|
|
7
7
|
attribute :qux
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
11
|
-
@options_hash = { foo:
|
10
|
+
it 'should work with a Hash or Struct' do
|
11
|
+
@options_hash = { foo: 'foo', baz: 42 }
|
12
12
|
@options_struct = OpenStruct.new(@options_hash)
|
13
13
|
|
14
14
|
@options1 = APIOptionsTest.new @options_hash
|
15
15
|
@options2 = APIOptionsTest.new @options_struct
|
16
16
|
|
17
|
-
assert_equal
|
18
|
-
assert_equal
|
17
|
+
assert_equal 'foo', @options1.foo
|
18
|
+
assert_equal 'foo', @options2.foo
|
19
19
|
assert_equal 42, @options1.baz
|
20
20
|
assert_equal 42, @options2.baz
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'should return default values' do
|
24
24
|
@options_hash = { baz: 42 }
|
25
25
|
@options = APIOptionsTest.new @options_hash
|
26
26
|
|
data/test/unit/api/stats_test.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::API::Stats do
|
4
4
|
before do
|
5
|
-
@codebase = test_codebase(:simple)
|
5
|
+
@codebase = test_codebase(:ruby, :simple)
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should work' do
|
9
9
|
@options = {}
|
10
10
|
@context = ::Inch::API::Stats.new @codebase, @options
|
11
11
|
refute @context.objects.empty?
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
2
|
|
3
3
|
describe ::Inch::API::Suggest do
|
4
4
|
before do
|
5
|
-
@codebase = test_codebase(:simple)
|
5
|
+
@codebase = test_codebase(:ruby, :simple)
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should work' do
|
9
9
|
@options = {}
|
10
10
|
@context = ::Inch::API::Suggest.new @codebase, @options
|
11
11
|
refute @context.objects.empty?
|
12
12
|
refute @context.grade_lists.empty?
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should work with option: object_count' do
|
16
16
|
@options = { object_count: 10 }
|
17
17
|
@context = ::Inch::API::Suggest.new @codebase, @options
|
18
18
|
|
@@ -1,70 +1,70 @@
|
|
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::Arguments do
|
4
4
|
before do
|
5
5
|
Dir.chdir fixture_path(:ruby, :simple)
|
6
|
-
assert File.file?(
|
6
|
+
assert File.file?('README')
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'should run with files' do
|
10
10
|
args = [
|
11
|
-
|
11
|
+
'lib/**/*.rb', 'app/**/*.rb', 'README'
|
12
12
|
]
|
13
13
|
arguments = ::Inch::CLI::Arguments.new(args)
|
14
|
-
assert_equal [
|
14
|
+
assert_equal ['lib/**/*.rb', 'app/**/*.rb', 'README'], arguments.files
|
15
15
|
assert_equal [], arguments.object_names
|
16
16
|
assert_equal [], arguments.switches
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'should run with directories as well' do
|
20
20
|
args = [
|
21
|
-
|
21
|
+
'lib', 'app/**/*.rb', 'README'
|
22
22
|
]
|
23
23
|
arguments = ::Inch::CLI::Arguments.new(args)
|
24
|
-
assert_equal [
|
24
|
+
assert_equal ['lib', 'app/**/*.rb', 'README'], arguments.files
|
25
25
|
assert_equal [], arguments.object_names
|
26
26
|
assert_equal [], arguments.switches
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'should run with files and object_name' do
|
30
30
|
args = [
|
31
|
-
|
31
|
+
'{app,lib}.rb', 'README', 'Foo'
|
32
32
|
]
|
33
33
|
arguments = ::Inch::CLI::Arguments.new(args)
|
34
|
-
assert_equal [
|
35
|
-
assert_equal [
|
34
|
+
assert_equal ['{app,lib}.rb', 'README'], arguments.files
|
35
|
+
assert_equal ['Foo'], arguments.object_names
|
36
36
|
assert_equal [], arguments.switches
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it 'should run with object_names' do
|
40
40
|
args = [
|
41
|
-
|
41
|
+
'Foo::Bar'
|
42
42
|
]
|
43
43
|
arguments = ::Inch::CLI::Arguments.new(args)
|
44
|
-
assert_equal [], arguments.files,
|
45
|
-
assert_equal [
|
44
|
+
assert_equal [], arguments.files, 'files'
|
45
|
+
assert_equal ['Foo::Bar'], arguments.object_names
|
46
46
|
assert_equal [], arguments.switches
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it 'should run with option switches' do
|
50
50
|
args = [
|
51
|
-
|
51
|
+
'--no-color', '--all'
|
52
52
|
]
|
53
53
|
arguments = ::Inch::CLI::Arguments.new(args)
|
54
54
|
assert_equal [], arguments.files
|
55
55
|
assert_equal [], arguments.object_names
|
56
|
-
assert_equal [
|
56
|
+
assert_equal ['--no-color', '--all'], arguments.switches
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it 'should run with all of them' do
|
60
60
|
args = [
|
61
|
-
|
62
|
-
|
61
|
+
'lib/**/*.rb', 'app/**/*.rb', 'README',
|
62
|
+
'Foo', 'Foo::Bar', '--no-color', '--all'
|
63
63
|
]
|
64
64
|
arguments = ::Inch::CLI::Arguments.new(args)
|
65
|
-
assert_equal [
|
66
|
-
assert_equal [
|
67
|
-
assert_equal [
|
65
|
+
assert_equal ['lib/**/*.rb', 'app/**/*.rb', 'README'], arguments.files
|
66
|
+
assert_equal ['Foo', 'Foo::Bar'], arguments.object_names
|
67
|
+
assert_equal ['--no-color', '--all'], arguments.switches
|
68
68
|
end
|
69
69
|
|
70
70
|
end
|
@@ -1,15 +1,15 @@
|
|
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::Console do
|
4
4
|
before do
|
5
5
|
@command = ::Inch::CLI::Command::Base.new
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should implement some defaults' do
|
9
9
|
assert @command.name
|
10
10
|
assert @command.usage
|
11
11
|
assert @command.description
|
12
12
|
|
13
|
-
assert_raises(NotImplementedError) { @command.run(
|
13
|
+
assert_raises(NotImplementedError) { @command.run('something') }
|
14
14
|
end
|
15
15
|
end
|
@@ -1,9 +1,9 @@
|
|
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::Options::BaseList do
|
4
|
-
it
|
4
|
+
it 'should run parse without errors' do
|
5
5
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
6
|
-
@options.parse([
|
6
|
+
@options.parse(['--no-color'])
|
7
7
|
assert_equal false, @options.show_all?
|
8
8
|
assert_equal [:public, :protected], @options.visibility
|
9
9
|
assert @options.namespaces.nil?
|
@@ -11,39 +11,39 @@ describe ::Inch::CLI::Command::Options::BaseList do
|
|
11
11
|
assert @options.depth.nil?
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'should run parse twice without affecting the second run' do
|
15
15
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
16
|
-
@options.parse([
|
16
|
+
@options.parse(['--no-public', '--no-protected', '--private'])
|
17
17
|
assert_equal [:private], @options.visibility
|
18
18
|
|
19
19
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
20
|
-
@options.parse([
|
20
|
+
@options.parse(['--no-color'])
|
21
21
|
assert_equal [:public, :protected], @options.visibility
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'should interpret --all options' do
|
25
25
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
26
|
-
@options.parse([
|
26
|
+
@options.parse(['--all'])
|
27
27
|
assert_equal true, @options.show_all?
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it 'should interpret visibility options' do
|
31
31
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
32
|
-
@options.parse([
|
32
|
+
@options.parse(['--no-public', '--no-protected', '--private'])
|
33
33
|
assert_equal [:private], @options.visibility
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should interpret options' do
|
37
37
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
38
|
-
@options.parse([
|
38
|
+
@options.parse(['--no-namespaces', '--no-undocumented', '--depth=2'])
|
39
39
|
assert_equal :none, @options.namespaces
|
40
40
|
assert_equal :none, @options.undocumented
|
41
41
|
assert_equal 2, @options.depth
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it 'should interpret other options' do
|
45
45
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
46
|
-
@options.parse([
|
46
|
+
@options.parse(['--only-namespaces', '--only-undocumented'])
|
47
47
|
assert_equal :only, @options.namespaces
|
48
48
|
assert_equal :only, @options.undocumented
|
49
49
|
end
|
@@ -1,14 +1,14 @@
|
|
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::Options::BaseObject do
|
4
|
-
it
|
4
|
+
it 'should run parse without errors' do
|
5
5
|
@options = ::Inch::CLI::Command::Options::BaseObject.new
|
6
|
-
@options.parse([
|
6
|
+
@options.parse(['--no-color'])
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'should interpret options' do
|
10
10
|
@options = ::Inch::CLI::Command::Options::BaseObject.new
|
11
|
-
@options.parse([
|
12
|
-
assert_equal [
|
11
|
+
@options.parse(['Foo', 'Foo::Bar', '--no-color'])
|
12
|
+
assert_equal ['Foo', 'Foo::Bar'], @options.object_names
|
13
13
|
end
|
14
14
|
end
|
@@ -1,8 +1,8 @@
|
|
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::Options::Base do
|
4
|
-
it
|
4
|
+
it 'should run parse without errors' do
|
5
5
|
@options = ::Inch::CLI::Command::Options::Base.new
|
6
|
-
@options.parse([
|
6
|
+
@options.parse(['--no-color'])
|
7
7
|
end
|
8
8
|
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::CommandParser do
|
4
4
|
before do
|
@@ -6,66 +6,66 @@ describe ::Inch::CLI::CommandParser do
|
|
6
6
|
@command_parser = ::Inch::CLI::CommandParser
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'should run without args' do
|
10
10
|
out, err = capture_io do
|
11
11
|
@command = @command_parser.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
|
assert_equal ::Inch::CLI::Command::Suggest, @command.class
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'should run Command::Suggest with filelist in args' do
|
19
19
|
out, err = capture_io do
|
20
|
-
@command = @command_parser.run(
|
20
|
+
@command = @command_parser.run('suggest', 'lib/**/*.rb', 'app/**/*.rb')
|
21
21
|
end
|
22
|
-
refute out.empty?,
|
23
|
-
assert err.empty?,
|
22
|
+
refute out.empty?, 'there should be some output'
|
23
|
+
assert err.empty?, 'there should be no errors'
|
24
24
|
assert_equal ::Inch::CLI::Command::Suggest, @command.class
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'should run Command::Suggest with only filelist in args' do
|
28
28
|
out, err = capture_io do
|
29
|
-
@command = @command_parser.run(
|
29
|
+
@command = @command_parser.run('lib/**/*.rb', 'app/**/*.rb')
|
30
30
|
end
|
31
|
-
refute out.empty?,
|
32
|
-
assert err.empty?,
|
31
|
+
refute out.empty?, 'there should be some output'
|
32
|
+
assert err.empty?, 'there should be no errors'
|
33
33
|
assert_equal ::Inch::CLI::Command::Suggest, @command.class
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should run Command::Suggest with only switches in args' do
|
37
37
|
out, err = capture_io do
|
38
|
-
@command = @command_parser.run(
|
38
|
+
@command = @command_parser.run('--no-color')
|
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
|
assert_equal ::Inch::CLI::Command::Suggest, @command.class
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'should run Command::List with filelist in args' do
|
46
46
|
out, err = capture_io do
|
47
|
-
@command = @command_parser.run(
|
47
|
+
@command = @command_parser.run('list', 'lib/**/*.rb', 'app/**/*.rb')
|
48
48
|
end
|
49
|
-
refute out.empty?,
|
50
|
-
assert err.empty?,
|
49
|
+
refute out.empty?, 'there should be some output'
|
50
|
+
assert err.empty?, 'there should be no errors'
|
51
51
|
assert_equal ::Inch::CLI::Command::List, @command.class
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it 'should run Command::Show with filelist in args' do
|
55
55
|
out, err = capture_io do
|
56
|
-
@command = @command_parser.run(
|
56
|
+
@command = @command_parser.run('show', 'Foo')
|
57
57
|
end
|
58
|
-
refute out.empty?,
|
59
|
-
assert err.empty?,
|
58
|
+
refute out.empty?, 'there should be some output'
|
59
|
+
assert err.empty?, 'there should be no errors'
|
60
60
|
assert_equal ::Inch::CLI::Command::Show, @command.class
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
63
|
+
it 'should output info when run with --help' do
|
64
64
|
out, err = capture_io do
|
65
|
-
@command = @command_parser.run(
|
65
|
+
@command = @command_parser.run('--help')
|
66
66
|
end
|
67
|
-
refute out.empty?,
|
68
|
-
assert_match
|
69
|
-
assert err.empty?,
|
67
|
+
refute out.empty?, 'there should be some output'
|
68
|
+
assert_match(/\bUsage\b.+inch/, out)
|
69
|
+
assert err.empty?, 'there should be no errors'
|
70
70
|
end
|
71
71
|
end
|