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
@@ -3,37 +3,37 @@ require 'ostruct'
|
|
3
3
|
|
4
4
|
describe YARD::Server::Commands::LibraryCommand do
|
5
5
|
before do
|
6
|
-
Templates::Engine.
|
7
|
-
Templates::Engine.
|
8
|
-
YARD.
|
9
|
-
Registry.
|
10
|
-
Registry.
|
6
|
+
allow(Templates::Engine).to receive(:render)
|
7
|
+
allow(Templates::Engine).to receive(:generate)
|
8
|
+
allow(YARD).to receive(:parse)
|
9
|
+
allow(Registry).to receive(:load)
|
10
|
+
allow(Registry).to receive(:save)
|
11
11
|
|
12
12
|
@cmd = LibraryCommand.new(:adapter => mock_adapter)
|
13
13
|
@request = OpenStruct.new(:xhr? => false, :path => "/foo")
|
14
14
|
@library = OpenStruct.new(:source_path => '.')
|
15
15
|
@cmd.library = @library
|
16
|
-
@cmd.
|
16
|
+
allow(@cmd).to receive(:load_yardoc).and_return(nil)
|
17
17
|
end
|
18
18
|
|
19
19
|
def call
|
20
|
-
|
20
|
+
expect { @cmd.call(@request) }.to raise_error(NotImplementedError)
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#call" do
|
24
|
-
it "
|
24
|
+
it "raises NotImplementedError" do
|
25
25
|
call
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "sets :rdoc as the default markup in incremental mode" do
|
29
29
|
@cmd.incremental = true
|
30
30
|
call
|
31
|
-
@cmd.options[:markup].
|
31
|
+
expect(@cmd.options[:markup]).to eq :rdoc
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "sets :rdoc as the default markup in regular mode" do
|
35
35
|
call
|
36
|
-
@cmd.options[:markup].
|
36
|
+
expect(@cmd.options[:markup]).to eq :rdoc
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -7,60 +7,60 @@ describe YARD::Server::Commands::StaticFileCommand do
|
|
7
7
|
@cmd = StaticFileCommand.new(:adapter => adapter)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe "#run" do
|
11
11
|
def run(path, status = nil, body = nil)
|
12
12
|
s, h, b = *@cmd.call(mock_request(path))
|
13
|
-
body.
|
14
|
-
status.
|
13
|
+
expect(body).to eq b.first if body
|
14
|
+
expect(status).to eq s if status
|
15
15
|
[s, h, b]
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
File.
|
18
|
+
it "searches through document root before static paths" do
|
19
|
+
expect(File).to receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
|
20
20
|
StaticFileCommand::STATIC_PATHS.reverse.each do |path|
|
21
|
-
File.
|
21
|
+
expect(File).to receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
|
22
22
|
end
|
23
23
|
run '/path/to/file.txt'
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "returns file contents if found" do
|
27
27
|
tpl = Templates::Engine.template(:default, :fulldoc, :html)
|
28
|
-
File.
|
29
|
-
tpl.
|
30
|
-
File.
|
28
|
+
expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(false)
|
29
|
+
expect(tpl).to receive(:find_file).with('/path/to/file.txt').and_return('/path/to/foo')
|
30
|
+
expect(File).to receive(:read).with('/path/to/foo').and_return('FOO')
|
31
31
|
run('/path/to/file.txt', 200, 'FOO')
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "allows registering of new paths and use those before other static paths" do
|
35
35
|
Server.register_static_path '/foo'
|
36
36
|
path = '/foo/path/to/file.txt'
|
37
|
-
File.
|
38
|
-
File.
|
39
|
-
File.
|
37
|
+
expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(false)
|
38
|
+
expect(File).to receive(:exist?).with(path).and_return(true)
|
39
|
+
expect(File).to receive(:read).with(path).and_return('FOO')
|
40
40
|
run('/path/to/file.txt', 200, 'FOO')
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "does not use registered path before docroot" do
|
44
44
|
Server.register_static_path '/foo'
|
45
45
|
path = '/foo/path/to/file.txt'
|
46
|
-
File.
|
47
|
-
File.
|
46
|
+
expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(true)
|
47
|
+
expect(File).to receive(:read).with('/c/path/to/file.txt').and_return('FOO')
|
48
48
|
run('/c/path/to/file.txt', 200, 'FOO')
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
52
|
-
File.
|
51
|
+
it "returns 404 if not found" do
|
52
|
+
expect(File).to receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
|
53
53
|
StaticFileCommand::STATIC_PATHS.reverse.each do |path|
|
54
|
-
File.
|
54
|
+
expect(File).to receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
|
55
55
|
end
|
56
56
|
run('/path/to/file.txt', 404)
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
60
|
-
File.
|
61
|
-
File.
|
59
|
+
it "returns text/html for file with no extension" do
|
60
|
+
expect(File).to receive(:exist?).with('/c/file').and_return(true)
|
61
|
+
expect(File).to receive(:read).with('/c/file')
|
62
62
|
s, h, b = *run('/file')
|
63
|
-
h['Content-Type'].
|
63
|
+
expect(h['Content-Type']).to eq 'text/html'
|
64
64
|
end
|
65
65
|
|
66
66
|
{
|
@@ -73,11 +73,11 @@ describe YARD::Server::Commands::StaticFileCommand do
|
|
73
73
|
"txt" => "text/plain",
|
74
74
|
"unknown" => "application/octet-stream"
|
75
75
|
}.each do |ext, mime|
|
76
|
-
it "
|
77
|
-
File.
|
78
|
-
File.
|
76
|
+
it "serves file.#{ext} as #{mime}" do
|
77
|
+
expect(File).to receive(:exist?).with('/c/file.' + ext).and_return(true)
|
78
|
+
expect(File).to receive(:read).with('/c/file.' + ext)
|
79
79
|
s, h, b = *run('/file.' + ext)
|
80
|
-
h['Content-Type'].
|
80
|
+
expect(h['Content-Type']).to eq mime
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -31,23 +31,23 @@ describe YARD::Server::DocServerHelper do
|
|
31
31
|
@helper = MockDocServerHelper.new
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
it "
|
34
|
+
describe "#url_for" do
|
35
|
+
it "does not link to /library/ if single_library = true" do
|
36
36
|
@helper.single_library = true
|
37
|
-
@helper.url_for(Registry.root).
|
37
|
+
expect(@helper.url_for(Registry.root)).to eq "/PREFIX/toplevel"
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "returns /PREFIX/foo/version if foo has a version" do
|
41
41
|
@helper.library = LibraryVersion.new('foo', 'bar')
|
42
42
|
@helper.adapter.router.request.version_supplied = true
|
43
|
-
@helper.url_for(P('A')).
|
43
|
+
expect(@helper.url_for(P('A'))).to eq '/PREFIX/foo/bar/A'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
describe
|
48
|
-
it "
|
47
|
+
describe "#url_for_file" do
|
48
|
+
it "properly links file objects using file/ prefix" do
|
49
49
|
file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
|
50
|
-
@helper.url_for_file(file).
|
50
|
+
expect(@helper.url_for_file(file)).to eq '/PREFIX/foo/file/a/b/FooBar.md'
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe YARD::Server::DocServerSerializer do
|
4
|
-
describe
|
4
|
+
describe "#serialized_path" do
|
5
5
|
before do
|
6
6
|
Registry.clear
|
7
7
|
@serializer = Server::DocServerSerializer.new
|
@@ -9,45 +9,50 @@ describe YARD::Server::DocServerSerializer do
|
|
9
9
|
|
10
10
|
after(:all) { Server::Adapter.shutdown }
|
11
11
|
|
12
|
-
it "
|
13
|
-
@serializer.serialized_path(Registry.root).
|
12
|
+
it "returns '/PREFIX/library/toplevel' for root" do
|
13
|
+
expect(@serializer.serialized_path(Registry.root)).to eq "toplevel"
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
@serializer.serialized_path(P('A::B::C')).
|
16
|
+
it "returns /PREFIX/library/Object for Object in a library" do
|
17
|
+
expect(@serializer.serialized_path(P('A::B::C'))).to eq 'A/B/C'
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "links to instance method as Class:method" do
|
21
21
|
obj = CodeObjects::MethodObject.new(:root, :method)
|
22
|
-
@serializer.serialized_path(obj).
|
22
|
+
expect(@serializer.serialized_path(obj)).to eq 'toplevel:method'
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
25
|
+
it "links to class method as Class.method" do
|
26
26
|
obj = CodeObjects::MethodObject.new(:root, :method, :class)
|
27
|
-
@serializer.serialized_path(obj).
|
27
|
+
expect(@serializer.serialized_path(obj)).to eq 'toplevel.method'
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
30
|
+
it "links to anchor for constant" do
|
31
31
|
obj = CodeObjects::ConstantObject.new(:root, :FOO)
|
32
|
-
@serializer.serialized_path(obj).
|
32
|
+
expect(@serializer.serialized_path(obj)).to eq 'toplevel#FOO-constant'
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "links to anchor for class variable" do
|
36
36
|
obj = CodeObjects::ClassVariableObject.new(:root, :@@foo)
|
37
|
-
@serializer.serialized_path(obj).
|
37
|
+
expect(@serializer.serialized_path(obj)).to eq 'toplevel#@@foo-classvariable'
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "links files using file/ prefix" do
|
41
41
|
file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
|
42
|
-
@serializer.serialized_path(file).
|
42
|
+
expect(@serializer.serialized_path(file)).to eq 'file/FooBar'
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "escapes special characters" do
|
46
|
+
obj = CodeObjects::MethodObject.new(:root, :method?)
|
47
|
+
expect(@serializer.serialized_path(obj)).to eq 'toplevel:method%3F'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "handles unicode data" do
|
46
51
|
file = CodeObjects::ExtraFileObject.new("test\u0160", '')
|
47
52
|
if file.name.encoding == Encoding.find("Windows-1252")
|
48
|
-
@serializer.serialized_path(file).
|
53
|
+
expect(@serializer.serialized_path(file)).to eq 'file/test_8A'
|
49
54
|
else
|
50
|
-
@serializer.serialized_path(file).
|
55
|
+
expect(@serializer.serialized_path(file)).to eq 'file/test_C5A0'
|
51
56
|
end
|
52
57
|
end if defined?(::Encoding)
|
53
58
|
end
|
@@ -3,18 +3,18 @@ require File.dirname(__FILE__) + "/spec_helper"
|
|
3
3
|
describe "YARD::Server::RackMiddleware" do
|
4
4
|
before do
|
5
5
|
begin; require 'rack'; rescue LoadError; pending "rack required for these tests" end
|
6
|
-
@superapp =
|
6
|
+
@superapp = double(:superapp)
|
7
7
|
@app = YARD::Server::RackMiddleware.new(@superapp, :libraries => {'foo' => [LibraryVersion.new('foo', nil)]})
|
8
8
|
end
|
9
9
|
|
10
10
|
after(:all) { YARD::Server::Adapter.shutdown }
|
11
11
|
|
12
|
-
it "
|
13
|
-
@app.call(Rack::MockRequest.env_for('/'))[0].
|
12
|
+
it "handles requests" do
|
13
|
+
expect(@app.call(Rack::MockRequest.env_for('/'))[0]).to eq 200
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
@superapp.
|
18
|
-
@app.call(Rack::MockRequest.env_for('/INVALID')).
|
16
|
+
it "passes up to the next middleware on 404" do
|
17
|
+
expect(@superapp).to receive(:call).and_return([200, {}, ['OK']])
|
18
|
+
expect(@app.call(Rack::MockRequest.env_for('/INVALID'))).to eq [200, {}, ['OK']]
|
19
19
|
end
|
20
20
|
end
|
data/spec/server/router_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe YARD::Server::Router do
|
|
15
15
|
@request = mock_request
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
18
|
+
describe "#parse_library_from_path" do
|
19
19
|
def parse(*args)
|
20
20
|
@request.path = '/' + args.join('/')
|
21
21
|
@router = MyRouterSpecRouter.new(@adapter)
|
@@ -23,36 +23,36 @@ describe YARD::Server::Router do
|
|
23
23
|
@router.parse_library_from_path(args.flatten)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
27
|
-
parse('project', '1.0.0').
|
28
|
-
@request.version_supplied.
|
26
|
+
it "parses library and version name out of path" do
|
27
|
+
expect(parse('project', '1.0.0')).to eq [@projects[0], []]
|
28
|
+
expect(@request.version_supplied).to be true
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
32
|
-
parse('project').
|
33
|
-
@request.version_supplied.
|
31
|
+
it "parses library and use latest version if version is not supplied" do
|
32
|
+
expect(parse('project')).to eq [@projects[1], []]
|
33
|
+
expect(@request.version_supplied).to be false
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
parse('project', 'notaversion').
|
38
|
-
@request.version_supplied.
|
36
|
+
it "parses library and use latest version if next component is not a version" do
|
37
|
+
expect(parse('project', 'notaversion')).to eq [@projects[1], ['notaversion']]
|
38
|
+
expect(@request.version_supplied).to be false
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
42
|
-
parse('notproject').
|
41
|
+
it "returns nil library if no library is found" do
|
42
|
+
expect(parse('notproject')).to eq [nil, ['notproject']]
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
46
|
-
@adapter.
|
47
|
-
parse('notproject').
|
45
|
+
it "does not parse library or version if single_library == true" do
|
46
|
+
allow(@adapter).to receive(:options).and_return(:single_library => true)
|
47
|
+
expect(parse('notproject')).to eq [@projects[0], ['notproject']]
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
describe
|
51
|
+
describe "#route" do
|
52
52
|
def route_to(route, command, *args)
|
53
53
|
req = mock_request(route)
|
54
54
|
router = MyRouterSpecRouter.new(@adapter)
|
55
|
-
command.
|
55
|
+
expect(command).to receive(:new) do |*args|
|
56
56
|
@command = command.allocate
|
57
57
|
@command.send(:initialize, *args)
|
58
58
|
class << @command; def call(req); self end end
|
@@ -61,61 +61,61 @@ describe YARD::Server::Router do
|
|
61
61
|
router.call(req)
|
62
62
|
end
|
63
63
|
|
64
|
-
it "
|
65
|
-
@adapter.
|
64
|
+
it "routes /docs/OBJECT to object if single_library = true" do
|
65
|
+
allow(@adapter).to receive(:options).and_return(:single_library => true)
|
66
66
|
route_to('/mydocs/foo/FOO', DisplayObjectCommand)
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
69
|
+
it "routes /docs" do
|
70
70
|
route_to('/mydocs/foo', LibraryIndexCommand)
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
74
|
-
@adapter.
|
73
|
+
it "routes /docs as index for library if single_library == true" do
|
74
|
+
allow(@adapter).to receive(:options).and_return(:single_library => true)
|
75
75
|
route_to('/mydocs/foo/', DisplayObjectCommand)
|
76
76
|
end
|
77
77
|
|
78
|
-
it "
|
78
|
+
it "routes /docs/name/version" do
|
79
79
|
route_to('/mydocs/foo/project/1.0.0', DisplayObjectCommand)
|
80
|
-
@command.library.
|
80
|
+
expect(@command.library).to eq @projects[0]
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
83
|
+
it "routes /docs/name/ to latest version of library" do
|
84
84
|
route_to('/mydocs/foo/project', DisplayObjectCommand)
|
85
|
-
@command.library.
|
85
|
+
expect(@command.library).to eq @projects[1]
|
86
86
|
end
|
87
87
|
|
88
|
-
it "
|
88
|
+
it "routes /list/name/version/class" do
|
89
89
|
route_to('/mylist/foo/project/1.0.0/class', ListCommand)
|
90
|
-
@command.library.
|
90
|
+
expect(@command.library).to eq @projects[0]
|
91
91
|
end
|
92
92
|
|
93
|
-
it "
|
93
|
+
it "routes /list/name/version/methods" do
|
94
94
|
route_to('/mylist/foo/project/1.0.0/methods', ListCommand)
|
95
|
-
@command.library.
|
95
|
+
expect(@command.library).to eq @projects[0]
|
96
96
|
end
|
97
97
|
|
98
|
-
it "
|
98
|
+
it "routes /list/name/version/files" do
|
99
99
|
route_to('/mylist/foo/project/1.0.0/files', ListCommand)
|
100
|
-
@command.library.
|
100
|
+
expect(@command.library).to eq @projects[0]
|
101
101
|
end
|
102
102
|
|
103
|
-
it "
|
103
|
+
it "routes /list/name to latest version of library" do
|
104
104
|
route_to('/mylist/foo/project/class', ListCommand)
|
105
|
-
@command.library.
|
105
|
+
expect(@command.library).to eq @projects[1]
|
106
106
|
end
|
107
107
|
|
108
|
-
it "
|
108
|
+
it "routes /search/name/version" do
|
109
109
|
route_to('/mysearch/foo/project/1.0.0', SearchCommand)
|
110
|
-
@command.library.
|
110
|
+
expect(@command.library).to eq @projects[0]
|
111
111
|
end
|
112
112
|
|
113
|
-
it "
|
113
|
+
it "routes /search/name to latest version of library" do
|
114
114
|
route_to('/mysearch/foo/project', SearchCommand)
|
115
|
-
@command.library.
|
115
|
+
expect(@command.library).to eq @projects[1]
|
116
116
|
end
|
117
117
|
|
118
|
-
it "
|
118
|
+
it "searches static files for non-existent library" do
|
119
119
|
route_to('/mydocs/foo/notproject', StaticFileCommand)
|
120
120
|
end
|
121
121
|
end
|
@@ -3,37 +3,37 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe YARD::Server::StaticCaching do
|
4
4
|
include StaticCaching
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe "#check_static_cache" do
|
7
7
|
def adapter; @adapter ||= mock_adapter end
|
8
8
|
def request; @request ||= OpenStruct.new end
|
9
9
|
|
10
|
-
it "
|
10
|
+
it "returns nil if document root is not set" do
|
11
11
|
adapter.document_root = nil
|
12
|
-
check_static_cache.
|
12
|
+
expect(check_static_cache).to be nil
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "reads a file from document root if path matches file on system" do
|
16
16
|
request.path = '/hello/world.html'
|
17
|
-
File.
|
18
|
-
File.
|
17
|
+
expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true)
|
18
|
+
expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body')
|
19
19
|
s, h, b = *check_static_cache
|
20
|
-
s.
|
21
|
-
b.
|
20
|
+
expect(s).to eq 200
|
21
|
+
expect(b).to eq ["body"]
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "reads a file if path matches file on system + .html" do
|
25
25
|
request.path = '/hello/world'
|
26
|
-
File.
|
27
|
-
File.
|
26
|
+
expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true)
|
27
|
+
expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body')
|
28
28
|
s, h, b = *check_static_cache
|
29
|
-
s.
|
30
|
-
b.
|
29
|
+
expect(s).to eq 200
|
30
|
+
expect(b).to eq ["body"]
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "returns nil if no matching file is found" do
|
34
34
|
request.path = '/hello/foo'
|
35
|
-
File.
|
36
|
-
check_static_cache.
|
35
|
+
expect(File).to receive(:file?).with('/public/hello/foo.html').and_return(false)
|
36
|
+
expect(check_static_cache).to eq nil
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|