inch 0.2.3 → 0.3.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.simplecov +7 -0
- data/TODOS.md +0 -5
- data/config/defaults.rb +26 -1
- data/inch.gemspec +1 -0
- data/lib/inch.rb +2 -1
- data/lib/inch/api.rb +34 -0
- data/lib/inch/api/filter.rb +17 -0
- data/lib/inch/api/get.rb +30 -0
- data/lib/inch/api/list.rb +10 -0
- data/lib/inch/api/options/base.rb +45 -0
- data/lib/inch/api/options/filter.rb +25 -0
- data/lib/inch/api/options/suggest.rb +36 -0
- data/lib/inch/api/stats.rb +7 -0
- data/lib/inch/api/suggest.rb +110 -0
- data/lib/inch/cli.rb +4 -1
- data/lib/inch/cli/command/base.rb +1 -17
- data/lib/inch/cli/command/base_list.rb +3 -63
- data/lib/inch/cli/command/base_object.rb +6 -28
- data/lib/inch/cli/command/list.rb +3 -2
- data/lib/inch/cli/command/options/base.rb +1 -1
- data/lib/inch/cli/command/options/base_list.rb +4 -2
- data/lib/inch/cli/command/options/suggest.rb +9 -8
- data/lib/inch/cli/command/output/base.rb +9 -11
- data/lib/inch/cli/command/output/list.rb +2 -2
- data/lib/inch/cli/command/output/show.rb +2 -10
- data/lib/inch/cli/command/output/stats.rb +4 -3
- data/lib/inch/cli/command/output/suggest.rb +5 -5
- data/lib/inch/cli/command/stats.rb +4 -3
- data/lib/inch/cli/command/suggest.rb +4 -94
- data/lib/inch/code_object.rb +2 -2
- data/lib/inch/code_object/converter.rb +89 -0
- data/lib/inch/code_object/provider.rb +36 -0
- data/lib/inch/code_object/provider/yard.rb +19 -0
- data/lib/inch/code_object/provider/yard/docstring.rb +106 -0
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +93 -0
- data/lib/inch/code_object/provider/yard/object.rb +55 -0
- data/lib/inch/code_object/provider/yard/object/base.rb +262 -0
- data/lib/inch/code_object/provider/yard/object/class_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/constant_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/method_object.rb +126 -0
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +88 -0
- data/lib/inch/code_object/provider/yard/object/module_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +47 -0
- data/lib/inch/code_object/provider/yard/parser.rb +54 -0
- data/lib/inch/code_object/proxy.rb +5 -3
- data/lib/inch/code_object/proxy/base.rb +103 -110
- data/lib/inch/code_object/proxy/class_object.rb +0 -1
- data/lib/inch/code_object/proxy/method_object.rb +20 -99
- data/lib/inch/code_object/proxy/method_parameter_object.rb +15 -39
- data/lib/inch/code_object/proxy/namespace_object.rb +7 -18
- data/lib/inch/codebase.rb +19 -0
- data/lib/inch/codebase/objects.rb +73 -0
- data/lib/inch/codebase/objects_filter.rb +61 -0
- data/lib/inch/codebase/proxy.rb +22 -0
- data/lib/inch/config.rb +8 -1
- data/lib/inch/evaluation.rb +5 -7
- data/lib/inch/evaluation/file.rb +1 -1
- data/lib/inch/evaluation/grade.rb +1 -1
- data/lib/inch/evaluation/object_schema.rb +3 -1
- data/lib/inch/evaluation/priority_range.rb +44 -0
- data/lib/inch/evaluation/proxy.rb +25 -0
- data/lib/inch/evaluation/proxy/base.rb +146 -0
- data/lib/inch/evaluation/proxy/class_object.rb +8 -0
- data/lib/inch/evaluation/proxy/constant_object.rb +19 -0
- data/lib/inch/evaluation/proxy/method_object.rb +65 -0
- data/lib/inch/evaluation/proxy/module_object.rb +8 -0
- data/lib/inch/evaluation/proxy/namespace_object.rb +27 -0
- data/lib/inch/evaluation/role/base.rb +19 -0
- data/lib/inch/evaluation/role/constant.rb +16 -0
- data/lib/inch/evaluation/role/method.rb +22 -0
- data/lib/inch/evaluation/role/method_parameter.rb +31 -1
- data/lib/inch/evaluation/role/namespace.rb +15 -0
- data/lib/inch/evaluation/role/object.rb +24 -0
- data/lib/inch/rake/suggest.rb +1 -0
- data/lib/inch/utils/read_write_methods.rb +44 -0
- data/lib/inch/{cli → utils}/weighted_list.rb +1 -1
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +8 -0
- data/test/inch/api/filter_test.rb +51 -0
- data/test/inch/api/get_test.rb +22 -0
- data/test/inch/api/list_test.rb +15 -0
- data/test/inch/api/options/base_test.rb +30 -0
- data/test/inch/api/stats_test.rb +15 -0
- data/test/inch/api/suggest_test.rb +26 -0
- data/test/inch/cli/command/list_test.rb +2 -1
- data/test/inch/code_object/converter_test.rb +29 -0
- data/test/inch/code_object/{docstring_test.rb → provider/yard/docstring_test.rb} +13 -13
- data/test/inch/code_object/{nodoc_helper_test.rb → provider/yard/nodoc_helper_test.rb} +6 -6
- data/test/inch/code_object/provider/yard_test.rb +11 -0
- data/test/inch/code_object/provider_test.rb +9 -0
- data/test/inch/code_object/proxy/method_object_test.rb +22 -22
- data/test/inch/code_object/proxy_test.rb +10 -10
- data/test/inch/codebase/objects_test.rb +28 -0
- data/test/inch/codebase/proxy_test.rb +17 -0
- data/test/inch/evaluation/role/base_test.rb +71 -0
- data/test/inch/{cli → utils}/weighted_list_test.rb +2 -2
- data/test/shared/base_list.rb +73 -0
- data/test/test_helper.rb +0 -95
- metadata +89 -24
- data/lib/inch/code_object/docstring.rb +0 -102
- data/lib/inch/code_object/nodoc_helper.rb +0 -107
- data/lib/inch/evaluation/base.rb +0 -157
- data/lib/inch/evaluation/class_object.rb +0 -6
- data/lib/inch/evaluation/constant_object.rb +0 -33
- data/lib/inch/evaluation/method_object.rb +0 -105
- data/lib/inch/evaluation/module_object.rb +0 -6
- data/lib/inch/evaluation/namespace_object.rb +0 -52
- data/lib/inch/evaluation/read_write_methods.rb +0 -21
- data/lib/inch/source_parser.rb +0 -62
- data/test/inch/source_parser_test.rb +0 -23
data/lib/inch/version.rb
CHANGED
@@ -7,6 +7,14 @@ module Foo
|
|
7
7
|
def method_with_wrong_param_tag(e)
|
8
8
|
|
9
9
|
end
|
10
|
+
|
11
|
+
# The problem here is that the @param tag does not describe the parameter
|
12
|
+
#
|
13
|
+
# @param [Encoding] e
|
14
|
+
# @return [String]
|
15
|
+
def method_with_empty_param_tag_text(e)
|
16
|
+
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
module YardError
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::API::Filter do
|
4
|
+
before do
|
5
|
+
@dir = fixture_path(:simple)
|
6
|
+
@codebase = ::Inch::Codebase.parse(@dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should work" do
|
10
|
+
@options = {}
|
11
|
+
@context = ::Inch::API::Filter.new @codebase, @options
|
12
|
+
refute @context.objects.empty?
|
13
|
+
refute @context.grade_lists.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should work with option: visibility == :public" do
|
17
|
+
@options = {:visibility => [:public]}
|
18
|
+
@context = ::Inch::API::Filter.new @codebase, @options
|
19
|
+
assert @context.objects.all? { |o| o.public? }
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should work with option: visibility == :protected" do
|
23
|
+
@options = {:visibility => [:protected]}
|
24
|
+
@context = ::Inch::API::Filter.new @codebase, @options
|
25
|
+
assert @context.objects.all? { |o| o.protected? }
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should work with option: visibility == :private" do
|
29
|
+
@options = {:visibility => [:private]}
|
30
|
+
@context = ::Inch::API::Filter.new @codebase, @options
|
31
|
+
assert @context.objects.all? { |o| o.private? || o.private_tag? }
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should work with option: namespaces == :only" do
|
35
|
+
@options = {:namespaces => :only}
|
36
|
+
@context = ::Inch::API::Filter.new @codebase, @options
|
37
|
+
assert @context.objects.all? { |o| o.namespace? }
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should work with option: undocumented == :only" do
|
41
|
+
@options = {:undocumented => :only}
|
42
|
+
@context = ::Inch::API::Filter.new @codebase, @options
|
43
|
+
assert @context.objects.all? { |o| o.undocumented? }
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should work with option: depth == 2" do
|
47
|
+
@options = {:depth => 2}
|
48
|
+
@context = ::Inch::API::Filter.new @codebase, @options
|
49
|
+
refute @context.objects.any? { |o| o.depth > 2 }
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::API::Get do
|
4
|
+
before do
|
5
|
+
@dir = fixture_path(:simple)
|
6
|
+
@codebase = ::Inch::Codebase.parse(@dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should work" do
|
10
|
+
@object_names = ["Foo", "Foo::Bar"]
|
11
|
+
@context = ::Inch::API::Get.new @codebase, @object_names
|
12
|
+
assert_equal 2, @context.objects.size
|
13
|
+
refute @context.object.nil?
|
14
|
+
refute @context.grade_lists.empty?
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should work with wildcard" do
|
18
|
+
@object_names = ["Foo", "Foo::Bar#"]
|
19
|
+
@context = ::Inch::API::Get.new @codebase, @object_names
|
20
|
+
assert @context.objects.size > 2
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::API::List do
|
4
|
+
before do
|
5
|
+
@dir = fixture_path(:simple)
|
6
|
+
@codebase = ::Inch::Codebase.parse(@dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should work" do
|
10
|
+
@options = {}
|
11
|
+
@context = ::Inch::API::List.new @codebase, @options
|
12
|
+
refute @context.objects.empty?
|
13
|
+
refute @context.grade_lists.empty?
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::API::Options::Base do
|
4
|
+
class APIOptionsTest < ::Inch::API::Options::Base
|
5
|
+
attribute :foo, :bar
|
6
|
+
attribute :baz
|
7
|
+
attribute :qux
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should work with a Hash or Struct" do
|
11
|
+
@options_hash = {:foo => "foo", :baz => 42}
|
12
|
+
@options_struct = OpenStruct.new(@options_hash)
|
13
|
+
|
14
|
+
@options1 = APIOptionsTest.new @options_hash
|
15
|
+
@options2 = APIOptionsTest.new @options_struct
|
16
|
+
|
17
|
+
assert_equal "foo", @options1.foo
|
18
|
+
assert_equal "foo", @options2.foo
|
19
|
+
assert_equal 42, @options1.baz
|
20
|
+
assert_equal 42, @options2.baz
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return default values" do
|
24
|
+
@options_hash = {:baz => 42}
|
25
|
+
@options = APIOptionsTest.new @options_hash
|
26
|
+
|
27
|
+
assert_equal :bar, @options.foo
|
28
|
+
assert_equal 42, @options.baz
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::API::Stats do
|
4
|
+
before do
|
5
|
+
@dir = fixture_path(:simple)
|
6
|
+
@codebase = ::Inch::Codebase.parse(@dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should work" do
|
10
|
+
@options = {}
|
11
|
+
@context = ::Inch::API::Stats.new @codebase, @options
|
12
|
+
refute @context.objects.empty?
|
13
|
+
refute @context.grade_lists.empty?
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::API::Suggest do
|
4
|
+
before do
|
5
|
+
@dir = fixture_path(:simple)
|
6
|
+
@codebase = ::Inch::Codebase.parse(@dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should work" do
|
10
|
+
@options = {}
|
11
|
+
@context = ::Inch::API::Suggest.new @codebase, @options
|
12
|
+
refute @context.objects.empty?
|
13
|
+
refute @context.grade_lists.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should work with option: object_count" do
|
17
|
+
@options = {:object_count => 10}
|
18
|
+
@context = ::Inch::API::Suggest.new @codebase, @options
|
19
|
+
|
20
|
+
@options2 = {:object_count => 20}
|
21
|
+
@context2 = ::Inch::API::Suggest.new @codebase, @options2
|
22
|
+
|
23
|
+
assert_equal 10, @context.objects.size
|
24
|
+
assert_equal 20, @context2.objects.size
|
25
|
+
end
|
26
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../shared/base_list')
|
2
3
|
|
3
4
|
describe ::Inch::CLI::Command::List do
|
4
5
|
before do
|
@@ -6,7 +7,7 @@ describe ::Inch::CLI::Command::List do
|
|
6
7
|
@command = ::Inch::CLI::Command::List
|
7
8
|
end
|
8
9
|
|
9
|
-
include
|
10
|
+
include Shared::BaseList
|
10
11
|
|
11
12
|
it "should run without args" do
|
12
13
|
out, err = capture_io do
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::CodeObject::Converter do
|
4
|
+
class MockObject
|
5
|
+
def docstring
|
6
|
+
"Foo::Bar"
|
7
|
+
end
|
8
|
+
|
9
|
+
def parameters
|
10
|
+
[]
|
11
|
+
end
|
12
|
+
|
13
|
+
def public?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def private?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:object) { MockObject.new }
|
23
|
+
it "should parse all objects" do
|
24
|
+
attributes = ::Inch::CodeObject::Converter.to_hash(object)
|
25
|
+
assert_equal object.docstring, attributes[:docstring]
|
26
|
+
assert_equal object.public?, attributes[:public?]
|
27
|
+
assert_equal object.private?, attributes[:private?]
|
28
|
+
end
|
29
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
2
|
-
|
3
|
-
describe ::Inch::CodeObject::Docstring do
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
|
4
2
|
|
3
|
+
describe ::Inch::CodeObject::Provider::YARD::Docstring do
|
4
|
+
let(:described_class) { ::Inch::CodeObject::Provider::YARD::Docstring }
|
5
5
|
|
6
6
|
#
|
7
7
|
# loose TomDoc compatibility
|
@@ -20,7 +20,7 @@ param3 - Optional String mode (defaults to nil)
|
|
20
20
|
|
21
21
|
Returns Language or nil.
|
22
22
|
DOC
|
23
|
-
docstring =
|
23
|
+
docstring = described_class.new(text)
|
24
24
|
assert docstring.mentions_parameter?(:param1)
|
25
25
|
assert docstring.mentions_parameter?(:param2)
|
26
26
|
assert docstring.mentions_parameter?(:param3)
|
@@ -45,7 +45,7 @@ Examples
|
|
45
45
|
|
46
46
|
Returns the Lexer or nil if none was found.
|
47
47
|
DOC
|
48
|
-
docstring =
|
48
|
+
docstring = described_class.new(text)
|
49
49
|
assert docstring.mentions_parameter?(:param1)
|
50
50
|
assert docstring.describes_parameter?(:param1)
|
51
51
|
refute docstring.mentions_parameter?(:alias)
|
@@ -68,7 +68,7 @@ Examples
|
|
68
68
|
|
69
69
|
Returns the Lexer or nil if none was found.
|
70
70
|
DOC
|
71
|
-
docstring =
|
71
|
+
docstring = described_class.new(text)
|
72
72
|
assert docstring.mentions_parameter?(:param1)
|
73
73
|
assert docstring.describes_parameter?(:param1)
|
74
74
|
refute docstring.mentions_parameter?(:alias)
|
@@ -89,7 +89,7 @@ text = <<-DOC
|
|
89
89
|
Just because format_html is mentioned here, does not mean
|
90
90
|
the first parameter is mentioned.
|
91
91
|
DOC
|
92
|
-
docstring =
|
92
|
+
docstring = described_class.new(text)
|
93
93
|
refute docstring.mentions_parameter?(:format)
|
94
94
|
refute docstring.contains_code_example?
|
95
95
|
end
|
@@ -100,7 +100,7 @@ text = <<-DOC
|
|
100
100
|
Just because format is mentioned here, does not mean
|
101
101
|
the first parameter is meant.
|
102
102
|
DOC
|
103
|
-
docstring =
|
103
|
+
docstring = described_class.new(text)
|
104
104
|
refute docstring.mentions_parameter?(:format)
|
105
105
|
refute docstring.contains_code_example?
|
106
106
|
end
|
@@ -123,7 +123,7 @@ param1::
|
|
123
123
|
== Returns:
|
124
124
|
A string in the specified format.
|
125
125
|
DOC
|
126
|
-
docstring =
|
126
|
+
docstring = described_class.new(text)
|
127
127
|
refute docstring.contains_code_example?
|
128
128
|
end
|
129
129
|
|
@@ -138,7 +138,7 @@ Params:
|
|
138
138
|
+param2+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
139
139
|
+param3+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
140
140
|
DOC
|
141
|
-
docstring =
|
141
|
+
docstring = described_class.new(text)
|
142
142
|
assert docstring.contains_code_example?
|
143
143
|
assert docstring.mentions_parameter?(:param1)
|
144
144
|
assert docstring.mentions_parameter?(:param2)
|
@@ -156,7 +156,7 @@ the first parameter is mentioned.
|
|
156
156
|
method_with_code_example() # => some value
|
157
157
|
method_with_missing_param_doc(param1, param2, param3)
|
158
158
|
DOC
|
159
|
-
docstring =
|
159
|
+
docstring = described_class.new(text)
|
160
160
|
assert docstring.contains_code_example?
|
161
161
|
assert_equal 1, docstring.code_examples.size
|
162
162
|
end
|
@@ -174,7 +174,7 @@ param1::
|
|
174
174
|
== Returns:
|
175
175
|
A string in the specified format.
|
176
176
|
DOC
|
177
|
-
docstring =
|
177
|
+
docstring = described_class.new(text)
|
178
178
|
assert docstring.contains_code_example?
|
179
179
|
assert_equal 1, docstring.code_examples.size
|
180
180
|
assert docstring.mentions_parameter?(:param1)
|
@@ -199,7 +199,7 @@ param1::
|
|
199
199
|
== Returns:
|
200
200
|
A string in the specified format.
|
201
201
|
DOC
|
202
|
-
docstring =
|
202
|
+
docstring = described_class.new(text)
|
203
203
|
assert docstring.contains_code_example?
|
204
204
|
assert_equal 2, docstring.code_examples.size
|
205
205
|
assert docstring.code_examples.last.index("create_index! 2")
|
@@ -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
|
-
describe ::Inch::CodeObject::NodocHelper do
|
3
|
+
describe ::Inch::CodeObject::Provider::YARD::NodocHelper do
|
4
4
|
before do
|
5
|
-
|
6
|
-
@
|
5
|
+
@provider = ::Inch::CodeObject::Provider::YARD.parse(fixture_path(:simple), ["lib/**/*.rb"], [])
|
6
|
+
@objects = @provider.objects
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should return true for explicitly or implicitly tagged objects" do
|
@@ -19,7 +19,7 @@ describe ::Inch::CodeObject::NodocHelper do
|
|
19
19
|
"Foo::HiddenClassViaTag",
|
20
20
|
"Foo::HiddenClassViaTag#some_value",
|
21
21
|
].each do |query|
|
22
|
-
m = @
|
22
|
+
m = @objects.detect { |o| o.fullname == query }
|
23
23
|
assert m.nodoc?, "nodoc? should return true for #{query}"
|
24
24
|
end
|
25
25
|
end
|
@@ -32,7 +32,7 @@ describe ::Inch::CodeObject::NodocHelper do
|
|
32
32
|
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass",
|
33
33
|
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass#method_with_implicit_doc",
|
34
34
|
].each do |query|
|
35
|
-
m = @
|
35
|
+
m = @objects.detect { |o| o.fullname == query }
|
36
36
|
refute m.nodoc?, "nodoc? should return false for #{query}"
|
37
37
|
end
|
38
38
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::CodeObject::Provider::YARD do
|
4
|
+
let(:described_class) { ::Inch::CodeObject::Provider::YARD }
|
5
|
+
|
6
|
+
it "should parse" do
|
7
|
+
provider = described_class.parse(fixture_path(:simple), ["lib/**/*.rb"], [])
|
8
|
+
assert !provider.objects.empty?
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::CodeObject::Provider do
|
4
|
+
it "should parse all objects" do
|
5
|
+
Dir.chdir File.dirname(__FILE__)
|
6
|
+
@provider = ::Inch::CodeObject::Provider.parse(fixture_path(:simple), ["lib/**/*.rb"], [])
|
7
|
+
refute @provider.objects.empty?
|
8
|
+
end
|
9
|
+
end
|
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
|
3
3
|
describe ::Inch::CodeObject::Proxy::MethodObject do
|
4
4
|
before do
|
5
5
|
Dir.chdir fixture_path(:simple)
|
6
|
-
@
|
6
|
+
@codebase = Inch::Codebase.parse(fixture_path(:simple), ["lib/**/*.rb"])
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_method_without_doc
|
10
|
-
m = @
|
10
|
+
m = @codebase.objects.find("Foo::Bar#method_without_doc")
|
11
11
|
refute m.has_doc?
|
12
12
|
refute m.has_parameters?
|
13
13
|
refute m.return_mentioned?
|
@@ -17,7 +17,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_method_with_missing_param_doc
|
20
|
-
m = @
|
20
|
+
m = @codebase.objects.find("Foo::Bar#method_with_missing_param_doc")
|
21
21
|
assert m.has_doc?
|
22
22
|
assert m.has_parameters?
|
23
23
|
assert m.return_mentioned?
|
@@ -34,7 +34,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_method_with_wrong_doc
|
37
|
-
m = @
|
37
|
+
m = @codebase.objects.find("Foo::Bar#method_with_wrong_doc")
|
38
38
|
assert m.has_doc?
|
39
39
|
assert m.has_parameters?
|
40
40
|
assert m.return_mentioned?
|
@@ -57,7 +57,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_method_with_full_doc
|
60
|
-
m = @
|
60
|
+
m = @codebase.objects.find("Foo::Bar#method_with_full_doc")
|
61
61
|
assert m.has_doc?
|
62
62
|
assert m.has_parameters?
|
63
63
|
assert m.return_mentioned?
|
@@ -74,7 +74,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_method_without_params_or_return_type
|
77
|
-
m = @
|
77
|
+
m = @codebase.objects.find("Foo::Bar#method_without_params_or_return_type")
|
78
78
|
assert m.has_doc?
|
79
79
|
refute m.has_parameters?
|
80
80
|
refute m.return_mentioned?
|
@@ -83,7 +83,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_method_without_docstring
|
86
|
-
m = @
|
86
|
+
m = @codebase.objects.find("Foo::Bar#method_without_docstring")
|
87
87
|
refute m.has_doc?
|
88
88
|
assert m.has_parameters?
|
89
89
|
assert m.return_mentioned?
|
@@ -92,7 +92,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_method_without_params_or_docstring
|
95
|
-
m = @
|
95
|
+
m = @codebase.objects.find("Foo::Bar#method_without_params_or_docstring")
|
96
96
|
refute m.has_doc?
|
97
97
|
refute m.has_parameters?
|
98
98
|
assert m.return_mentioned?
|
@@ -101,7 +101,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_method_with_rdoc_doc
|
104
|
-
m = @
|
104
|
+
m = @codebase.objects.find("Foo::Bar#method_with_rdoc_doc")
|
105
105
|
assert m.has_doc?
|
106
106
|
assert m.has_parameters?
|
107
107
|
p = m.parameter(:param1)
|
@@ -112,7 +112,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def test_method_with_other_rdoc_doc
|
115
|
-
m = @
|
115
|
+
m = @codebase.objects.find("Foo::Bar#method_with_other_rdoc_doc")
|
116
116
|
assert m.has_doc?
|
117
117
|
assert m.has_parameters?
|
118
118
|
p = m.parameter(:param1)
|
@@ -127,7 +127,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_method_with_unstructured_doc
|
130
|
-
m = @
|
130
|
+
m = @codebase.objects.find("Foo::Bar#method_with_unstructured_doc")
|
131
131
|
assert m.has_doc?
|
132
132
|
assert m.has_parameters?
|
133
133
|
p = m.parameter(:param1)
|
@@ -138,7 +138,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def test_method_with_unstructured_doc_missing_params
|
141
|
-
m = @
|
141
|
+
m = @codebase.objects.find("Foo::Bar#method_with_unstructured_doc_missing_params")
|
142
142
|
assert m.has_doc?
|
143
143
|
assert m.has_parameters?
|
144
144
|
p = m.parameter(:format)
|
@@ -149,7 +149,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def test_question_mark_method
|
152
|
-
m = @
|
152
|
+
m = @codebase.objects.find("InchTest#question_mark_method?")
|
153
153
|
refute m.has_doc?
|
154
154
|
refute m.has_parameters?
|
155
155
|
|
@@ -157,7 +157,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def test_question_mark_method_with_description
|
160
|
-
m = @
|
160
|
+
m = @codebase.objects.find("InchTest#question_mark_method_with_description?")
|
161
161
|
refute m.has_doc?
|
162
162
|
refute m.has_parameters?
|
163
163
|
|
@@ -166,7 +166,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def test_method_with_description_and_parameters
|
169
|
-
m = @
|
169
|
+
m = @codebase.objects.find("InchTest#method_with_description_and_parameters?")
|
170
170
|
refute m.has_doc?
|
171
171
|
assert m.has_parameters?
|
172
172
|
|
@@ -174,43 +174,43 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def test_getter
|
177
|
-
m = @
|
177
|
+
m = @codebase.objects.find("InchTest#getter")
|
178
178
|
assert m.getter?, "should be a getter"
|
179
179
|
refute m.setter?
|
180
180
|
end
|
181
181
|
|
182
182
|
def test_setter
|
183
|
-
m = @
|
183
|
+
m = @codebase.objects.find("InchTest#attr_setter=")
|
184
184
|
refute m.getter?
|
185
185
|
assert m.setter?, "should be a setter"
|
186
186
|
end
|
187
187
|
|
188
188
|
def test_setter2
|
189
|
-
m = @
|
189
|
+
m = @codebase.objects.find("InchTest#manual_setter=")
|
190
190
|
refute m.getter?
|
191
191
|
assert m.setter?, "should be a setter"
|
192
192
|
end
|
193
193
|
|
194
194
|
def test_manual_getset
|
195
|
-
m = @
|
195
|
+
m = @codebase.objects.find("InchTest#manual_getset")
|
196
196
|
assert m.getter?, "should be a getter"
|
197
197
|
refute m.setter?
|
198
198
|
end
|
199
199
|
|
200
200
|
def test_manual_getset2
|
201
|
-
m = @
|
201
|
+
m = @codebase.objects.find("InchTest#manual_getset=")
|
202
202
|
refute m.getter?
|
203
203
|
assert m.setter?, "should be a setter"
|
204
204
|
end
|
205
205
|
|
206
206
|
def test_attr_getset
|
207
|
-
m = @
|
207
|
+
m = @codebase.objects.find("InchTest#attr_getset")
|
208
208
|
assert m.getter?, "should be a getter"
|
209
209
|
refute m.setter?
|
210
210
|
end
|
211
211
|
|
212
212
|
def test_attr_getset2
|
213
|
-
m = @
|
213
|
+
m = @codebase.objects.find("InchTest#attr_getset=")
|
214
214
|
refute m.getter?
|
215
215
|
assert m.setter?, "should be a setter"
|
216
216
|
end
|