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/config_spec.rb
CHANGED
@@ -3,174 +3,174 @@ require File.join(File.dirname(__FILE__), "spec_helper")
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
describe YARD::Config do
|
6
|
-
describe
|
6
|
+
describe ".load" do
|
7
7
|
before do
|
8
|
-
File.
|
8
|
+
expect(File).to receive(:file?).twice.with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
File.
|
13
|
-
File.
|
11
|
+
it "uses default options if no ~/.yard/config is found" do
|
12
|
+
expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
|
13
|
+
expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
|
14
14
|
YARD::Config.load
|
15
|
-
YARD::Config.options.
|
15
|
+
expect(YARD::Config.options).to eq YARD::Config::DEFAULT_CONFIG_OPTIONS
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
File.
|
20
|
-
File.
|
21
|
-
YAML.
|
18
|
+
it "overwrites options with data in ~/.yard/config" do
|
19
|
+
expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(true)
|
20
|
+
expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
|
21
|
+
expect(YAML).to receive(:load_file).with(YARD::Config::CONFIG_FILE).and_return({'test' => true})
|
22
22
|
YARD::Config.load
|
23
|
-
YARD::Config.options[:test].
|
23
|
+
expect(YARD::Config.options[:test]).to be true
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
27
|
-
File.
|
28
|
-
File.
|
29
|
-
File.
|
26
|
+
it "ignores any plugins specified in '~/.yard/ignored_plugins'" do
|
27
|
+
expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
|
28
|
+
expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(true)
|
29
|
+
expect(File).to receive(:read).with(YARD::Config::IGNORED_PLUGINS).and_return('yard-plugin plugin2')
|
30
30
|
YARD::Config.load
|
31
|
-
YARD::Config.options[:ignored_plugins].
|
32
|
-
YARD::Config.
|
33
|
-
YARD::Config.load_plugin('yard-plugin2').
|
31
|
+
expect(YARD::Config.options[:ignored_plugins]).to eq ['yard-plugin', 'yard-plugin2']
|
32
|
+
expect(YARD::Config).not_to receive(:require).with('yard-plugin2')
|
33
|
+
expect(YARD::Config.load_plugin('yard-plugin2')).to be false
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
File.
|
38
|
-
File.
|
36
|
+
it "loads safe_mode setting from --safe command line option" do
|
37
|
+
expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
|
38
|
+
expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
|
39
39
|
ARGV.replace(['--safe'])
|
40
40
|
YARD::Config.load
|
41
|
-
YARD::Config.options[:safe_mode].
|
41
|
+
expect(YARD::Config.options[:safe_mode]).to be true
|
42
42
|
ARGV.replace([''])
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
47
|
-
it "
|
48
|
-
YARD::Config.
|
49
|
-
file =
|
50
|
-
File.
|
51
|
-
file.
|
46
|
+
describe ".save" do
|
47
|
+
it "saves options to config file" do
|
48
|
+
allow(YARD::Config).to receive(:options).and_return(:a => 1, :b => %w(a b c))
|
49
|
+
file = double(:file)
|
50
|
+
expect(File).to receive(:open).with(YARD::Config::CONFIG_FILE, 'w').and_yield(file)
|
51
|
+
expect(file).to receive(:write).with(YAML.dump(:a => 1, :b => %w(a b c)))
|
52
52
|
YARD::Config.save
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
57
|
-
it "
|
58
|
-
YARD::Config.
|
59
|
-
log.
|
60
|
-
YARD::Config.load_plugin('foo').
|
56
|
+
describe ".load_plugin" do
|
57
|
+
it "loads a plugin by 'name' as 'yard-name'" do
|
58
|
+
expect(YARD::Config).to receive(:require).with('yard-foo')
|
59
|
+
expect(log).to receive(:debug).with(/Loading plugin 'yard-foo'/).once
|
60
|
+
expect(YARD::Config.load_plugin('foo')).to be true
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
64
|
-
YARD::Config.
|
63
|
+
it "does not load plugins like 'doc-*'" do
|
64
|
+
expect(YARD::Config).not_to receive(:require).with('yard-doc-core')
|
65
65
|
YARD::Config.load_plugin('doc-core')
|
66
66
|
YARD::Config.load_plugin('yard-doc-core')
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
70
|
-
YARD::Config.
|
71
|
-
log.
|
72
|
-
YARD::Config.load_plugin('yard-foo').
|
69
|
+
it "loads plugin by 'yard-name' as 'yard-name'" do
|
70
|
+
expect(YARD::Config).to receive(:require).with('yard-foo')
|
71
|
+
expect(log).to receive(:debug).with(/Loading plugin 'yard-foo'/).once
|
72
|
+
expect(YARD::Config.load_plugin('yard-foo')).to be true
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
76
|
-
YARD::Config.
|
77
|
-
log.
|
75
|
+
it "loads plugin by 'yard_name' as 'yard_name'" do
|
76
|
+
expect(YARD::Config).to receive(:require).with('yard_foo')
|
77
|
+
expect(log).to receive(:debug).with(/Loading plugin 'yard_foo'/).once
|
78
78
|
log.show_backtraces = false
|
79
|
-
YARD::Config.load_plugin('yard_foo').
|
79
|
+
expect(YARD::Config.load_plugin('yard_foo')).to be true
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
83
|
-
YARD::Config.
|
84
|
-
log.
|
85
|
-
YARD::Config.load_plugin('yard-foo').
|
82
|
+
it "logs error if plugin is not found" do
|
83
|
+
expect(YARD::Config).to receive(:require).with('yard-foo').and_raise(LoadError)
|
84
|
+
expect(log).to receive(:warn).with(/Error loading plugin 'yard-foo'/).once
|
85
|
+
expect(YARD::Config.load_plugin('yard-foo')).to be false
|
86
86
|
end
|
87
87
|
|
88
|
-
it "
|
89
|
-
YARD::Config.
|
90
|
-
YARD::Config.load_plugin('foo/foo').
|
88
|
+
it "sanitizes plugin name (remove /'s)" do
|
89
|
+
expect(YARD::Config).to receive(:require).with('yard-foofoo')
|
90
|
+
expect(YARD::Config.load_plugin('foo/foo')).to be true
|
91
91
|
end
|
92
92
|
|
93
|
-
it "
|
94
|
-
YARD::Config.
|
95
|
-
YARD::Config.load_plugin('foo').
|
96
|
-
YARD::Config.load_plugin('bar').
|
93
|
+
it "ignores plugins in :ignore_plugins" do
|
94
|
+
allow(YARD::Config).to receive(:options).and_return(:ignored_plugins => ['yard-foo', 'yard-bar'])
|
95
|
+
expect(YARD::Config.load_plugin('foo')).to be false
|
96
|
+
expect(YARD::Config.load_plugin('bar')).to be false
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
describe
|
101
|
-
it "
|
102
|
-
YARD::Config.
|
103
|
-
YARD::Config.
|
104
|
-
YARD::Config.
|
100
|
+
describe ".load_plugins" do
|
101
|
+
it "loads gem plugins if :load_plugins is true" do
|
102
|
+
allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
|
103
|
+
allow(YARD::Config).to receive(:load_plugin)
|
104
|
+
expect(YARD::Config).to receive(:require).with('rubygems')
|
105
105
|
YARD::Config.load_plugins
|
106
106
|
end
|
107
107
|
|
108
|
-
it "
|
109
|
-
YARD::Config.
|
110
|
-
YARD::Config.
|
111
|
-
YARD::Config.load_plugins.
|
108
|
+
it "ignores gem loading if RubyGems cannot load" do
|
109
|
+
allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
|
110
|
+
expect(YARD::Config).to receive(:require).with('rubygems').and_raise(LoadError)
|
111
|
+
expect(YARD::Config.load_plugins).to be false
|
112
112
|
end
|
113
113
|
|
114
|
-
it "
|
115
|
-
File.
|
116
|
-
YARD::Config.
|
117
|
-
YARD::Config.
|
118
|
-
YARD::Config.load_plugins.
|
114
|
+
it "loads certain plugins automatically when specified in :autoload_plugins" do
|
115
|
+
expect(File).to receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
|
116
|
+
allow(YARD::Config).to receive(:options).and_return(:load_plugins => false, :ignored_plugins => [], :autoload_plugins => ['yard-plugin'])
|
117
|
+
expect(YARD::Config).to receive(:require).with('yard-plugin').and_return(true)
|
118
|
+
expect(YARD::Config.load_plugins).to be true
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
122
|
-
YARD::Config.
|
123
|
-
YARD::Config.
|
124
|
-
YARD::Config.
|
125
|
-
YARD::Config.load_plugins.
|
121
|
+
it "parses --plugin from command line arguments" do
|
122
|
+
expect(YARD::Config).to receive(:arguments).at_least(1).times.and_return(%w(--plugin foo --plugin bar a b c))
|
123
|
+
expect(YARD::Config).to receive(:load_plugin).with('foo').and_return(true)
|
124
|
+
expect(YARD::Config).to receive(:load_plugin).with('bar').and_return(true)
|
125
|
+
expect(YARD::Config.load_plugins).to be true
|
126
126
|
end
|
127
127
|
|
128
|
-
it "
|
129
|
-
File.
|
130
|
-
File.
|
131
|
-
File.
|
132
|
-
File.
|
133
|
-
YARD::Config.
|
128
|
+
it "loads --plugin arguments from .yardopts" do
|
129
|
+
expect(File).to receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).twice.and_return(true)
|
130
|
+
expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
|
131
|
+
expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
|
132
|
+
expect(File).to receive(:read_binary).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).twice.and_return('--plugin foo')
|
133
|
+
expect(YARD::Config).to receive(:load_plugin).with('foo')
|
134
134
|
YARD::Config.load
|
135
135
|
end
|
136
136
|
|
137
|
-
it "
|
138
|
-
File.
|
139
|
-
YARD::Config.
|
137
|
+
it "loads any gem plugins starting with 'yard_' or 'yard-'" do
|
138
|
+
expect(File).to receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
|
139
|
+
allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => ['yard_plugin'], :autoload_plugins => [])
|
140
140
|
plugins = {
|
141
|
-
'yard' =>
|
142
|
-
'yard_plugin' =>
|
143
|
-
'yard-plugin' =>
|
144
|
-
'my-yard-plugin' =>
|
145
|
-
'rspec' =>
|
141
|
+
'yard' => double('yard'),
|
142
|
+
'yard_plugin' => double('yard_plugin'),
|
143
|
+
'yard-plugin' => double('yard-plugin'),
|
144
|
+
'my-yard-plugin' => double('yard-plugin'),
|
145
|
+
'rspec' => double('rspec'),
|
146
146
|
}
|
147
147
|
plugins.each do |k, v|
|
148
|
-
v.
|
148
|
+
expect(v).to receive(:name).at_least(1).times.and_return(k)
|
149
149
|
end
|
150
150
|
|
151
|
-
source_mock =
|
152
|
-
source_mock.
|
153
|
-
Gem.
|
154
|
-
YARD::Config.
|
155
|
-
YARD::Config.
|
156
|
-
YARD::Config.load_plugins.
|
151
|
+
source_mock = double(:source_index)
|
152
|
+
expect(source_mock).to receive(:find_name).with('').and_return(plugins.values)
|
153
|
+
expect(Gem).to receive(:source_index).and_return(source_mock)
|
154
|
+
expect(YARD::Config).to receive(:load_plugin).with('yard_plugin').and_return(false)
|
155
|
+
expect(YARD::Config).to receive(:load_plugin).with('yard-plugin').and_return(true)
|
156
|
+
expect(YARD::Config.load_plugins).to be true
|
157
157
|
end
|
158
158
|
|
159
|
-
it "
|
160
|
-
YARD::Config.
|
159
|
+
it "logs an error if a gem raises an error" do
|
160
|
+
allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
|
161
161
|
plugins = {
|
162
|
-
'yard-plugin' =>
|
162
|
+
'yard-plugin' => double('yard-plugin')
|
163
163
|
}
|
164
164
|
plugins.each do |k, v|
|
165
|
-
v.
|
165
|
+
expect(v).to receive(:name).at_least(1).times.and_return(k)
|
166
166
|
end
|
167
167
|
|
168
|
-
source_mock =
|
169
|
-
source_mock.
|
170
|
-
Gem.
|
171
|
-
YARD::Config.
|
172
|
-
log.
|
173
|
-
YARD::Config.load_plugins.
|
168
|
+
source_mock = double(:source_index)
|
169
|
+
expect(source_mock).to receive(:find_name).with('').and_return(plugins.values)
|
170
|
+
expect(Gem).to receive(:source_index).and_return(source_mock)
|
171
|
+
expect(YARD::Config).to receive(:load_plugin).with('yard-plugin').and_raise(Gem::LoadError)
|
172
|
+
expect(log).to receive(:warn).with(/Error loading plugin 'yard-plugin'/)
|
173
|
+
expect(YARD::Config.load_plugins).to be false
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
data/spec/core_ext/array_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe Array do
|
4
|
-
describe
|
5
|
-
it "
|
6
|
-
[].place('x').
|
4
|
+
describe "#place" do
|
5
|
+
it "creates an Insertion object" do
|
6
|
+
expect([].place('x')).to be_kind_of(Insertion)
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
10
|
-
[1, 2].place('x', 'y', 'z').before(2).
|
9
|
+
it "allows multiple objects to be placed" do
|
10
|
+
expect([1, 2].place('x', 'y', 'z').before(2)).to eq [1, 'x', 'y', 'z', 2]
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/spec/core_ext/file_spec.rb
CHANGED
@@ -2,66 +2,66 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
|
3
3
|
describe File do
|
4
4
|
describe ".relative_path" do
|
5
|
-
it "
|
6
|
-
File.relative_path('a/b/c/d.html', 'a/b/d/q.html').
|
5
|
+
it "returns the relative path between two files" do
|
6
|
+
expect(File.relative_path('a/b/c/d.html', 'a/b/d/q.html')).to eq '../d/q.html'
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
10
|
-
File.relative_path('a/b/c/d/', 'a/b/d/').
|
9
|
+
it "returns the relative path between two directories" do
|
10
|
+
expect(File.relative_path('a/b/c/d/', 'a/b/d/')).to eq '../d'
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
14
|
-
File.relative_path('a/b/c/d', 'a/b/c/e').
|
13
|
+
it "returns only the to file if from file is in the same directory as the to file" do
|
14
|
+
expect(File.relative_path('a/b/c/d', 'a/b/c/e')).to eq 'e'
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
File.relative_path('Hello/./I/Am/Fred', 'Hello/Fred').
|
19
|
-
File.relative_path('A//B/C', 'Q/X').
|
17
|
+
it "handles non-normalized paths" do
|
18
|
+
expect(File.relative_path('Hello/./I/Am/Fred', 'Hello/Fred')).to eq '../../Fred'
|
19
|
+
expect(File.relative_path('A//B/C', 'Q/X')).to eq '../../Q/X'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it "
|
25
|
-
File.cleanpath('A//B/C').
|
23
|
+
describe ".cleanpath" do
|
24
|
+
it "cleans double brackets" do
|
25
|
+
expect(File.cleanpath('A//B/C')).to eq "A/B/C"
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
File.cleanpath('Hello/./I/.Am/Fred').
|
28
|
+
it "cleans a path with ." do
|
29
|
+
expect(File.cleanpath('Hello/./I/.Am/Fred')).to eq "Hello/I/.Am/Fred"
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
33
|
-
File.cleanpath('Hello/../World').
|
32
|
+
it "cleans a path with .." do
|
33
|
+
expect(File.cleanpath('Hello/../World')).to eq "World"
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
File.cleanpath('A/B/C/../../D').
|
36
|
+
it "cleans a path with multiple .." do
|
37
|
+
expect(File.cleanpath('A/B/C/../../D')).to eq "A/D"
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
41
|
-
File.cleanpath('A/B/C/D/..').
|
40
|
+
it "cleans a path ending in .." do
|
41
|
+
expect(File.cleanpath('A/B/C/D/..')).to eq "A/B/C"
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
45
|
-
File.cleanpath('C/../../D').
|
44
|
+
it "passes the initial directory" do
|
45
|
+
expect(File.cleanpath('C/../../D')).to eq "../D"
|
46
46
|
end
|
47
47
|
|
48
|
-
it "
|
49
|
-
File.cleanpath('../../A/B').
|
48
|
+
it "does not remove multiple '../' at the beginning" do
|
49
|
+
expect(File.cleanpath('../../A/B')).to eq '../../A/B'
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
describe
|
54
|
-
it "
|
55
|
-
File.
|
56
|
-
FileUtils.
|
57
|
-
File.
|
53
|
+
describe ".open!" do
|
54
|
+
it "creates the path before opening" do
|
55
|
+
expect(File).to receive(:directory?).with('/path/to').and_return(false)
|
56
|
+
expect(FileUtils).to receive(:mkdir_p).with('/path/to')
|
57
|
+
expect(File).to receive(:open).with('/path/to/file', 'w')
|
58
58
|
File.open!('/path/to/file', 'w')
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
62
|
-
File.
|
63
|
-
FileUtils.
|
64
|
-
File.
|
61
|
+
it "just opens the file if the path exists" do
|
62
|
+
expect(File).to receive(:directory?).with('/path/to').and_return(true)
|
63
|
+
expect(FileUtils).not_to receive(:mkdir_p)
|
64
|
+
expect(File).to receive(:open).with('/path/to/file', 'w')
|
65
65
|
File.open!('/path/to/file', 'w')
|
66
66
|
end
|
67
67
|
end
|
data/spec/core_ext/hash_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe Hash do
|
4
|
-
describe
|
5
|
-
it "
|
4
|
+
describe ".[]" do
|
5
|
+
it "accepts an Array argument (Ruby 1.8.6 and older)" do
|
6
6
|
list = [['foo', 'bar'], ['foo2', 'bar2']]
|
7
|
-
Hash[list].
|
7
|
+
expect(Hash[list]).to eq({'foo' => 'bar', 'foo2' => 'bar2'})
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
Hash[['a', 'b'], 1].
|
10
|
+
it "accepts an array as a key" do
|
11
|
+
expect(Hash[['a', 'b'], 1]).to eq({['a', 'b'] => 1})
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,37 +1,37 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe Insertion do
|
4
|
-
describe
|
5
|
-
it "
|
6
|
-
[1, 2].place(3).before(2).
|
7
|
-
[1, 2].place(3).before(1).
|
8
|
-
[1, [4], 2].place(3).before(2).
|
4
|
+
describe "#before" do
|
5
|
+
it "places an object before another" do
|
6
|
+
expect([1, 2].place(3).before(2)).to eq [1, 3, 2]
|
7
|
+
expect([1, 2].place(3).before(1)).to eq [3, 1, 2]
|
8
|
+
expect([1, [4], 2].place(3).before(2)).to eq [1, [4], 3, 2]
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it "
|
14
|
-
[1, 2].place(3).after(2).
|
12
|
+
describe "#after" do
|
13
|
+
it "places an object after another" do
|
14
|
+
expect([1, 2].place(3).after(2)).to eq [1, 2, 3]
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
[1, [2]].place(3).after(1).
|
17
|
+
it "no longer places an object after another and its subsections (0.6)" do
|
18
|
+
expect([1, [2]].place(3).after(1)).to eq [1, 3, [2]]
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
22
|
-
[1, 2, 3].place([4]).after(1).
|
21
|
+
it "places an array after an object" do
|
22
|
+
expect([1, 2, 3].place([4]).after(1)).to eq [1, [4], 2, 3]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
27
|
-
it "
|
28
|
-
[1, 2, [3]].place(4).before_any(3).
|
26
|
+
describe "#before_any" do
|
27
|
+
it "places an object before another anywhere inside list (including sublists)" do
|
28
|
+
expect([1, 2, [3]].place(4).before_any(3)).to eq [1, 2, [4, 3]]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it "
|
34
|
-
[1, 2, [3]].place(4).after_any(3).
|
32
|
+
describe "#after_any" do
|
33
|
+
it "places an object after another anywhere inside list (including sublists)" do
|
34
|
+
expect([1, 2, [3]].place(4).after_any(3)).to eq [1, 2, [3, 4]]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|