yard 0.9.24 → 0.9.25
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/.rubocop.yml +37 -24
- data/CHANGELOG.md +18 -3
- data/README.md +96 -101
- data/Rakefile +2 -0
- data/lib/yard/cli/diff.rb +4 -1
- data/lib/yard/cli/server.rb +22 -13
- data/lib/yard/code_objects/proxy.rb +2 -1
- data/lib/yard/globals.rb +1 -1
- data/lib/yard/handlers/c/base.rb +164 -129
- data/lib/yard/parser/ruby/ruby_parser.rb +6 -4
- data/lib/yard/registry_store.rb +1 -1
- data/lib/yard/templates/helpers/html_helper.rb +10 -3
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
- data/lib/yard/version.rb +1 -1
- data/tasks/update_error_map.rake +53 -0
- data/yard.gemspec +1 -1
- metadata +3 -207
- data/spec/cli/command_parser_spec.rb +0 -43
- data/spec/cli/command_spec.rb +0 -36
- data/spec/cli/config_spec.rb +0 -148
- data/spec/cli/diff_spec.rb +0 -254
- data/spec/cli/display_spec.rb +0 -30
- data/spec/cli/gems_spec.rb +0 -81
- data/spec/cli/graph_spec.rb +0 -18
- data/spec/cli/help_spec.rb +0 -22
- data/spec/cli/i18n_spec.rb +0 -107
- data/spec/cli/list_spec.rb +0 -8
- data/spec/cli/markup_types_spec.rb +0 -22
- data/spec/cli/server_spec.rb +0 -324
- data/spec/cli/stats_spec.rb +0 -96
- data/spec/cli/yard_on_yard_spec.rb +0 -38
- data/spec/cli/yardoc_spec.rb +0 -896
- data/spec/cli/yri_spec.rb +0 -101
- data/spec/code_objects/base_spec.rb +0 -485
- data/spec/code_objects/class_object_spec.rb +0 -226
- data/spec/code_objects/code_object_list_spec.rb +0 -36
- data/spec/code_objects/constants_spec.rb +0 -116
- data/spec/code_objects/extra_file_object_spec.rb +0 -161
- data/spec/code_objects/macro_object_spec.rb +0 -150
- data/spec/code_objects/method_object_spec.rb +0 -184
- data/spec/code_objects/module_object_spec.rb +0 -142
- data/spec/code_objects/namespace_mapper_spec.rb +0 -32
- data/spec/code_objects/namespace_object_spec.rb +0 -171
- data/spec/code_objects/proxy_spec.rb +0 -147
- data/spec/code_objects/spec_helper.rb +0 -3
- data/spec/config_spec.rb +0 -171
- data/spec/core_ext/array_spec.rb +0 -13
- data/spec/core_ext/file_spec.rb +0 -72
- data/spec/core_ext/hash_spec.rb +0 -14
- data/spec/core_ext/insertion_spec.rb +0 -37
- data/spec/core_ext/module_spec.rb +0 -9
- data/spec/core_ext/string_spec.rb +0 -42
- data/spec/core_ext/symbol_hash_spec.rb +0 -89
- data/spec/docstring_parser_spec.rb +0 -280
- data/spec/docstring_spec.rb +0 -373
- data/spec/handlers/alias_handler_spec.rb +0 -82
- data/spec/handlers/attribute_handler_spec.rb +0 -96
- data/spec/handlers/base_spec.rb +0 -216
- data/spec/handlers/c/alias_handler_spec.rb +0 -34
- data/spec/handlers/c/attribute_handler_spec.rb +0 -41
- data/spec/handlers/c/class_handler_spec.rb +0 -78
- data/spec/handlers/c/constant_handler_spec.rb +0 -71
- data/spec/handlers/c/init_handler_spec.rb +0 -48
- data/spec/handlers/c/method_handler_spec.rb +0 -327
- data/spec/handlers/c/mixin_handler_spec.rb +0 -44
- data/spec/handlers/c/module_handler_spec.rb +0 -71
- data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
- data/spec/handlers/c/path_handler_spec.rb +0 -36
- data/spec/handlers/c/spec_helper.rb +0 -23
- data/spec/handlers/c/struct_handler_spec.rb +0 -16
- data/spec/handlers/class_condition_handler_spec.rb +0 -87
- data/spec/handlers/class_handler_spec.rb +0 -247
- data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
- data/spec/handlers/class_variable_handler_spec.rb +0 -12
- data/spec/handlers/constant_handler_spec.rb +0 -112
- data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
- data/spec/handlers/dsl_handler_spec.rb +0 -226
- data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
- data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
- data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
- data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
- data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
- data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
- data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
- data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
- data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
- data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
- data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
- data/spec/handlers/exception_handler_spec.rb +0 -49
- data/spec/handlers/extend_handler_spec.rb +0 -28
- data/spec/handlers/legacy_base_spec.rb +0 -128
- data/spec/handlers/method_condition_handler_spec.rb +0 -15
- data/spec/handlers/method_handler_spec.rb +0 -214
- data/spec/handlers/mixin_handler_spec.rb +0 -60
- data/spec/handlers/module_function_handler_spec.rb +0 -106
- data/spec/handlers/module_handler_spec.rb +0 -35
- data/spec/handlers/private_class_method_handler_spec.rb +0 -11
- data/spec/handlers/private_constant_handler_spec.rb +0 -25
- data/spec/handlers/processor_spec.rb +0 -35
- data/spec/handlers/public_class_method_handler_spec.rb +0 -11
- data/spec/handlers/ruby/base_spec.rb +0 -95
- data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
- data/spec/handlers/spec_helper.rb +0 -33
- data/spec/handlers/visibility_handler_spec.rb +0 -44
- data/spec/handlers/yield_handler_spec.rb +0 -52
- data/spec/i18n/locale_spec.rb +0 -81
- data/spec/i18n/message_spec.rb +0 -52
- data/spec/i18n/messages_spec.rb +0 -67
- data/spec/i18n/pot_generator_spec.rb +0 -295
- data/spec/i18n/text_spec.rb +0 -184
- data/spec/logging_spec.rb +0 -44
- data/spec/options_spec.rb +0 -171
- data/spec/parser/base_spec.rb +0 -24
- data/spec/parser/c_parser_spec.rb +0 -236
- data/spec/parser/examples/array.c.txt +0 -6267
- data/spec/parser/examples/example1.rb.txt +0 -8
- data/spec/parser/examples/extrafile.c.txt +0 -8
- data/spec/parser/examples/file.c.txt +0 -28
- data/spec/parser/examples/multifile.c.txt +0 -22
- data/spec/parser/examples/namespace.cpp.txt +0 -68
- data/spec/parser/examples/override.c.txt +0 -424
- data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
- data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
- data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
- data/spec/parser/ruby/ast_node_spec.rb +0 -33
- data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
- data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
- data/spec/parser/ruby/ruby_parser_spec.rb +0 -520
- data/spec/parser/ruby/token_resolver_spec.rb +0 -165
- data/spec/parser/source_parser_spec.rb +0 -727
- data/spec/parser/tag_parsing_spec.rb +0 -17
- data/spec/rake/yardoc_task_spec.rb +0 -118
- data/spec/registry_resolver_spec.rb +0 -15
- data/spec/registry_spec.rb +0 -463
- data/spec/registry_store_spec.rb +0 -327
- data/spec/rubygems/doc_manager_spec.rb +0 -112
- data/spec/serializers/data/serialized_yardoc/checksums +0 -1
- data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
- data/spec/serializers/file_system_serializer_spec.rb +0 -145
- data/spec/serializers/spec_helper.rb +0 -2
- data/spec/serializers/yardoc_serializer_spec.rb +0 -90
- data/spec/server/adapter_spec.rb +0 -39
- data/spec/server/commands/base_spec.rb +0 -91
- data/spec/server/commands/library_command_spec.rb +0 -39
- data/spec/server/doc_server_helper_spec.rb +0 -72
- data/spec/server/doc_server_serializer_spec.rb +0 -60
- data/spec/server/rack_adapter_spec.rb +0 -21
- data/spec/server/router_spec.rb +0 -123
- data/spec/server/spec_helper.rb +0 -22
- data/spec/server/static_caching_spec.rb +0 -47
- data/spec/server/webrick_servlet_spec.rb +0 -20
- data/spec/server_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -212
- data/spec/tags/default_factory_spec.rb +0 -168
- data/spec/tags/default_tag_spec.rb +0 -11
- data/spec/tags/directives_spec.rb +0 -463
- data/spec/tags/library_spec.rb +0 -48
- data/spec/tags/overload_tag_spec.rb +0 -53
- data/spec/tags/ref_tag_list_spec.rb +0 -53
- data/spec/tags/types_explainer_spec.rb +0 -203
- data/spec/templates/class_spec.rb +0 -45
- data/spec/templates/constant_spec.rb +0 -41
- data/spec/templates/engine_spec.rb +0 -131
- data/spec/templates/examples/class001.html +0 -308
- data/spec/templates/examples/class001.txt +0 -36
- data/spec/templates/examples/class002.html +0 -39
- data/spec/templates/examples/constant001.txt +0 -25
- data/spec/templates/examples/constant002.txt +0 -7
- data/spec/templates/examples/constant003.txt +0 -11
- data/spec/templates/examples/method001.html +0 -137
- data/spec/templates/examples/method001.txt +0 -35
- data/spec/templates/examples/method002.html +0 -91
- data/spec/templates/examples/method002.txt +0 -20
- data/spec/templates/examples/method003.html +0 -165
- data/spec/templates/examples/method003.txt +0 -45
- data/spec/templates/examples/method004.html +0 -48
- data/spec/templates/examples/method004.txt +0 -10
- data/spec/templates/examples/method005.html +0 -105
- data/spec/templates/examples/method005.txt +0 -33
- data/spec/templates/examples/method006.html +0 -108
- data/spec/templates/examples/method006.txt +0 -20
- data/spec/templates/examples/module001.dot +0 -33
- data/spec/templates/examples/module001.html +0 -833
- data/spec/templates/examples/module001.txt +0 -33
- data/spec/templates/examples/module002.html +0 -341
- data/spec/templates/examples/module003.html +0 -202
- data/spec/templates/examples/module004.html +0 -394
- data/spec/templates/examples/module005.html +0 -82
- data/spec/templates/examples/tag001.txt +0 -82
- data/spec/templates/helpers/base_helper_spec.rb +0 -171
- data/spec/templates/helpers/html_helper_spec.rb +0 -666
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
- data/spec/templates/helpers/markup_helper_spec.rb +0 -136
- data/spec/templates/helpers/method_helper_spec.rb +0 -107
- data/spec/templates/helpers/module_helper_spec.rb +0 -35
- data/spec/templates/helpers/shared_signature_examples.rb +0 -126
- data/spec/templates/helpers/text_helper_spec.rb +0 -65
- data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -50
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -48
- data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -64
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -64
- data/spec/templates/method_spec.rb +0 -118
- data/spec/templates/module_spec.rb +0 -203
- data/spec/templates/onefile_spec.rb +0 -66
- data/spec/templates/section_spec.rb +0 -144
- data/spec/templates/spec_helper.rb +0 -76
- data/spec/templates/tag_spec.rb +0 -52
- data/spec/templates/template_spec.rb +0 -410
- data/spec/verifier_spec.rb +0 -106
@@ -1,226 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe YARD::CodeObjects::ClassObject do
|
5
|
-
describe "#inheritance_tree" do
|
6
|
-
before(:all) do
|
7
|
-
Registry.clear
|
8
|
-
@mixin = ModuleObject.new(:root, :SomeMixin)
|
9
|
-
@mixin2 = ModuleObject.new(:root, :SomeMixin2)
|
10
|
-
@mixin2.instance_mixins << @mixin
|
11
|
-
@mixin3 = ModuleObject.new(:root, :SomeMixin3)
|
12
|
-
@mixin4 = ModuleObject.new(:root, :SomeMixin4)
|
13
|
-
@mixin2.instance_mixins << @mixin3
|
14
|
-
@superyard = ClassObject.new(:root, :SuperYard)
|
15
|
-
@superyard.superclass = P("String")
|
16
|
-
@superyard.instance_mixins << @mixin2
|
17
|
-
@superyard.class_mixins << @mixin4
|
18
|
-
@yard = ClassObject.new(:root, :YARD)
|
19
|
-
@yard.superclass = @superyard
|
20
|
-
@yard.instance_mixins << @mixin
|
21
|
-
end
|
22
|
-
|
23
|
-
it "shows the proper inheritance tree" do
|
24
|
-
expect(@yard.inheritance_tree).to eq [@yard, @superyard, P(:String)]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "shows proper inheritance tree when mixins are included" do
|
28
|
-
expect(@yard.inheritance_tree(true)).to eq [@yard, @mixin, @superyard, @mixin4, @mixin2, @mixin3, P(:String)]
|
29
|
-
end
|
30
|
-
|
31
|
-
it "does not modify the object's mixin list when mixins are included" do
|
32
|
-
@class1 = ClassObject.new(:root, :A)
|
33
|
-
@class2 = ClassObject.new(:root, :B)
|
34
|
-
@class2.superclass = @class1
|
35
|
-
|
36
|
-
@class2.inheritance_tree(true)
|
37
|
-
expect(@class2.mixins).to eq []
|
38
|
-
end
|
39
|
-
|
40
|
-
it "lists class mixins in inheritance tree" do
|
41
|
-
mod = ModuleObject.new(:root, :ClassMethods)
|
42
|
-
klass = ClassObject.new(:root, :ReceivingClass)
|
43
|
-
klass.class_mixins << mod
|
44
|
-
expect(klass.inheritance_tree(true)).to eq [klass, mod]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#meths / #inherited_meths" do
|
49
|
-
before(:all) do
|
50
|
-
Registry.clear
|
51
|
-
|
52
|
-
YARD.parse_string <<-eof
|
53
|
-
class SuperYard < String
|
54
|
-
def foo; end
|
55
|
-
def foo2; end
|
56
|
-
def bar; end
|
57
|
-
def middle; end
|
58
|
-
protected :foo2
|
59
|
-
private
|
60
|
-
def self.bar; end
|
61
|
-
end
|
62
|
-
|
63
|
-
class MiddleYard < SuperYard
|
64
|
-
def middle; end
|
65
|
-
end
|
66
|
-
|
67
|
-
class YARD < MiddleYard
|
68
|
-
def mymethod; end
|
69
|
-
def bar; end
|
70
|
-
end
|
71
|
-
|
72
|
-
module IncludedYard
|
73
|
-
def foo; end
|
74
|
-
end
|
75
|
-
|
76
|
-
class FinalYard < SuperYard
|
77
|
-
include IncludedYard
|
78
|
-
end
|
79
|
-
eof
|
80
|
-
end
|
81
|
-
|
82
|
-
it "shows inherited methods by default" do
|
83
|
-
meths = P(:YARD).meths
|
84
|
-
expect(meths).to include(P("YARD#mymethod"))
|
85
|
-
expect(meths).to include(P("SuperYard#foo"))
|
86
|
-
expect(meths).to include(P("SuperYard#foo2"))
|
87
|
-
expect(meths).to include(P("SuperYard.bar"))
|
88
|
-
end
|
89
|
-
|
90
|
-
it "allows :inherited to be set to false" do
|
91
|
-
meths = P(:YARD).meths(:inherited => false)
|
92
|
-
expect(meths).to include(P("YARD#mymethod"))
|
93
|
-
expect(meths).not_to include(P("SuperYard#foo"))
|
94
|
-
expect(meths).not_to include(P("SuperYard#foo2"))
|
95
|
-
expect(meths).not_to include(P("SuperYard.bar"))
|
96
|
-
end
|
97
|
-
|
98
|
-
it "does not show overridden methods" do
|
99
|
-
meths = P(:YARD).meths
|
100
|
-
expect(meths).to include(P("YARD#bar"))
|
101
|
-
expect(meths).not_to include(P("SuperYard#bar"))
|
102
|
-
|
103
|
-
meths = P(:YARD).inherited_meths
|
104
|
-
expect(meths).not_to include(P("YARD#bar"))
|
105
|
-
expect(meths).not_to include(P("YARD#mymethod"))
|
106
|
-
expect(meths).to include(P("SuperYard#foo"))
|
107
|
-
expect(meths).to include(P("SuperYard#foo2"))
|
108
|
-
expect(meths).to include(P("SuperYard.bar"))
|
109
|
-
end
|
110
|
-
|
111
|
-
it "does not show inherited methods overridden by other subclasses" do
|
112
|
-
meths = P(:YARD).inherited_meths
|
113
|
-
expect(meths).to include(P('MiddleYard#middle'))
|
114
|
-
expect(meths).not_to include(P('SuperYard#middle'))
|
115
|
-
end
|
116
|
-
|
117
|
-
it "shows mixed in methods before superclass method" do
|
118
|
-
meths = P(:FinalYard).meths
|
119
|
-
expect(meths).to include(P('IncludedYard#foo'))
|
120
|
-
expect(meths).not_to include(P('SuperYard#foo'))
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "#constants / #inherited_constants" do
|
125
|
-
before(:all) do
|
126
|
-
Registry.clear
|
127
|
-
|
128
|
-
Parser::SourceParser.parse_string <<-eof
|
129
|
-
class YARD
|
130
|
-
CONST1 = 1
|
131
|
-
CONST2 = "hello"
|
132
|
-
CONST4 = 0
|
133
|
-
end
|
134
|
-
|
135
|
-
class SUPERYARD < YARD
|
136
|
-
CONST4 = 5
|
137
|
-
end
|
138
|
-
|
139
|
-
class SubYard < SUPERYARD
|
140
|
-
CONST2 = "hi"
|
141
|
-
CONST3 = "foo"
|
142
|
-
end
|
143
|
-
eof
|
144
|
-
end
|
145
|
-
|
146
|
-
it "lists inherited constants by default" do
|
147
|
-
consts = P(:SubYard).constants
|
148
|
-
expect(consts).to include(P("YARD::CONST1"))
|
149
|
-
expect(consts).to include(P("SubYard::CONST3"))
|
150
|
-
|
151
|
-
consts = P(:SubYard).inherited_constants
|
152
|
-
expect(consts).to include(P("YARD::CONST1"))
|
153
|
-
expect(consts).not_to include(P("YARD::CONST2"))
|
154
|
-
expect(consts).not_to include(P("SubYard::CONST2"))
|
155
|
-
expect(consts).not_to include(P("SubYard::CONST3"))
|
156
|
-
end
|
157
|
-
|
158
|
-
it "does not list inherited constants if turned off" do
|
159
|
-
consts = P(:SubYard).constants(:inherited => false)
|
160
|
-
expect(consts).not_to include(P("YARD::CONST1"))
|
161
|
-
expect(consts).to include(P("SubYard::CONST3"))
|
162
|
-
end
|
163
|
-
|
164
|
-
it "does not include an inherited constant if it is overridden by the object" do
|
165
|
-
consts = P(:SubYard).constants
|
166
|
-
expect(consts).to include(P("SubYard::CONST2"))
|
167
|
-
expect(consts).not_to include(P("YARD::CONST2"))
|
168
|
-
end
|
169
|
-
|
170
|
-
it "does not include an inherited constant if it is overridden by another subclass" do
|
171
|
-
consts = P(:SubYard).inherited_constants
|
172
|
-
expect(consts).to include(P("SUPERYARD::CONST4"))
|
173
|
-
expect(consts).not_to include(P("YARD::CONST4"))
|
174
|
-
end
|
175
|
-
|
176
|
-
it "does not set a superclass on BasicObject class" do
|
177
|
-
o = ClassObject.new(:root, :BasicObject)
|
178
|
-
expect(o.superclass).to be nil
|
179
|
-
end
|
180
|
-
|
181
|
-
it "sets superclass of Object to BasicObject" do
|
182
|
-
o = ClassObject.new(:root, :Object)
|
183
|
-
expect(o.superclass).to eq P(:BasicObject)
|
184
|
-
end
|
185
|
-
|
186
|
-
it "raises ArgumentError if superclass == self" do
|
187
|
-
expect do
|
188
|
-
ClassObject.new(:root, :Object) do |o|
|
189
|
-
o.superclass = :Object
|
190
|
-
end
|
191
|
-
end.to raise_error(ArgumentError)
|
192
|
-
end
|
193
|
-
|
194
|
-
it "tells the world if it is an exception class" do
|
195
|
-
o = ClassObject.new(:root, :MyClass)
|
196
|
-
o2 = ClassObject.new(:root, :OtherClass)
|
197
|
-
o2.superclass = :SystemCallError
|
198
|
-
o3 = ClassObject.new(:root, :StandardError)
|
199
|
-
o3.superclass = :Object
|
200
|
-
ClassObject.new(:root, :Object)
|
201
|
-
|
202
|
-
o.superclass = :Object
|
203
|
-
expect(o.is_exception?).to be false
|
204
|
-
|
205
|
-
o.superclass = :Exception
|
206
|
-
expect(o.is_exception?).to be true
|
207
|
-
|
208
|
-
o.superclass = :NoMethodError
|
209
|
-
expect(o.is_exception?).to be true
|
210
|
-
|
211
|
-
o.superclass = o2
|
212
|
-
expect(o.is_exception?).to be true
|
213
|
-
|
214
|
-
o.superclass = o3
|
215
|
-
expect(o.is_exception?).to be true
|
216
|
-
end
|
217
|
-
|
218
|
-
it "does not raise ArgumentError if superclass is proxy in different namespace" do
|
219
|
-
expect do
|
220
|
-
ClassObject.new(:root, :X) do |o|
|
221
|
-
o.superclass = P('OTHER::X')
|
222
|
-
end
|
223
|
-
end.not_to raise_error
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe YARD::CodeObjects::CodeObjectList do
|
5
|
-
before { Registry.clear }
|
6
|
-
|
7
|
-
describe "#push" do
|
8
|
-
it "only allows CodeObjects::Base, String or Symbol" do
|
9
|
-
list = CodeObjectList.new(nil)
|
10
|
-
expect { list.push(:hash => 1) }.to raise_error(ArgumentError)
|
11
|
-
list << "Test"
|
12
|
-
list << :Test2
|
13
|
-
list << ModuleObject.new(nil, :YARD)
|
14
|
-
expect(list.size).to eq 3
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "added value should be a proxy if parameter was String or Symbol" do
|
19
|
-
list = CodeObjectList.new(nil)
|
20
|
-
list << "Test"
|
21
|
-
expect(list.first.class).to eq Proxy
|
22
|
-
end
|
23
|
-
|
24
|
-
it "contains a unique list of objects" do
|
25
|
-
obj = ModuleObject.new(nil, :YARD)
|
26
|
-
list = CodeObjectList.new(nil)
|
27
|
-
|
28
|
-
list << P(:YARD)
|
29
|
-
list << obj
|
30
|
-
expect(list.size).to eq 1
|
31
|
-
|
32
|
-
list << :Test
|
33
|
-
list << "Test"
|
34
|
-
expect(list.size).to eq 2
|
35
|
-
end
|
36
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe YARD::CodeObjects do
|
5
|
-
def silence_warnings
|
6
|
-
origverb = $VERBOSE
|
7
|
-
$VERBOSE = nil
|
8
|
-
yield
|
9
|
-
$VERBOSE = origverb
|
10
|
-
end
|
11
|
-
|
12
|
-
describe :CONSTANTMATCH do
|
13
|
-
it "matches a constant" do
|
14
|
-
expect("Constant"[CodeObjects::CONSTANTMATCH]).to eq "Constant"
|
15
|
-
expect("identifier"[CodeObjects::CONSTANTMATCH]).to be nil
|
16
|
-
expect("File.new"[CodeObjects::CONSTANTMATCH]).to eq "File"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe :CONSTANTSTART do
|
21
|
-
it "matches a constant" do
|
22
|
-
expect("Constant"[CodeObjects::CONSTANTSTART]).to eq "C"
|
23
|
-
expect("identifier"[CodeObjects::CONSTANTSTART]).to be nil
|
24
|
-
expect("File.new"[CodeObjects::CONSTANTSTART]).to eq "F"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe :NAMESPACEMATCH do
|
29
|
-
it "matches a namespace (multiple constants with ::)" do
|
30
|
-
expect("Constant"[CodeObjects::NAMESPACEMATCH]).to eq "Constant"
|
31
|
-
expect("A::B::C.new"[CodeObjects::NAMESPACEMATCH]).to eq "A::B::C"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe :METHODNAMEMATCH do
|
36
|
-
it "matches a method name" do
|
37
|
-
expect("method"[CodeObjects::METHODNAMEMATCH]).to eq "method"
|
38
|
-
expect("[]()"[CodeObjects::METHODNAMEMATCH]).to eq "[]"
|
39
|
-
expect("-@"[CodeObjects::METHODNAMEMATCH]).to eq "-@"
|
40
|
-
expect("method?"[CodeObjects::METHODNAMEMATCH]).to eq "method?"
|
41
|
-
expect("method!!"[CodeObjects::METHODNAMEMATCH]).to eq "method!"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe :METHODMATCH do
|
46
|
-
it "matches a full class method path" do
|
47
|
-
expect("method"[CodeObjects::METHODMATCH]).to eq "method"
|
48
|
-
expect("A::B::C.method?"[CodeObjects::METHODMATCH]).to eq "A::B::C.method?"
|
49
|
-
expect("A::B::C :: method"[CodeObjects::METHODMATCH]).to eq "A::B::C :: method"
|
50
|
-
expect("SomeClass . method"[CodeObjects::METHODMATCH]).to eq "SomeClass . method"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "matches self.method" do
|
54
|
-
expect("self :: method!"[CodeObjects::METHODMATCH]).to eq "self :: method!"
|
55
|
-
expect("self.is_a?"[CodeObjects::METHODMATCH]).to eq "self.is_a?"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe :BUILTIN_EXCEPTIONS do
|
60
|
-
it "includes all base exceptions" do
|
61
|
-
bad_names = []
|
62
|
-
silence_warnings do
|
63
|
-
YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
|
64
|
-
begin
|
65
|
-
bad_names << name unless eval(name) <= Exception
|
66
|
-
rescue NameError
|
67
|
-
nil # noop
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
expect(bad_names).to be_empty
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe :BUILTIN_CLASSES do
|
76
|
-
it "includes all base classes" do
|
77
|
-
bad_names = []
|
78
|
-
silence_warnings do
|
79
|
-
YARD::CodeObjects::BUILTIN_CLASSES.each do |name|
|
80
|
-
begin
|
81
|
-
bad_names << name unless eval(name).is_a?(Class)
|
82
|
-
rescue NameError
|
83
|
-
nil # noop
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
expect(bad_names).to be_empty
|
88
|
-
end
|
89
|
-
|
90
|
-
it "includes all exceptions" do
|
91
|
-
YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
|
92
|
-
expect(YARD::CodeObjects::BUILTIN_CLASSES).to include(name)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe :BUILTIN_ALL do
|
98
|
-
it "includes classes, modules, and exceptions" do
|
99
|
-
a = YARD::CodeObjects::BUILTIN_ALL
|
100
|
-
b = YARD::CodeObjects::BUILTIN_CLASSES
|
101
|
-
c = YARD::CodeObjects::BUILTIN_MODULES
|
102
|
-
expect(a).to eq b + c
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe :BUILTIN_MODULES do
|
107
|
-
it "includes all base modules" do
|
108
|
-
silence_warnings do
|
109
|
-
YARD::CodeObjects::BUILTIN_MODULES.each do |name|
|
110
|
-
next if YARD.ruby19? && ["Precision"].include?(name)
|
111
|
-
expect(eval(name)).to be_instance_of(Module)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
@@ -1,161 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe YARD::CodeObjects::ExtraFileObject do
|
5
|
-
describe "#initialize" do
|
6
|
-
it "attempts to read contents from filesystem if contents=nil" do
|
7
|
-
expect(File).to receive(:read).with('file.txt').and_return('')
|
8
|
-
ExtraFileObject.new('file.txt')
|
9
|
-
end
|
10
|
-
|
11
|
-
it "raises Errno::ENOENT if contents=nil and file does not exist" do
|
12
|
-
expect { ExtraFileObject.new('file.txt') }.to raise_error(Errno::ENOENT)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "does not attempt to read from disk if contents are provided" do
|
16
|
-
# TODO: no assertions here!
|
17
|
-
ExtraFileObject.new('file.txt', 'CONTENTS')
|
18
|
-
end
|
19
|
-
|
20
|
-
it "sets filename to filename" do
|
21
|
-
file = ExtraFileObject.new('a/b/c/file.txt', 'CONTENTS')
|
22
|
-
expect(file.filename).to eq "a/b/c/file.txt"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "parses out attributes at top of the file" do
|
26
|
-
file = ExtraFileObject.new('file.txt', "# @title X\n# @some_attribute Y\nFOO BAR")
|
27
|
-
expect(file.attributes[:title]).to eq "X"
|
28
|
-
expect(file.attributes[:some_attribute]).to eq "Y"
|
29
|
-
expect(file.contents).to eq "FOO BAR"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "allows whitespace prior to '#' marker when parsing attributes" do
|
33
|
-
file = ExtraFileObject.new('file.txt', " \t # @title X\nFOO BAR")
|
34
|
-
expect(file.attributes[:title]).to eq "X"
|
35
|
-
expect(file.contents).to eq "FOO BAR"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "allows the attributes section to be wrapped in an HTML comment" do
|
39
|
-
file = ExtraFileObject.new('file.txt', "<!--\n# @title X\n-->\nFOO BAR")
|
40
|
-
expect(file.attributes[:title]).to eq "X"
|
41
|
-
expect(file.contents).to eq "FOO BAR"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "allows whitespace around ignored HTML comment" do
|
45
|
-
file = ExtraFileObject.new('file.txt', " \t <!-- \n# @title X\n \t --> \nFOO BAR")
|
46
|
-
expect(file.attributes[:title]).to eq "X"
|
47
|
-
expect(file.contents).to eq "FOO BAR"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "parses out old-style #!markup shebang format" do
|
51
|
-
file = ExtraFileObject.new('file.txt', "#!foobar\nHello")
|
52
|
-
expect(file.attributes[:markup]).to eq "foobar"
|
53
|
-
end
|
54
|
-
|
55
|
-
it "does not parse old-style #!markup if any whitespace is found" do
|
56
|
-
file = ExtraFileObject.new('file.txt', " #!foobar\nHello")
|
57
|
-
expect(file.attributes[:markup]).to be nil
|
58
|
-
expect(file.contents).to eq " #!foobar\nHello"
|
59
|
-
end
|
60
|
-
|
61
|
-
it "does not parse out attributes if there are newlines prior to attributes" do
|
62
|
-
file = ExtraFileObject.new('file.txt', "\n# @title\nFOO BAR")
|
63
|
-
expect(file.attributes).to be_empty
|
64
|
-
expect(file.contents).to eq "\n# @title\nFOO BAR"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "sets contents to data after attributes" do
|
68
|
-
file = ExtraFileObject.new('file.txt', "# @title\nFOO BAR")
|
69
|
-
expect(file.contents).to eq "FOO BAR"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "preserves newlines" do
|
73
|
-
file = ExtraFileObject.new('file.txt', "FOO\r\nBAR\nBAZ")
|
74
|
-
expect(file.contents).to eq "FOO\r\nBAR\nBAZ"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "does not include newlines in attribute data" do
|
78
|
-
file = ExtraFileObject.new('file.txt', "# @title FooBar\r\nHello world")
|
79
|
-
expect(file.attributes[:title]).to eq "FooBar"
|
80
|
-
end
|
81
|
-
|
82
|
-
it "forces encoding to @encoding attribute if present" do
|
83
|
-
expect(log).not_to receive(:warn)
|
84
|
-
data = String.new("# @encoding sjis\nFOO")
|
85
|
-
data.force_encoding('binary')
|
86
|
-
file = ExtraFileObject.new('file.txt', data)
|
87
|
-
expect(['Shift_JIS', 'Windows-31J']).to include(file.contents.encoding.to_s)
|
88
|
-
end if YARD.ruby19?
|
89
|
-
|
90
|
-
it "warns if @encoding is invalid" do
|
91
|
-
expect(log).to receive(:warn).with("Invalid encoding `INVALID' in file.txt")
|
92
|
-
data = String.new("# @encoding INVALID\nFOO")
|
93
|
-
encoding = data.encoding
|
94
|
-
file = ExtraFileObject.new('file.txt', data)
|
95
|
-
expect(file.contents.encoding).to eq encoding
|
96
|
-
end if YARD.ruby19?
|
97
|
-
|
98
|
-
it "ignores encoding in 1.8.x (or encoding-unaware platforms)" do
|
99
|
-
expect(log).not_to receive(:warn)
|
100
|
-
ExtraFileObject.new('file.txt', "# @encoding INVALID\nFOO")
|
101
|
-
end if YARD.ruby18?
|
102
|
-
|
103
|
-
it "attempts to re-parse data as 8-bit ascii if parsing fails" do
|
104
|
-
expect(log).not_to receive(:warn)
|
105
|
-
str, out = *([String.new("\xB0")] * 2)
|
106
|
-
if str.respond_to?(:force_encoding!)
|
107
|
-
str.force_encoding!('utf-8')
|
108
|
-
out.force_encoding!('binary')
|
109
|
-
end
|
110
|
-
expect(str.valid_encoding?).to be(false)
|
111
|
-
file = ExtraFileObject.new('file.txt', str)
|
112
|
-
expect(file.contents).to eq out
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "#name" do
|
117
|
-
it "returns basename (not extension) of filename" do
|
118
|
-
file = ExtraFileObject.new('file.txt', '')
|
119
|
-
expect(file.name).to eq 'file'
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe "#title" do
|
124
|
-
it "returns @title attribute if present" do
|
125
|
-
file = ExtraFileObject.new('file.txt', '# @title FOO')
|
126
|
-
expect(file.title).to eq 'FOO'
|
127
|
-
end
|
128
|
-
|
129
|
-
it "returns #name if no @title attribute exists" do
|
130
|
-
file = ExtraFileObject.new('file.txt', '')
|
131
|
-
expect(file.title).to eq 'file'
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe "#locale=" do
|
136
|
-
it "translates contents" do
|
137
|
-
file = ExtraFileObject.new('file.txt', 'Hello')
|
138
|
-
file.locale = 'fr'
|
139
|
-
fr_locale = I18n::Locale.new('fr')
|
140
|
-
fr_messages = fr_locale.instance_variable_get(:@messages)
|
141
|
-
fr_messages["Hello"] = 'Bonjour'
|
142
|
-
expect(Registry).to receive(:locale).with('fr').and_return(fr_locale)
|
143
|
-
expect(file.contents).to eq 'Bonjour'
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "#==" do
|
148
|
-
it "defines equality based on filename alone" do
|
149
|
-
file1 = ExtraFileObject.new('file.txt', 'A')
|
150
|
-
file2 = ExtraFileObject.new('file.txt', 'B')
|
151
|
-
expect(file1).to eq file2
|
152
|
-
expect(file1).to eql file2
|
153
|
-
expect(file1).to equal file2
|
154
|
-
|
155
|
-
# Another way to test the equality interface
|
156
|
-
a = [file1]
|
157
|
-
a |= [file2]
|
158
|
-
expect(a.size).to eq 1
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|