yard 0.8.7.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +2 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +88 -6
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
- data/lib/yard/autoload.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/code_objects/base.rb +4 -1
- data/lib/yard/code_objects/extra_file_object.rb +3 -1
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/docstring.rb +11 -6
- data/lib/yard/handlers/base.rb +1 -2
- data/lib/yard/handlers/c/base.rb +19 -0
- data/lib/yard/handlers/c/handler_methods.rb +42 -8
- data/lib/yard/handlers/c/init_handler.rb +1 -1
- data/lib/yard/handlers/c/method_handler.rb +3 -3
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
- data/lib/yard/logging.rb +1 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
- data/lib/yard/parser/source_parser.rb +6 -6
- data/lib/yard/rake/yardoc_task.rb +2 -2
- data/lib/yard/serializers/file_system_serializer.rb +33 -1
- data/lib/yard/server/commands/display_file_command.rb +8 -3
- data/lib/yard/server/commands/display_object_command.rb +7 -3
- data/lib/yard/server/doc_server_helper.rb +2 -8
- data/lib/yard/server/doc_server_serializer.rb +2 -4
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
- data/lib/yard/tags/directives.rb +1 -0
- data/lib/yard/tags/library.rb +9 -7
- data/lib/yard/tags/overload_tag.rb +4 -1
- data/lib/yard/templates/helpers/html_helper.rb +4 -3
- data/lib/yard/templates/template_options.rb +3 -0
- data/lib/yard/version.rb +1 -1
- data/spec/cli/command_parser_spec.rb +14 -14
- data/spec/cli/command_spec.rb +11 -11
- data/spec/cli/config_spec.rb +32 -32
- data/spec/cli/diff_spec.rb +86 -90
- data/spec/cli/display_spec.rb +6 -6
- data/spec/cli/gems_spec.rb +28 -28
- data/spec/cli/graph_spec.rb +8 -8
- data/spec/cli/help_spec.rb +8 -8
- data/spec/cli/i18n_spec.rb +33 -37
- data/spec/cli/list_spec.rb +2 -2
- data/spec/cli/markup_types_spec.rb +3 -3
- data/spec/cli/server_spec.rb +74 -88
- data/spec/cli/stats_spec.rb +14 -14
- data/spec/cli/yardoc_spec.rb +316 -321
- data/spec/cli/yri_spec.rb +45 -45
- data/spec/code_objects/base_spec.rb +174 -173
- data/spec/code_objects/class_object_spec.rb +65 -65
- data/spec/code_objects/code_object_list_spec.rb +13 -11
- data/spec/code_objects/constants_spec.rb +68 -58
- data/spec/code_objects/extra_file_object_spec.rb +71 -59
- data/spec/code_objects/macro_object_spec.rb +64 -64
- data/spec/code_objects/method_object_spec.rb +80 -72
- data/spec/code_objects/module_object_spec.rb +47 -47
- data/spec/code_objects/namespace_object_spec.rb +51 -51
- data/spec/code_objects/proxy_spec.rb +54 -54
- data/spec/config_spec.rb +104 -104
- data/spec/core_ext/array_spec.rb +5 -5
- data/spec/core_ext/file_spec.rb +33 -33
- data/spec/core_ext/hash_spec.rb +5 -5
- data/spec/core_ext/insertion_spec.rb +18 -18
- data/spec/core_ext/module_spec.rb +6 -6
- data/spec/core_ext/string_spec.rb +17 -17
- data/spec/core_ext/symbol_hash_spec.rb +42 -39
- data/spec/docstring_parser_spec.rb +65 -65
- data/spec/docstring_spec.rb +137 -130
- data/spec/handlers/alias_handler_spec.rb +39 -39
- data/spec/handlers/attribute_handler_spec.rb +35 -35
- data/spec/handlers/base_spec.rb +60 -51
- data/spec/handlers/c/alias_handler_spec.rb +6 -6
- data/spec/handlers/c/attribute_handler_spec.rb +12 -12
- data/spec/handlers/c/class_handler_spec.rb +35 -22
- data/spec/handlers/c/constant_handler_spec.rb +24 -22
- data/spec/handlers/c/init_handler_spec.rb +10 -10
- data/spec/handlers/c/method_handler_spec.rb +150 -65
- data/spec/handlers/c/mixin_handler_spec.rb +5 -5
- data/spec/handlers/c/module_handler_spec.rb +27 -15
- data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
- data/spec/handlers/c/path_handler_spec.rb +8 -8
- data/spec/handlers/c/spec_helper.rb +10 -0
- data/spec/handlers/c/struct_handler_spec.rb +3 -3
- data/spec/handlers/class_condition_handler_spec.rb +18 -18
- data/spec/handlers/class_handler_spec.rb +97 -97
- data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -3
- data/spec/handlers/constant_handler_spec.rb +32 -29
- data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
- data/spec/handlers/dsl_handler_spec.rb +108 -109
- data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/exception_handler_spec.rb +23 -23
- data/spec/handlers/extend_handler_spec.rb +9 -9
- data/spec/handlers/legacy_base_spec.rb +60 -60
- data/spec/handlers/method_condition_handler_spec.rb +5 -5
- data/spec/handlers/method_handler_spec.rb +92 -92
- data/spec/handlers/mixin_handler_spec.rb +25 -25
- data/spec/handlers/module_function_handler_spec.rb +24 -24
- data/spec/handlers/module_handler_spec.rb +15 -15
- data/spec/handlers/private_class_method_handler_spec.rb +4 -48
- data/spec/handlers/private_constant_handler_spec.rb +8 -8
- data/spec/handlers/processor_spec.rb +12 -12
- data/spec/handlers/public_class_method_handler_spec.rb +10 -0
- data/spec/handlers/ruby/base_spec.rb +16 -16
- data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/handlers/visibility_handler_spec.rb +25 -21
- data/spec/handlers/yield_handler_spec.rb +28 -28
- data/spec/i18n/locale_spec.rb +16 -16
- data/spec/i18n/message_spec.rb +8 -8
- data/spec/i18n/messages_spec.rb +14 -14
- data/spec/i18n/pot_generator_spec.rb +32 -32
- data/spec/i18n/text_spec.rb +22 -22
- data/spec/logging_spec.rb +12 -12
- data/spec/options_spec.rb +56 -56
- data/spec/parser/base_spec.rb +9 -9
- data/spec/parser/c_parser_spec.rb +50 -50
- data/spec/parser/ruby/ast_node_spec.rb +7 -7
- data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
- data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
- data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
- data/spec/parser/source_parser_spec.rb +224 -224
- data/spec/parser/tag_parsing_spec.rb +6 -7
- data/spec/rake/yardoc_task_spec.rb +38 -48
- data/spec/registry_spec.rb +143 -143
- data/spec/registry_store_spec.rb +165 -165
- data/spec/rubygems/doc_manager_spec.rb +38 -38
- data/spec/serializers/file_system_serializer_spec.rb +53 -33
- data/spec/serializers/yardoc_serializer_spec.rb +15 -15
- data/spec/server/adapter_spec.rb +15 -15
- data/spec/server/commands/base_spec.rb +29 -29
- data/spec/server/commands/library_command_spec.rb +12 -12
- data/spec/server/commands/static_file_command_spec.rb +28 -28
- data/spec/server/doc_server_helper_spec.rb +8 -8
- data/spec/server/doc_server_serializer_spec.rb +23 -18
- data/spec/server/rack_adapter_spec.rb +6 -6
- data/spec/server/router_spec.rb +39 -39
- data/spec/server/static_caching_spec.rb +16 -16
- data/spec/server/webrick_servlet_spec.rb +6 -7
- data/spec/server_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -2
- data/spec/tags/default_factory_spec.rb +64 -64
- data/spec/tags/default_tag_spec.rb +5 -5
- data/spec/tags/directives_spec.rb +121 -121
- data/spec/tags/library_spec.rb +14 -14
- data/spec/tags/overload_tag_spec.rb +24 -24
- data/spec/tags/ref_tag_list_spec.rb +12 -12
- data/spec/templates/class_spec.rb +3 -3
- data/spec/templates/constant_spec.rb +4 -4
- data/spec/templates/engine_spec.rb +47 -48
- data/spec/templates/examples/class001.html +129 -101
- data/spec/templates/examples/class002.html +31 -27
- data/spec/templates/examples/method001.html +54 -47
- data/spec/templates/examples/method002.html +33 -28
- data/spec/templates/examples/method003.html +70 -64
- data/spec/templates/examples/method004.html +13 -9
- data/spec/templates/examples/method005.html +38 -32
- data/spec/templates/examples/module001.html +343 -339
- data/spec/templates/examples/module002.html +147 -124
- data/spec/templates/examples/module003.html +94 -81
- data/spec/templates/examples/module004.html +40 -33
- data/spec/templates/helpers/base_helper_spec.rb +91 -95
- data/spec/templates/helpers/html_helper_spec.rb +276 -279
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
- data/spec/templates/helpers/markup_helper_spec.rb +57 -57
- data/spec/templates/helpers/method_helper_spec.rb +20 -20
- data/spec/templates/helpers/shared_signature_examples.rb +33 -31
- data/spec/templates/helpers/text_helper_spec.rb +6 -6
- data/spec/templates/method_spec.rb +7 -7
- data/spec/templates/module_spec.rb +7 -7
- data/spec/templates/onefile_spec.rb +7 -7
- data/spec/templates/section_spec.rb +66 -69
- data/spec/templates/spec_helper.rb +1 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +158 -158
- data/spec/verifier_spec.rb +52 -52
- data/templates/default/fulldoc/html/css/full_list.css +32 -31
- data/templates/default/fulldoc/html/css/style.css +212 -77
- data/templates/default/fulldoc/html/frames.erb +6 -15
- data/templates/default/fulldoc/html/full_list.erb +14 -21
- data/templates/default/fulldoc/html/full_list_class.erb +1 -1
- data/templates/default/fulldoc/html/full_list_file.erb +6 -4
- data/templates/default/fulldoc/html/full_list_method.erb +8 -6
- data/templates/default/fulldoc/html/js/app.js +100 -76
- data/templates/default/fulldoc/html/js/full_list.js +170 -135
- data/templates/default/fulldoc/html/setup.rb +50 -7
- data/templates/default/layout/html/breadcrumb.erb +0 -2
- data/templates/default/layout/html/headers.erb +2 -1
- data/templates/default/layout/html/layout.erb +16 -10
- data/templates/default/layout/html/script_setup.erb +1 -2
- data/templates/default/layout/html/search.erb +7 -2
- data/templates/default/layout/html/setup.rb +16 -0
- data/templates/default/method/html/header.erb +7 -6
- data/templates/default/module/html/attribute_summary.erb +1 -1
- data/templates/default/module/html/box_info.erb +24 -18
- data/templates/default/module/html/constant_summary.erb +9 -11
- data/templates/default/module/html/item_summary.erb +1 -1
- data/templates/default/module/html/method_summary.erb +1 -1
- data/templates/guide/fulldoc/html/setup.rb +1 -1
- data/yard.gemspec +1 -2
- metadata +10 -7
- data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
- data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
- data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
data/spec/cli/yri_spec.rb
CHANGED
@@ -9,89 +9,89 @@ end
|
|
9
9
|
describe YARD::CLI::YRI do
|
10
10
|
before do
|
11
11
|
@yri = TestYRI.new
|
12
|
-
Registry.
|
12
|
+
allow(Registry).to receive(:load)
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
16
|
-
it "
|
17
|
-
@yri.
|
18
|
-
File.
|
19
|
-
File.
|
20
|
-
Registry.
|
21
|
-
Registry.
|
22
|
-
Registry.
|
15
|
+
describe "#find_object" do
|
16
|
+
it "uses cache if available" do
|
17
|
+
allow(@yri).to receive(:cache_object)
|
18
|
+
expect(File).to receive(:exist?).with('.yardoc').and_return(false)
|
19
|
+
expect(File).to receive(:exist?).with('bar.yardoc').and_return(true)
|
20
|
+
expect(Registry).to receive(:load).with('bar.yardoc')
|
21
|
+
expect(Registry).to receive(:at).ordered.with('Foo').and_return(nil)
|
22
|
+
expect(Registry).to receive(:at).ordered.with('Foo').and_return('OBJ')
|
23
23
|
@yri.instance_variable_set("@cache", {'Foo' => 'bar.yardoc'})
|
24
|
-
@yri.find_object('Foo').
|
24
|
+
expect(@yri.find_object('Foo')).to eq 'OBJ'
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
28
|
-
@yri.
|
29
|
-
File.
|
30
|
-
Registry.
|
31
|
-
Registry.
|
32
|
-
Registry.
|
27
|
+
it "never uses cache ahead of current directory's .yardoc" do
|
28
|
+
allow(@yri).to receive(:cache_object)
|
29
|
+
expect(File).to receive(:exist?).with('.yardoc').and_return(true)
|
30
|
+
expect(Registry).to receive(:load).with('.yardoc')
|
31
|
+
expect(Registry).to receive(:at).ordered.with('Foo').and_return(nil)
|
32
|
+
expect(Registry).to receive(:at).ordered.with('Foo').and_return('OBJ')
|
33
33
|
@yri.instance_variable_set("@cache", {'Foo' => 'bar.yardoc'})
|
34
|
-
@yri.find_object('Foo').
|
35
|
-
@yri.instance_variable_get("@search_paths")[0].
|
34
|
+
expect(@yri.find_object('Foo')).to eq 'OBJ'
|
35
|
+
expect(@yri.instance_variable_get("@search_paths")[0]).to eq '.yardoc'
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
it "
|
41
|
-
File.
|
39
|
+
describe "#cache_object" do
|
40
|
+
it "skips caching for Registry.yardoc_file" do
|
41
|
+
expect(File).not_to receive(:open).with(CLI::YRI::CACHE_FILE, 'w')
|
42
42
|
@yri.cache_object('Foo', Registry.yardoc_file)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
47
|
-
it "
|
46
|
+
describe "#initialize" do
|
47
|
+
it "loads search paths" do
|
48
48
|
path = %r{/\.yard/yri_search_paths$}
|
49
|
-
File.
|
50
|
-
File.
|
51
|
-
File.
|
49
|
+
expect(File).to receive(:file?).with(%r{/\.yard/yri_cache$}).and_return(false)
|
50
|
+
expect(File).to receive(:file?).with(path).and_return(true)
|
51
|
+
expect(File).to receive(:readlines).with(path).and_return(%w(line1 line2))
|
52
52
|
@yri = YARD::CLI::YRI.new
|
53
53
|
spaths = @yri.instance_variable_get("@search_paths")
|
54
|
-
spaths.
|
55
|
-
spaths.
|
54
|
+
expect(spaths).to include('line1')
|
55
|
+
expect(spaths).to include('line2')
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "uses DEFAULT_SEARCH_PATHS prior to other paths" do
|
59
59
|
YARD::CLI::YRI::DEFAULT_SEARCH_PATHS.push('foo', 'bar')
|
60
60
|
path = %r{/\.yard/yri_search_paths$}
|
61
|
-
File.
|
62
|
-
File.
|
63
|
-
File.
|
61
|
+
expect(File).to receive(:file?).with(%r{/\.yard/yri_cache$}).and_return(false)
|
62
|
+
expect(File).to receive(:file?).with(path).and_return(true)
|
63
|
+
expect(File).to receive(:readlines).with(path).and_return(%w(line1 line2))
|
64
64
|
@yri = YARD::CLI::YRI.new
|
65
65
|
spaths = @yri.instance_variable_get("@search_paths")
|
66
|
-
spaths[0,4].
|
66
|
+
expect(spaths[0,4]).to eq %w(foo bar line1 line2)
|
67
67
|
YARD::CLI::YRI::DEFAULT_SEARCH_PATHS.replace([])
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe
|
72
|
-
it "
|
71
|
+
describe "#run" do
|
72
|
+
it "searches for objects and print their documentation" do
|
73
73
|
obj = YARD::CodeObjects::ClassObject.new(:root, 'Foo')
|
74
|
-
@yri.
|
74
|
+
expect(@yri).to receive(:print_object).with(obj)
|
75
75
|
@yri.run('Foo')
|
76
76
|
Registry.clear
|
77
77
|
end
|
78
78
|
|
79
|
-
it "
|
80
|
-
@yri.
|
81
|
-
@yri.
|
79
|
+
it "prints usage if no object is provided" do
|
80
|
+
expect(@yri).to receive(:print_usage)
|
81
|
+
expect(@yri).to receive(:exit).with(1)
|
82
82
|
@yri.run('')
|
83
83
|
end
|
84
84
|
|
85
|
-
it "
|
86
|
-
STDERR.
|
87
|
-
@yri.
|
85
|
+
it "prints 'no documentation exists for object' if object is not found" do
|
86
|
+
expect(STDERR).to receive(:puts).with("No documentation for `Foo'")
|
87
|
+
expect(@yri).to receive(:exit).with(1)
|
88
88
|
@yri.run('Foo')
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
91
|
+
it "ensures output is serialized" do
|
92
92
|
obj = YARD::CodeObjects::ClassObject.new(:root, 'Foo')
|
93
|
-
|
94
|
-
|
93
|
+
allow(@yri).to receive(:test_stub) do
|
94
|
+
expect(@yri.instance_variable_get(:@serializer)).to receive(:serialize).once
|
95
95
|
end
|
96
96
|
@yri.run('Foo')
|
97
97
|
end
|
@@ -3,47 +3,46 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe YARD::CodeObjects::Base do
|
4
4
|
before { Registry.clear }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# end
|
6
|
+
it "does not allow empty object name" do
|
7
|
+
expect { Base.new(:root, '') }.to raise_error(ArgumentError)
|
8
|
+
end
|
10
9
|
|
11
|
-
it "
|
10
|
+
it "returns a unique instance of any registered object" do
|
12
11
|
obj = ClassObject.new(:root, :Me)
|
13
12
|
obj2 = ClassObject.new(:root, :Me)
|
14
|
-
obj.object_id.
|
13
|
+
expect(obj.object_id).to eq obj2.object_id
|
15
14
|
|
16
15
|
obj3 = ModuleObject.new(obj, :Too)
|
17
16
|
obj4 = CodeObjects::Base.new(obj3, :Hello)
|
18
17
|
obj4.parent = obj
|
19
18
|
|
20
19
|
obj5 = CodeObjects::Base.new(obj3, :hello)
|
21
|
-
obj4.object_id.
|
20
|
+
expect(obj4.object_id).not_to eq obj5.object_id
|
22
21
|
end
|
23
22
|
|
24
|
-
it "
|
25
|
-
ConstantObject.new(:root, "MYMODULE").
|
26
|
-
ModuleObject.new(:root, "MYMODULE").
|
27
|
-
ClassObject.new(:root, "MYMODULE").
|
28
|
-
YARD::Registry.at("MYMODULE").
|
23
|
+
it "creates a new object if cached object is not of the same class" do
|
24
|
+
expect(ConstantObject.new(:root, "MYMODULE")).to be_instance_of(ConstantObject)
|
25
|
+
expect(ModuleObject.new(:root, "MYMODULE")).to be_instance_of(ModuleObject)
|
26
|
+
expect(ClassObject.new(:root, "MYMODULE")).to be_instance_of(ClassObject)
|
27
|
+
expect(YARD::Registry.at("MYMODULE")).to be_instance_of(ClassObject)
|
29
28
|
end
|
30
29
|
|
31
|
-
it "
|
30
|
+
it "simplifies complex namespace paths" do
|
32
31
|
obj = ClassObject.new(:root, "A::B::C::D")
|
33
|
-
obj.name.
|
34
|
-
obj.path.
|
35
|
-
obj.namespace.
|
32
|
+
expect(obj.name).to eq :D
|
33
|
+
expect(obj.path).to eq "A::B::C::D"
|
34
|
+
expect(obj.namespace).to eq P("A::B::C")
|
36
35
|
end
|
37
36
|
|
38
37
|
# @bug gh-552
|
39
|
-
it "
|
38
|
+
it "simplifies complex namespace paths when path starts with ::" do
|
40
39
|
obj = ClassObject.new(:root, "::A::B::C::D")
|
41
|
-
obj.name.
|
42
|
-
obj.path.
|
43
|
-
obj.namespace.
|
40
|
+
expect(obj.name).to eq :D
|
41
|
+
expect(obj.path).to eq "A::B::C::D"
|
42
|
+
expect(obj.namespace).to eq P("A::B::C")
|
44
43
|
end
|
45
44
|
|
46
|
-
it "
|
45
|
+
it "calls the block again if #new is called on an existing object" do
|
47
46
|
o1 = ClassObject.new(:root, :Me) do |o|
|
48
47
|
o.docstring = "DOCSTRING"
|
49
48
|
end
|
@@ -52,74 +51,76 @@ describe YARD::CodeObjects::Base do
|
|
52
51
|
o.docstring = "NOT_DOCSTRING"
|
53
52
|
end
|
54
53
|
|
55
|
-
o1.object_id.
|
56
|
-
o1.docstring.
|
57
|
-
o2.docstring.
|
54
|
+
expect(o1.object_id).to eq o2.object_id
|
55
|
+
expect(o1.docstring).to eq "NOT_DOCSTRING"
|
56
|
+
expect(o2.docstring).to eq "NOT_DOCSTRING"
|
58
57
|
end
|
59
58
|
|
60
|
-
it "
|
59
|
+
it "allows complex name and converts it to namespace" do
|
61
60
|
obj = CodeObjects::Base.new(nil, "A::B")
|
62
|
-
obj.namespace.path.
|
63
|
-
obj.name.
|
61
|
+
expect(obj.namespace.path).to eq "A"
|
62
|
+
expect(obj.name).to eq :B
|
64
63
|
end
|
65
64
|
|
66
|
-
it "
|
65
|
+
it "allows namespace to be nil and not register in the Registry" do
|
67
66
|
obj = CodeObjects::Base.new(nil, :Me)
|
68
|
-
obj.namespace.
|
69
|
-
Registry.at(:Me).
|
67
|
+
expect(obj.namespace).to eq nil
|
68
|
+
expect(Registry.at(:Me)).to eq nil
|
70
69
|
end
|
71
70
|
|
72
|
-
it "
|
71
|
+
it "allows namespace to be a NamespaceObject" do
|
73
72
|
ns = ModuleObject.new(:root, :Name)
|
74
73
|
obj = CodeObjects::Base.new(ns, :Me)
|
75
|
-
obj.namespace.
|
74
|
+
expect(obj.namespace).to eq ns
|
76
75
|
end
|
77
76
|
|
78
|
-
it "
|
77
|
+
it "allows :root to be the shorthand namespace of `Registry.root`" do
|
79
78
|
obj = CodeObjects::Base.new(:root, :Me)
|
80
|
-
obj.namespace.
|
79
|
+
expect(obj.namespace).to eq Registry.root
|
81
80
|
end
|
82
81
|
|
83
|
-
it "
|
84
|
-
|
82
|
+
it "does not allow any other types as namespace" do
|
83
|
+
expect { CodeObjects::Base.new("ROOT!", :Me) }.to raise_error(ArgumentError)
|
85
84
|
end
|
86
85
|
|
87
|
-
it "
|
86
|
+
it "registers itself in the registry if namespace is supplied" do
|
88
87
|
obj = ModuleObject.new(:root, :Me)
|
89
|
-
Registry.at(:Me).
|
88
|
+
expect(Registry.at(:Me)).to eq obj
|
90
89
|
|
91
90
|
obj2 = ModuleObject.new(obj, :Too)
|
92
|
-
Registry.at(:"Me::Too").
|
91
|
+
expect(Registry.at(:"Me::Too")).to eq obj2
|
93
92
|
end
|
94
93
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
94
|
+
describe "#[]=" do
|
95
|
+
it "sets any attribute" do
|
96
|
+
obj = ModuleObject.new(:root, :YARD)
|
97
|
+
obj[:some_attr] = "hello"
|
98
|
+
expect(obj[:some_attr]).to eq "hello"
|
99
|
+
end
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
101
|
+
it "uses the accessor method if available" do
|
102
|
+
obj = CodeObjects::Base.new(:root, :YARD)
|
103
|
+
obj[:source] = "hello"
|
104
|
+
expect(obj.source).to eq "hello"
|
105
|
+
obj.source = "unhello"
|
106
|
+
expect(obj[:source]).to eq "unhello"
|
107
|
+
end
|
107
108
|
end
|
108
109
|
|
109
|
-
it "
|
110
|
+
it "sets attributes via attr= through method_missing" do
|
110
111
|
obj = CodeObjects::Base.new(:root, :YARD)
|
111
112
|
obj.something = 2
|
112
|
-
obj.something.
|
113
|
-
obj[:something].
|
113
|
+
expect(obj.something).to eq 2
|
114
|
+
expect(obj[:something]).to eq 2
|
114
115
|
end
|
115
116
|
|
116
|
-
it "
|
117
|
+
it "exists in the parent's #children after creation" do
|
117
118
|
obj = ModuleObject.new(:root, :YARD)
|
118
119
|
obj2 = MethodObject.new(obj, :testing)
|
119
|
-
obj.children.
|
120
|
+
expect(obj.children).to include(obj2)
|
120
121
|
end
|
121
122
|
|
122
|
-
it "
|
123
|
+
it "properly re-indents source starting from 0 indentation" do
|
123
124
|
obj = CodeObjects::Base.new(nil, :test)
|
124
125
|
obj.source = <<-eof
|
125
126
|
def mymethod
|
@@ -131,7 +132,7 @@ describe YARD::CodeObjects::Base do
|
|
131
132
|
end
|
132
133
|
end
|
133
134
|
eof
|
134
|
-
obj.source.
|
135
|
+
expect(obj.source).to eq "def mymethod\n if x == 2 &&\n 5 == 5\n 3\n else\n 1\n end\nend"
|
135
136
|
|
136
137
|
Registry.clear
|
137
138
|
Parser::SourceParser.parse_string <<-eof
|
@@ -139,7 +140,7 @@ describe YARD::CodeObjects::Base do
|
|
139
140
|
super(key)
|
140
141
|
end
|
141
142
|
eof
|
142
|
-
Registry.at('#key?').source.
|
143
|
+
expect(Registry.at('#key?').source).to eq "def key?(key)\n super(key)\nend"
|
143
144
|
|
144
145
|
Registry.clear
|
145
146
|
Parser::SourceParser.parse_string <<-eof
|
@@ -151,10 +152,10 @@ describe YARD::CodeObjects::Base do
|
|
151
152
|
end
|
152
153
|
end
|
153
154
|
eof
|
154
|
-
Registry.at('#key?').source.
|
155
|
+
expect(Registry.at('#key?').source).to eq "def key?(key)\n if x == 2\n puts key\n else\n exit\n end\nend"
|
155
156
|
end
|
156
157
|
|
157
|
-
it "
|
158
|
+
it "does not add newlines to source when parsing sub blocks" do
|
158
159
|
Parser::SourceParser.parse_string <<-eof
|
159
160
|
module XYZ
|
160
161
|
module ZYX
|
@@ -166,47 +167,47 @@ describe YARD::CodeObjects::Base do
|
|
166
167
|
end
|
167
168
|
end
|
168
169
|
eof
|
169
|
-
Registry.at('XYZ::ZYX::ABC#msg').source.
|
170
|
+
expect(Registry.at('XYZ::ZYX::ABC#msg').source).to eq "def msg\n hello_world\nend"
|
170
171
|
end
|
171
172
|
|
172
|
-
it "
|
173
|
+
it "handles source for 'def x; end'" do
|
173
174
|
Registry.clear
|
174
175
|
Parser::SourceParser.parse_string "def x; 2 end"
|
175
|
-
Registry.at('#x').source.
|
176
|
+
expect(Registry.at('#x').source).to eq "def x; 2 end"
|
176
177
|
end
|
177
178
|
|
178
|
-
it "
|
179
|
+
it "sets file and line information" do
|
179
180
|
Parser::SourceParser.parse_string <<-eof
|
180
181
|
class X; end
|
181
182
|
eof
|
182
|
-
Registry.at(:X).file.
|
183
|
-
Registry.at(:X).line.
|
183
|
+
expect(Registry.at(:X).file).to eq '(stdin)'
|
184
|
+
expect(Registry.at(:X).line).to eq 1
|
184
185
|
end
|
185
186
|
|
186
|
-
it "
|
187
|
+
it "maintains all file associations when objects are defined multiple times in one file" do
|
187
188
|
Parser::SourceParser.parse_string <<-eof
|
188
189
|
class X; end
|
189
190
|
class X; end
|
190
191
|
class X; end
|
191
192
|
eof
|
192
193
|
|
193
|
-
Registry.at(:X).file.
|
194
|
-
Registry.at(:X).line.
|
195
|
-
Registry.at(:X).files.
|
194
|
+
expect(Registry.at(:X).file).to eq '(stdin)'
|
195
|
+
expect(Registry.at(:X).line).to eq 1
|
196
|
+
expect(Registry.at(:X).files).to eq [['(stdin)', 1], ['(stdin)', 2], ['(stdin)', 3]]
|
196
197
|
end
|
197
198
|
|
198
|
-
it "
|
199
|
+
it "maintains all file associations when objects are defined multiple times in multiple files" do
|
199
200
|
3.times do |i|
|
200
|
-
File.
|
201
|
+
allow(File).to receive(:read_binary).and_return("class X; end")
|
201
202
|
Parser::SourceParser.new.parse("file#{i+1}.rb")
|
202
203
|
end
|
203
204
|
|
204
|
-
Registry.at(:X).file.
|
205
|
-
Registry.at(:X).line.
|
206
|
-
Registry.at(:X).files.
|
205
|
+
expect(Registry.at(:X).file).to eq 'file1.rb'
|
206
|
+
expect(Registry.at(:X).line).to eq 1
|
207
|
+
expect(Registry.at(:X).files).to eq [['file1.rb', 1], ['file2.rb', 1], ['file3.rb', 1]]
|
207
208
|
end
|
208
209
|
|
209
|
-
it "
|
210
|
+
it "prioritizes the definition with a docstring when returning #file" do
|
210
211
|
Parser::SourceParser.parse_string <<-eof
|
211
212
|
class X; end
|
212
213
|
class X; end
|
@@ -214,172 +215,172 @@ describe YARD::CodeObjects::Base do
|
|
214
215
|
class X; end
|
215
216
|
eof
|
216
217
|
|
217
|
-
Registry.at(:X).file.
|
218
|
-
Registry.at(:X).line.
|
219
|
-
Registry.at(:X).files.
|
218
|
+
expect(Registry.at(:X).file).to eq '(stdin)'
|
219
|
+
expect(Registry.at(:X).line).to eq 4
|
220
|
+
expect(Registry.at(:X).files).to eq [['(stdin)', 4], ['(stdin)', 1], ['(stdin)', 2]]
|
220
221
|
end
|
221
222
|
|
222
|
-
describe
|
223
|
-
it "
|
223
|
+
describe "#format" do
|
224
|
+
it "sends object to Templates.render" do
|
224
225
|
object = MethodObject.new(:root, :method)
|
225
|
-
Templates::Engine.
|
226
|
+
expect(Templates::Engine).to receive(:render).with(:x => 1, :object => object)
|
226
227
|
object.format :x => 1
|
227
228
|
end
|
228
229
|
end
|
229
230
|
|
230
|
-
describe
|
231
|
-
it "
|
231
|
+
describe "#source_type" do
|
232
|
+
it "defaults to :ruby" do
|
232
233
|
object = MethodObject.new(:root, :method)
|
233
|
-
object.source_type.
|
234
|
+
expect(object.source_type).to eq :ruby
|
234
235
|
end
|
235
236
|
end
|
236
237
|
|
237
|
-
describe
|
238
|
-
it "
|
238
|
+
describe "#relative_path" do
|
239
|
+
it "accepts a string" do
|
239
240
|
YARD.parse_string "module A; class B; end; class C; end; end"
|
240
|
-
Registry.at('A::B').relative_path(Registry.at('A::C')).
|
241
|
-
Registry.at('A::B').relative_path('A::C')
|
241
|
+
expect(Registry.at('A::B').relative_path(Registry.at('A::C'))).to eq(
|
242
|
+
Registry.at('A::B').relative_path('A::C'))
|
242
243
|
end
|
243
244
|
|
244
|
-
it "
|
245
|
+
it "returns full class name when objects share a common class prefix" do
|
245
246
|
YARD.parse_string "module User; end; module UserManager; end"
|
246
|
-
Registry.at('User').relative_path('UserManager').
|
247
|
-
Registry.at('User').relative_path(Registry.at('UserManager')).
|
247
|
+
expect(Registry.at('User').relative_path('UserManager')).to eq 'UserManager'
|
248
|
+
expect(Registry.at('User').relative_path(Registry.at('UserManager'))).to eq 'UserManager'
|
248
249
|
end
|
249
250
|
|
250
|
-
it "
|
251
|
+
it "returns the relative path when they share a common namespace" do
|
251
252
|
YARD.parse_string "module A; class B; end; class C; end; end"
|
252
|
-
Registry.at('A::B').relative_path(Registry.at('A::C')).
|
253
|
+
expect(Registry.at('A::B').relative_path(Registry.at('A::C'))).to eq 'C'
|
253
254
|
YARD.parse_string "module Foo; module A; end; module B; def foo; end end end"
|
254
|
-
Registry.at('Foo::A').relative_path(Registry.at('Foo::B#foo')).
|
255
|
+
expect(Registry.at('Foo::A').relative_path(Registry.at('Foo::B#foo'))).to eq 'B#foo'
|
255
256
|
end
|
256
257
|
|
257
|
-
it "
|
258
|
+
it "returns the full path if they don't have a common namespace" do
|
258
259
|
YARD.parse_string "module A; class B; end; end; module D; class C; end; end"
|
259
|
-
Registry.at('A::B').relative_path('D::C').
|
260
|
+
expect(Registry.at('A::B').relative_path('D::C')).to eq 'D::C'
|
260
261
|
YARD.parse_string 'module C::B::C; module Apple; end; module Ant; end end'
|
261
|
-
Registry.at('C::B::C::Apple').relative_path('C::B::C::Ant').
|
262
|
+
expect(Registry.at('C::B::C::Apple').relative_path('C::B::C::Ant')).to eq 'Ant'
|
262
263
|
YARD.parse_string 'module OMG::ABC; end; class Object; end'
|
263
|
-
Registry.at('OMG::ABC').relative_path('Object').
|
264
|
+
expect(Registry.at('OMG::ABC').relative_path('Object')).to eq "Object"
|
264
265
|
YARD.parse_string("class YARD::Config; MYCONST = 1; end")
|
265
|
-
Registry.at('YARD::Config').relative_path('YARD::Config::MYCONST').
|
266
|
+
expect(Registry.at('YARD::Config').relative_path('YARD::Config::MYCONST')).to eq "MYCONST"
|
266
267
|
end
|
267
268
|
|
268
|
-
it "
|
269
|
+
it "returns a relative path for class methods" do
|
269
270
|
YARD.parse_string "module A; def self.b; end; def self.c; end; end"
|
270
|
-
Registry.at('A.b').relative_path('A.c').
|
271
|
-
Registry.at('A').relative_path('A.c').
|
271
|
+
expect(Registry.at('A.b').relative_path('A.c')).to eq 'c'
|
272
|
+
expect(Registry.at('A').relative_path('A.c')).to eq 'c'
|
272
273
|
end
|
273
274
|
|
274
|
-
it "
|
275
|
+
it "returns a relative path for instance methods" do
|
275
276
|
YARD.parse_string "module A; def b; end; def c; end; end"
|
276
|
-
Registry.at('A#b').relative_path('A#c').
|
277
|
-
Registry.at('A').relative_path('A#c').
|
277
|
+
expect(Registry.at('A#b').relative_path('A#c')).to eq '#c'
|
278
|
+
expect(Registry.at('A').relative_path('A#c')).to eq '#c'
|
278
279
|
end
|
279
280
|
|
280
|
-
it "
|
281
|
+
it "returns full path if relative path is to parent namespace" do
|
281
282
|
YARD.parse_string "module A; module B; end end"
|
282
|
-
Registry.at('A::B').relative_path('A').
|
283
|
+
expect(Registry.at('A::B').relative_path('A')).to eq 'A'
|
283
284
|
end
|
284
285
|
|
285
|
-
it "
|
286
|
+
it "only returns name for relative path to self" do
|
286
287
|
YARD.parse_string("class A::B::C; def foo; end end")
|
287
|
-
Registry.at('A::B::C').relative_path('A::B::C').
|
288
|
-
Registry.at('A::B::C#foo').relative_path('A::B::C#foo').
|
288
|
+
expect(Registry.at('A::B::C').relative_path('A::B::C')).to eq 'C'
|
289
|
+
expect(Registry.at('A::B::C#foo').relative_path('A::B::C#foo')).to eq '#foo'
|
289
290
|
end
|
290
291
|
end
|
291
292
|
|
292
|
-
describe
|
293
|
-
it "
|
293
|
+
describe "#docstring=" do
|
294
|
+
it "converts string into Docstring when #docstring= is set" do
|
294
295
|
o = ClassObject.new(:root, :Me)
|
295
296
|
o.docstring = "DOCSTRING"
|
296
|
-
o.docstring.
|
297
|
+
expect(o.docstring).to be_instance_of(Docstring)
|
297
298
|
end
|
298
299
|
|
299
|
-
it "
|
300
|
+
it "sets docstring to docstring of other object if docstring is '(see Path)'" do
|
300
301
|
ClassObject.new(:root, :AnotherObject) {|x| x.docstring = "FOO" }
|
301
302
|
o = ClassObject.new(:root, :Me)
|
302
303
|
o.docstring = '(see AnotherObject)'
|
303
|
-
o.docstring.
|
304
|
+
expect(o.docstring).to eq "FOO"
|
304
305
|
end
|
305
306
|
|
306
|
-
it "
|
307
|
+
it "does not copy docstring mid-docstring" do
|
307
308
|
doc = "Hello.\n(see file.rb)\nmore documentation"
|
308
309
|
o = ClassObject.new(:root, :Me)
|
309
310
|
o.docstring = doc
|
310
|
-
o.docstring.
|
311
|
+
expect(o.docstring).to eq doc
|
311
312
|
end
|
312
313
|
|
313
|
-
it "
|
314
|
+
it "allows extra docstring after (see Path)" do
|
314
315
|
ClassObject.new(:root, :AnotherObject) {|x| x.docstring = "FOO" }
|
315
316
|
o = ClassObject.new(:root, :Me)
|
316
317
|
o.docstring = Docstring.new("(see AnotherObject)\n\nEXTRA\n@api private", o)
|
317
|
-
o.docstring.
|
318
|
-
o.docstring.
|
318
|
+
expect(o.docstring).to eq "FOO\n\nEXTRA"
|
319
|
+
expect(o.docstring).to have_tag(:api)
|
319
320
|
end
|
320
321
|
end
|
321
322
|
|
322
|
-
describe
|
323
|
-
it "
|
323
|
+
describe "#docstring" do
|
324
|
+
it "returns an empty string if docstring was '(see Path)' and Path is not resolved" do
|
324
325
|
o = ClassObject.new(:root, :Me)
|
325
326
|
o.docstring = '(see AnotherObject)'
|
326
|
-
o.docstring.
|
327
|
+
expect(o.docstring).to eq ""
|
327
328
|
end
|
328
329
|
|
329
|
-
it "
|
330
|
+
it "returns docstring when object is resolved" do
|
330
331
|
o = ClassObject.new(:root, :Me)
|
331
332
|
o.docstring = '(see AnotherObject)'
|
332
|
-
o.docstring.
|
333
|
+
expect(o.docstring).to eq ""
|
333
334
|
ClassObject.new(:root, :AnotherObject) {|x| x.docstring = "FOO" }
|
334
|
-
o.docstring.
|
335
|
+
expect(o.docstring).to eq "FOO"
|
335
336
|
end
|
336
337
|
|
337
|
-
describe
|
338
|
-
it "
|
338
|
+
describe "localization" do
|
339
|
+
it "returns localized docstring" do
|
339
340
|
fr_locale = YARD::I18n::Locale.new('fr')
|
340
|
-
fr_locale.
|
341
|
+
allow(fr_locale).to receive(:translate).with('Hello').and_return('Bonjour')
|
341
342
|
|
342
343
|
o = ClassObject.new(:root, :Me)
|
343
344
|
o.docstring = 'Hello'
|
344
|
-
o.docstring.
|
345
|
+
expect(o.docstring).to eq 'Hello'
|
345
346
|
|
346
|
-
Registry.
|
347
|
-
o.docstring('fr').
|
347
|
+
allow(Registry).to receive(:locale).with('fr').and_return(fr_locale)
|
348
|
+
expect(o.docstring('fr')).to eq "Bonjour"
|
348
349
|
end
|
349
350
|
|
350
|
-
it "
|
351
|
+
it "returns updated localized docstring" do
|
351
352
|
fr_locale = YARD::I18n::Locale.new('fr')
|
352
|
-
Registry.
|
353
|
+
allow(Registry).to receive(:locale).with('fr').and_return(fr_locale)
|
353
354
|
|
354
355
|
o = ClassObject.new(:root, :Me)
|
355
356
|
o.docstring = 'Hello'
|
356
|
-
o.docstring.
|
357
|
+
expect(o.docstring).to eq 'Hello'
|
357
358
|
|
358
|
-
fr_locale.
|
359
|
-
o.docstring('fr').
|
359
|
+
allow(fr_locale).to receive(:translate).with('Hello').and_return('Bonjour')
|
360
|
+
expect(o.docstring('fr')).to eq "Bonjour"
|
360
361
|
|
361
362
|
o.docstring = 'World'
|
362
|
-
fr_locale.
|
363
|
-
o.docstring('fr').
|
364
|
-
o.docstring.
|
363
|
+
allow(fr_locale).to receive(:translate).with('World').and_return('Monde')
|
364
|
+
expect(o.docstring('fr')).to eq "Monde"
|
365
|
+
expect(o.docstring).to eq 'World'
|
365
366
|
end
|
366
367
|
end
|
367
368
|
end
|
368
369
|
|
369
|
-
describe
|
370
|
-
it "
|
370
|
+
describe "#add_file" do
|
371
|
+
it "only adds a file/line combination once" do
|
371
372
|
o = ClassObject.new(:root, :Me)
|
372
373
|
o.add_file('filename', 12)
|
373
|
-
o.files.
|
374
|
+
expect(o.files).to eq [['filename', 12]]
|
374
375
|
o.add_file('filename', 12)
|
375
|
-
o.files.
|
376
|
+
expect(o.files).to eq [['filename', 12]]
|
376
377
|
o.add_file('filename', 40) # different line
|
377
|
-
o.files.
|
378
|
+
expect(o.files).to eq [['filename', 12], ['filename', 40]]
|
378
379
|
end
|
379
380
|
end
|
380
381
|
|
381
|
-
describe
|
382
|
-
it "
|
382
|
+
describe "#copy_to" do
|
383
|
+
it "copies all data to new object" do
|
383
384
|
YARD.parse_string <<-eof
|
384
385
|
private
|
385
386
|
# A docstring
|
@@ -390,27 +391,27 @@ describe YARD::CodeObjects::Base do
|
|
390
391
|
eof
|
391
392
|
foo_c = MethodObject.new(:root, :foo, :class)
|
392
393
|
Registry.at('#foo').copy_to(foo_c)
|
393
|
-
foo_c.scope.
|
394
|
-
foo_c.visibility.
|
395
|
-
foo_c.type.
|
396
|
-
foo_c.class.
|
397
|
-
foo_c.path.
|
398
|
-
foo_c.docstring.
|
399
|
-
foo_c.tag(:return).types.
|
400
|
-
foo_c.file.
|
401
|
-
foo_c.line.
|
402
|
-
foo_c.source.
|
403
|
-
foo_c.signature.
|
404
|
-
foo_c.parameters.
|
394
|
+
expect(foo_c.scope).to eq :class
|
395
|
+
expect(foo_c.visibility).to eq :private
|
396
|
+
expect(foo_c.type).to eq :method
|
397
|
+
expect(foo_c.class).to eq MethodObject
|
398
|
+
expect(foo_c.path).to eq '::foo'
|
399
|
+
expect(foo_c.docstring).to eq "A docstring"
|
400
|
+
expect(foo_c.tag(:return).types).to eq ['String']
|
401
|
+
expect(foo_c.file).to eq '(stdin)'
|
402
|
+
expect(foo_c.line).to eq 4
|
403
|
+
expect(foo_c.source).to match /source_code_here/
|
404
|
+
expect(foo_c.signature).to eq 'def foo(a, b, c)'
|
405
|
+
expect(foo_c.parameters).to eq [['a', nil], ['b', nil], ['c', nil]]
|
405
406
|
end
|
406
407
|
|
407
|
-
it "
|
408
|
+
it "returns the copied object" do
|
408
409
|
YARD.parse_string 'def foo; end'
|
409
410
|
foo_c = MethodObject.new(:root, :foo, :class)
|
410
|
-
Registry.at('#foo').copy_to(foo_c).
|
411
|
+
expect(Registry.at('#foo').copy_to(foo_c)).to eq foo_c
|
411
412
|
end
|
412
413
|
|
413
|
-
it "
|
414
|
+
it "copies docstring and rewrite tags to new object" do
|
414
415
|
YARD.parse_string <<-eof
|
415
416
|
# @return [String] a tag
|
416
417
|
def foo; end
|
@@ -418,20 +419,20 @@ describe YARD::CodeObjects::Base do
|
|
418
419
|
foo_c = MethodObject.new(:root, :foo, :class)
|
419
420
|
foo_i = Registry.at('#foo')
|
420
421
|
foo_i.copy_to(foo_c)
|
421
|
-
foo_i.tags.
|
422
|
-
foo_c.tags.first.object.
|
422
|
+
expect(foo_i.tags).not_to eq foo_c.tags
|
423
|
+
expect(foo_c.tags.first.object).to eq foo_c
|
423
424
|
end
|
424
425
|
|
425
|
-
it "
|
426
|
+
it "only copies #copyable_attributes" do
|
426
427
|
foo = MethodObject.new(:root, :foo)
|
427
|
-
foo.
|
428
|
-
foo.
|
429
|
-
foo.
|
430
|
-
foo.
|
428
|
+
expect(foo).to receive(:copyable_attributes).and_return %w(a b c)
|
429
|
+
expect(foo).to receive(:instance_variable_get).with('@a').and_return(1)
|
430
|
+
expect(foo).to receive(:instance_variable_get).with('@b').and_return(2)
|
431
|
+
expect(foo).to receive(:instance_variable_get).with('@c').and_return(3)
|
431
432
|
bar = MethodObject.new(:root, :bar)
|
432
|
-
bar.
|
433
|
-
bar.
|
434
|
-
bar.
|
433
|
+
expect(bar).to receive(:instance_variable_set).with('@a', 1)
|
434
|
+
expect(bar).to receive(:instance_variable_set).with('@b', 2)
|
435
|
+
expect(bar).to receive(:instance_variable_set).with('@c', 3)
|
435
436
|
foo.copy_to(bar)
|
436
437
|
end
|
437
438
|
end
|