yard 0.7.5 → 0.8.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.
- data/.yardopts +10 -2
- data/ChangeLog +1263 -38
- data/LEGAL +5 -5
- data/LICENSE +1 -1
- data/README.md +91 -82
- data/Rakefile +6 -6
- data/benchmarks/builtins_vs_eval.rb +1 -1
- data/benchmarks/erb_vs_erubis.rb +4 -4
- data/benchmarks/generation.rb +5 -5
- data/benchmarks/parsing.rb +2 -2
- data/benchmarks/registry_store_types.rb +48 -0
- data/bin/yard +9 -1
- data/bin/yardoc +9 -1
- data/bin/yri +10 -2
- data/docs/CodeObjects.md +10 -10
- data/docs/GettingStarted.md +85 -83
- data/docs/Handlers.md +21 -21
- data/docs/Overview.md +7 -7
- data/docs/Parser.md +30 -30
- data/docs/Tags.md +250 -554
- data/docs/TagsArch.md +123 -0
- data/docs/Templates.md +58 -80
- data/docs/WhatsNew.md +378 -133
- data/docs/templates/default/fulldoc/html/full_list_tag.erb +7 -0
- data/docs/templates/default/fulldoc/html/setup.rb +6 -0
- data/docs/templates/default/layout/html/setup.rb +8 -0
- data/docs/templates/default/layout/html/tag_list.erb +11 -0
- data/docs/templates/default/yard_tags/html/list.erb +18 -0
- data/docs/templates/default/yard_tags/html/setup.rb +27 -0
- data/docs/templates/plugin.rb +65 -0
- data/lib/yard.rb +1 -10
- data/lib/yard/autoload.rb +75 -27
- data/lib/yard/cli/command.rb +5 -2
- data/lib/yard/cli/command_parser.rb +3 -2
- data/lib/yard/cli/diff.rb +1 -1
- data/lib/yard/cli/i18n.rb +69 -0
- data/lib/yard/cli/list.rb +1 -1
- data/lib/yard/cli/server.rb +30 -7
- data/lib/yard/cli/stats.rb +5 -6
- data/lib/yard/cli/yardoc.rb +95 -45
- data/lib/yard/cli/yri.rb +24 -3
- data/lib/yard/code_objects/base.rb +35 -4
- data/lib/yard/code_objects/extra_file_object.rb +1 -1
- data/lib/yard/code_objects/macro_object.rb +56 -99
- data/lib/yard/code_objects/method_object.rb +44 -6
- data/lib/yard/config.rb +18 -8
- data/lib/yard/core_ext/symbol_hash.rb +1 -1
- data/lib/yard/docstring.rb +45 -85
- data/lib/yard/docstring_parser.rb +269 -0
- data/lib/yard/handlers/base.rb +129 -118
- data/lib/yard/handlers/c/alias_handler.rb +15 -0
- data/lib/yard/handlers/c/attribute_handler.rb +13 -0
- data/lib/yard/handlers/c/base.rb +110 -0
- data/lib/yard/handlers/c/class_handler.rb +26 -0
- data/lib/yard/handlers/c/constant_handler.rb +12 -0
- data/lib/yard/handlers/c/handler_methods.rb +165 -0
- data/lib/yard/handlers/c/init_handler.rb +16 -0
- data/lib/yard/handlers/c/method_handler.rb +35 -0
- data/lib/yard/handlers/c/mixin_handler.rb +13 -0
- data/lib/yard/handlers/c/module_handler.rb +16 -0
- data/lib/yard/handlers/c/override_comment_handler.rb +22 -0
- data/lib/yard/handlers/c/path_handler.rb +10 -0
- data/lib/yard/handlers/c/struct_handler.rb +12 -0
- data/lib/yard/handlers/c/symbol_handler.rb +7 -0
- data/lib/yard/handlers/processor.rb +41 -30
- data/lib/yard/handlers/ruby/alias_handler.rb +0 -2
- data/lib/yard/handlers/ruby/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/base.rb +10 -6
- data/lib/yard/handlers/ruby/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/dsl_handler.rb +14 -0
- data/lib/yard/handlers/ruby/dsl_handler_methods.rb +71 -0
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +0 -3
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +16 -17
- data/lib/yard/handlers/ruby/legacy/base.rb +28 -6
- data/lib/yard/handlers/ruby/legacy/comment_handler.rb +9 -0
- data/lib/yard/handlers/ruby/legacy/dsl_handler.rb +16 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +0 -2
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/module_function_handler.rb +18 -0
- data/lib/yard/handlers/ruby/method_handler.rb +10 -15
- data/lib/yard/handlers/ruby/mixin_handler.rb +1 -1
- data/lib/yard/handlers/ruby/module_function_handler.rb +26 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +3 -2
- data/lib/yard/i18n/pot_generator.rb +281 -0
- data/lib/yard/i18n/text.rb +72 -0
- data/lib/yard/logging.rb +3 -7
- data/lib/yard/options.rb +216 -0
- data/lib/yard/parser/c/c_parser.rb +225 -0
- data/lib/yard/parser/c/comment_parser.rb +131 -0
- data/lib/yard/parser/c/statement.rb +63 -0
- data/lib/yard/parser/ruby/ast_node.rb +91 -1
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +1 -0
- data/lib/yard/parser/ruby/legacy/statement.rb +7 -2
- data/lib/yard/parser/ruby/legacy/statement_list.rb +13 -22
- data/lib/yard/parser/ruby/ruby_parser.rb +87 -26
- data/lib/yard/parser/source_parser.rb +89 -88
- data/lib/yard/rake/yardoc_task.rb +1 -1
- data/lib/yard/registry.rb +21 -10
- data/lib/yard/registry_store.rb +48 -0
- data/lib/yard/serializers/file_system_serializer.rb +18 -20
- data/lib/yard/serializers/yardoc_serializer.rb +1 -0
- data/lib/yard/server/adapter.rb +2 -2
- data/lib/yard/server/commands/base.rb +1 -1
- data/lib/yard/server/commands/display_object_command.rb +13 -6
- data/lib/yard/server/commands/frames_command.rb +4 -21
- data/lib/yard/server/commands/library_command.rb +57 -11
- data/lib/yard/server/commands/list_command.rb +10 -34
- data/lib/yard/server/commands/search_command.rb +8 -2
- data/lib/yard/server/doc_server_helper.rb +34 -0
- data/lib/yard/server/rack_adapter.rb +5 -1
- data/lib/yard/server/router.rb +4 -10
- data/lib/yard/server/static_caching.rb +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +2 -2
- data/lib/yard/server/templates/default/fulldoc/html/js/live.js +0 -15
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +3 -3
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +8 -0
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
- data/lib/yard/server/templates/doc_server/search/html/setup.rb +1 -1
- data/lib/yard/tags/default_factory.rb +31 -4
- data/lib/yard/tags/directives.rb +593 -0
- data/lib/yard/tags/library.rb +437 -35
- data/lib/yard/templates/engine.rb +17 -12
- data/lib/yard/templates/helpers/base_helper.rb +8 -2
- data/lib/yard/templates/helpers/html_helper.rb +57 -14
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +1 -1
- data/lib/yard/templates/helpers/markup_helper.rb +9 -9
- data/lib/yard/templates/helpers/text_helper.rb +2 -2
- data/lib/yard/templates/template.rb +42 -13
- data/lib/yard/templates/template_options.rb +81 -0
- data/spec/cli/command_parser_spec.rb +4 -4
- data/spec/cli/command_spec.rb +3 -3
- data/spec/cli/config_spec.rb +13 -13
- data/spec/cli/diff_spec.rb +13 -10
- data/spec/cli/gems_spec.rb +12 -12
- data/spec/cli/help_spec.rb +2 -2
- data/spec/cli/i18n_spec.rb +111 -0
- data/spec/cli/server_spec.rb +66 -18
- data/spec/cli/stats_spec.rb +15 -15
- data/spec/cli/yardoc_spec.rb +124 -97
- data/spec/cli/yri_spec.rb +14 -12
- data/spec/code_objects/base_spec.rb +104 -46
- data/spec/code_objects/class_object_spec.rb +33 -33
- data/spec/code_objects/code_object_list_spec.rb +5 -5
- data/spec/code_objects/constants_spec.rb +4 -3
- data/spec/code_objects/extra_file_object_spec.rb +19 -19
- data/spec/code_objects/macro_object_spec.rb +31 -37
- data/spec/code_objects/method_object_spec.rb +46 -23
- data/spec/code_objects/module_object_spec.rb +16 -16
- data/spec/code_objects/namespace_object_spec.rb +6 -6
- data/spec/code_objects/proxy_spec.rb +19 -19
- data/spec/config_spec.rb +33 -24
- data/spec/core_ext/array_spec.rb +1 -1
- data/spec/core_ext/file_spec.rb +8 -8
- data/spec/core_ext/hash_spec.rb +1 -1
- data/spec/core_ext/insertion_spec.rb +3 -3
- data/spec/core_ext/module_spec.rb +1 -1
- data/spec/core_ext/string_spec.rb +6 -6
- data/spec/core_ext/symbol_hash_spec.rb +11 -11
- data/spec/docstring_parser_spec.rb +207 -0
- data/spec/docstring_spec.rb +33 -146
- data/spec/handlers/alias_handler_spec.rb +14 -14
- data/spec/handlers/attribute_handler_spec.rb +20 -20
- data/spec/handlers/base_spec.rb +16 -16
- data/spec/handlers/c/alias_handler_spec.rb +33 -0
- data/spec/handlers/c/attribute_handler_spec.rb +40 -0
- data/spec/handlers/c/class_handler_spec.rb +64 -0
- data/spec/handlers/c/constant_handler_spec.rb +68 -0
- data/spec/handlers/c/init_handler_spec.rb +36 -0
- data/spec/handlers/c/method_handler_spec.rb +228 -0
- data/spec/handlers/c/mixin_handler_spec.rb +27 -0
- data/spec/handlers/c/module_handler_spec.rb +38 -0
- data/spec/handlers/c/override_comment_handler_spec.rb +43 -0
- data/spec/handlers/c/path_handler_spec.rb +35 -0
- data/spec/handlers/c/spec_helper.rb +11 -0
- data/spec/handlers/c/struct_handler_spec.rb +15 -0
- data/spec/handlers/class_condition_handler_spec.rb +10 -10
- data/spec/handlers/class_handler_spec.rb +38 -38
- data/spec/handlers/class_variable_handler_spec.rb +1 -1
- data/spec/handlers/constant_handler_spec.rb +7 -7
- data/spec/handlers/{macro_handler_spec.rb → dsl_handler_spec.rb} +72 -53
- data/spec/handlers/examples/alias_handler_001.rb.txt +5 -5
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +9 -9
- data/spec/handlers/examples/class_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/dsl_handler_001.rb.txt +110 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +14 -14
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +2 -2
- data/spec/handlers/examples/method_handler_001.rb.txt +16 -16
- data/spec/handlers/examples/mixin_handler_001.rb.txt +8 -4
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +3 -3
- data/spec/handlers/examples/yield_handler_001.rb.txt +13 -14
- data/spec/handlers/exception_handler_spec.rb +9 -9
- data/spec/handlers/extend_handler_spec.rb +2 -2
- data/spec/handlers/legacy_base_spec.rb +34 -34
- data/spec/handlers/method_condition_handler_spec.rb +2 -2
- data/spec/handlers/method_handler_spec.rb +33 -33
- data/spec/handlers/mixin_handler_spec.rb +13 -9
- data/spec/handlers/module_function_handler_spec.rb +82 -0
- data/spec/handlers/module_handler_spec.rb +6 -6
- data/spec/handlers/private_constant_handler_spec.rb +3 -3
- data/spec/handlers/processor_spec.rb +5 -5
- data/spec/handlers/ruby/base_spec.rb +10 -6
- data/spec/handlers/ruby/legacy/base_spec.rb +11 -7
- data/spec/handlers/spec_helper.rb +2 -3
- data/spec/handlers/visibility_handler_spec.rb +6 -6
- data/spec/handlers/yield_handler_spec.rb +8 -8
- data/spec/i18n/pot_generator_spec.rb +244 -0
- data/spec/i18n/text_spec.rb +69 -0
- data/spec/options_spec.rb +160 -0
- data/spec/parser/base_spec.rb +3 -3
- data/spec/parser/c_parser_spec.rb +31 -257
- data/spec/parser/examples/array.c.txt +187 -187
- data/spec/parser/examples/extrafile.c.txt +1 -1
- data/spec/parser/examples/override.c.txt +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +1 -1
- data/spec/parser/ruby/legacy/statement_list_spec.rb +24 -24
- data/spec/parser/ruby/legacy/token_list_spec.rb +7 -7
- data/spec/parser/ruby/ruby_parser_spec.rb +56 -34
- data/spec/parser/source_parser_spec.rb +125 -65
- data/spec/parser/tag_parsing_spec.rb +4 -4
- data/spec/rake/yardoc_task_spec.rb +10 -8
- data/spec/registry_spec.rb +65 -36
- data/spec/registry_store_spec.rb +90 -40
- data/spec/serializers/file_system_serializer_spec.rb +12 -12
- data/spec/serializers/yardoc_serializer_spec.rb +2 -2
- data/spec/server/adapter_spec.rb +3 -3
- data/spec/server/commands/base_spec.rb +8 -8
- data/spec/server/commands/library_command_spec.rb +3 -3
- data/spec/server/commands/static_file_command_spec.rb +7 -7
- data/spec/server/doc_server_helper_spec.rb +1 -1
- data/spec/server/doc_server_serializer_spec.rb +6 -6
- data/spec/server/rack_adapter_spec.rb +3 -3
- data/spec/server/router_spec.rb +19 -19
- data/spec/server/static_caching_spec.rb +4 -4
- data/spec/spec_helper.rb +7 -7
- data/spec/tags/default_factory_spec.rb +24 -16
- data/spec/tags/directives_spec.rb +422 -0
- data/spec/tags/library_spec.rb +15 -4
- data/spec/tags/overload_tag_spec.rb +6 -6
- data/spec/tags/ref_tag_list_spec.rb +8 -8
- data/spec/templates/class_spec.rb +7 -7
- data/spec/templates/constant_spec.rb +7 -7
- data/spec/templates/engine_spec.rb +28 -36
- data/spec/templates/examples/class001.html +108 -108
- data/spec/templates/examples/class002.html +17 -17
- data/spec/templates/examples/constant001.txt +1 -1
- data/spec/templates/examples/method001.html +45 -45
- data/spec/templates/examples/method002.html +25 -25
- data/spec/templates/examples/method003.html +60 -60
- data/spec/templates/examples/method004.html +7 -7
- data/spec/templates/examples/method005.html +28 -28
- data/spec/templates/examples/module001.html +321 -321
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/examples/module002.html +130 -130
- data/spec/templates/examples/module003.html +74 -74
- data/spec/templates/examples/module004.html +388 -0
- data/spec/templates/helpers/base_helper_spec.rb +32 -32
- data/spec/templates/helpers/html_helper_spec.rb +87 -68
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +9 -9
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +16 -16
- data/spec/templates/helpers/markup_helper_spec.rb +31 -28
- data/spec/templates/helpers/method_helper_spec.rb +7 -7
- data/spec/templates/helpers/shared_signature_examples.rb +9 -7
- data/spec/templates/helpers/text_helper_spec.rb +3 -3
- data/spec/templates/method_spec.rb +13 -13
- data/spec/templates/module_spec.rb +70 -24
- data/spec/templates/onefile_spec.rb +32 -15
- data/spec/templates/section_spec.rb +23 -23
- data/spec/templates/spec_helper.rb +31 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +54 -46
- data/spec/verifier_spec.rb +5 -5
- data/templates/default/class/setup.rb +2 -2
- data/templates/default/docstring/html/abstract.erb +1 -1
- data/templates/default/docstring/html/note.erb +1 -1
- data/templates/default/docstring/html/private.erb +1 -1
- data/templates/default/docstring/html/todo.erb +1 -1
- data/templates/default/docstring/setup.rb +2 -2
- data/templates/default/fulldoc/html/css/full_list.css +4 -2
- data/templates/default/fulldoc/html/css/style.css +50 -44
- data/templates/default/fulldoc/html/frames.erb +21 -6
- data/templates/default/fulldoc/html/full_list.erb +5 -3
- data/templates/default/fulldoc/html/{full_list_files.erb → full_list_file.erb} +0 -0
- data/templates/default/fulldoc/html/js/app.js +29 -26
- data/templates/default/fulldoc/html/js/full_list.js +9 -9
- data/templates/default/fulldoc/html/js/jquery.js +4 -16
- data/templates/default/fulldoc/html/setup.rb +42 -38
- data/templates/default/layout/dot/header.erb +1 -1
- data/templates/default/layout/html/breadcrumb.erb +6 -6
- data/templates/default/layout/html/files.erb +1 -1
- data/templates/default/layout/html/footer.erb +1 -1
- data/templates/default/layout/html/headers.erb +3 -6
- data/templates/default/layout/html/index.erb +1 -1
- data/templates/default/layout/html/layout.erb +3 -7
- data/templates/default/layout/html/objects.erb +1 -1
- data/templates/default/layout/html/script_setup.erb +5 -0
- data/templates/default/layout/html/search.erb +4 -1
- data/templates/default/layout/html/setup.rb +8 -8
- data/templates/default/method_details/html/method_signature.erb +10 -3
- data/templates/default/method_details/setup.rb +1 -0
- data/templates/default/module/dot/info.erb +1 -1
- data/templates/default/module/dot/setup.rb +2 -2
- data/templates/default/module/html/attribute_details.erb +1 -1
- data/templates/default/module/html/children.erb +1 -1
- data/templates/default/module/html/defines.erb +1 -1
- data/templates/default/module/html/inherited_methods.erb +5 -4
- data/templates/default/module/html/item_summary.erb +15 -5
- data/templates/default/module/html/method_details_list.erb +2 -2
- data/templates/default/module/setup.rb +25 -12
- data/templates/default/module/text/setup.rb +1 -1
- data/templates/default/onefile/html/layout.erb +1 -1
- data/templates/default/onefile/html/setup.rb +2 -2
- data/templates/default/tags/html/example.erb +4 -2
- data/templates/default/tags/html/option.erb +1 -1
- data/templates/default/tags/html/overload.erb +1 -1
- data/templates/default/tags/html/see.erb +1 -1
- data/templates/default/tags/html/tag.erb +1 -1
- data/templates/default/tags/setup.rb +4 -3
- data/templates/guide/fulldoc/html/css/style.css +8 -8
- data/templates/guide/fulldoc/html/js/app.js +6 -6
- data/templates/guide/fulldoc/html/setup.rb +12 -12
- data/templates/guide/layout/html/layout.erb +11 -11
- data/templates/guide/layout/html/setup.rb +9 -9
- data/templates/guide/method/html/header.erb +2 -2
- data/templates/guide/method/html/setup.rb +1 -1
- metadata +68 -18
- data/bin/yard-graph +0 -4
- data/bin/yard-server +0 -4
- data/docs/Glossary.md +0 -12
- data/lib/yard/handlers/ruby/legacy/macro_handler.rb +0 -39
- data/lib/yard/handlers/ruby/macro_handler.rb +0 -40
- data/lib/yard/handlers/ruby/macro_handler_methods.rb +0 -131
- data/lib/yard/parser/c_parser.rb +0 -497
- data/lib/yard/server/templates/default/layout/html/headers.erb +0 -16
- data/lib/yard/server/templates/doc_server/frames/html/frames.erb +0 -13
- data/lib/yard/server/templates/doc_server/frames/html/setup.rb +0 -3
- data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +0 -34
- data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +0 -20
- data/spec/handlers/examples/macro_handler_001.rb.txt +0 -83
@@ -5,7 +5,7 @@ describe YARD::CLI::CommandParser do
|
|
5
5
|
before do
|
6
6
|
@cmd = CLI::CommandParser.new
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should show help if --help is provided" do
|
10
10
|
command = mock(:command)
|
11
11
|
command.should_receive(:run).with('--help')
|
@@ -13,7 +13,7 @@ describe YARD::CLI::CommandParser do
|
|
13
13
|
@cmd.class.default_command = :foo
|
14
14
|
@cmd.run *%w( foo --help )
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should use default command if first argument is a switch" do
|
18
18
|
command = mock(:command)
|
19
19
|
command.should_receive(:run).with('--a', 'b', 'c')
|
@@ -21,7 +21,7 @@ describe YARD::CLI::CommandParser do
|
|
21
21
|
@cmd.class.default_command = :foo
|
22
22
|
@cmd.run *%w( --a b c )
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should use default command if no arguments are provided" do
|
26
26
|
command = mock(:command)
|
27
27
|
command.should_receive(:run)
|
@@ -29,7 +29,7 @@ describe YARD::CLI::CommandParser do
|
|
29
29
|
@cmd.class.default_command = :foo
|
30
30
|
@cmd.run
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should list commands if command is not found" do
|
34
34
|
@cmd.should_receive(:list_commands)
|
35
35
|
@cmd.run *%w( unknown_command --args )
|
data/spec/cli/command_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe YARD::CLI::Command do
|
|
8
8
|
@saw_foo = false
|
9
9
|
@options.on('--foo') { @saw_foo = true }
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def parse(*args)
|
13
13
|
CLI::Command.new.send(:parse_options, @options, args)
|
14
14
|
args
|
@@ -20,13 +20,13 @@ describe YARD::CLI::Command do
|
|
20
20
|
parse('--list', '--list2', '--foo')
|
21
21
|
@saw_foo.should be_true
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should skip unrecognized options and any extra non-option arg that follows" do
|
25
25
|
log.should_receive(:warn).with(/Unrecognized.*--list/)
|
26
26
|
parse('--list', 'foo', '--foo')
|
27
27
|
@saw_foo.should be_true
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "should stop retrying to parse at non-switch argument" do
|
31
31
|
log.should_receive(:warn).with(/Unrecognized.*--list/)
|
32
32
|
args = parse('--list', 'foo', 'foo', 'foo')
|
data/spec/cli/config_spec.rb
CHANGED
@@ -8,11 +8,11 @@ describe YARD::CLI::Config do
|
|
8
8
|
YARD::Config.options = YARD::Config::DEFAULT_CONFIG_OPTIONS.dup
|
9
9
|
YARD::Config.stub!(:save)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def run(*args)
|
13
13
|
@config.run(*args)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
describe 'Listing configuration' do
|
17
17
|
it "should accept --list" do
|
18
18
|
opts = YARD::Config.options
|
@@ -23,7 +23,7 @@ describe YARD::CLI::Config do
|
|
23
23
|
YARD::Config.options.should == opts
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
describe 'Viewing an item' do
|
28
28
|
it "should view item if no value is given" do
|
29
29
|
YARD::Config.options[:foo] = 'bar'
|
@@ -32,19 +32,19 @@ describe YARD::CLI::Config do
|
|
32
32
|
YARD::Config.options[:foo].should == 'bar'
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
describe 'Modifying an item' do
|
37
37
|
it "should accept --reset to set value" do
|
38
38
|
YARD::Config.options[:load_plugins] = 'foo'
|
39
39
|
run('--reset', 'load_plugins')
|
40
40
|
YARD::Config.options[:load_plugins].should == false
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "should accept --as-list to force single item as list" do
|
44
44
|
run('--as-list', 'foo', 'bar')
|
45
45
|
YARD::Config.options[:foo].should == ['bar']
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "should accept --append to append values to existing key" do
|
49
49
|
YARD::Config.options[:foo] = ['bar']
|
50
50
|
run('--append', 'foo', 'baz', 'quux')
|
@@ -52,38 +52,38 @@ describe YARD::CLI::Config do
|
|
52
52
|
run('-a', 'foo', 'last')
|
53
53
|
YARD::Config.options[:foo].should == ['bar', 'baz', 'quux', 'last']
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
it "should turn key into list if --append is used on single item" do
|
57
57
|
YARD::Config.options[:foo] = 'bar'
|
58
58
|
run('-a', 'foo', 'baz')
|
59
59
|
YARD::Config.options[:foo].should == ['bar', 'baz']
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it "should modify item if value is given" do
|
63
63
|
run('foo', 'xxx')
|
64
64
|
YARD::Config.options[:foo].should == 'xxx'
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
it "should turn list of values into array of values" do
|
68
68
|
run('foo', 'a', 'b', '1', 'true', 'false')
|
69
69
|
YARD::Config.options[:foo].should == ['a', 'b', 1, true, false]
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "should turn number into numeric Ruby type" do
|
73
73
|
run('foo', '1')
|
74
74
|
YARD::Config.options[:foo].should == 1
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
it "should turn true into TrueClass" do
|
78
78
|
run('foo', 'true')
|
79
79
|
YARD::Config.options[:foo].should == true
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
it "should turn false into FalseClass" do
|
83
83
|
run('foo', 'false')
|
84
84
|
YARD::Config.options[:foo].should == false
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
it "should save on modification" do
|
88
88
|
YARD::Config.should_receive(:save)
|
89
89
|
run('foo', 'true')
|
data/spec/cli/diff_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe YARD::CLI::Diff do
|
|
8
8
|
CLI::Gems.stub!(:run)
|
9
9
|
@diff = CLI::Diff.new
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
describe 'Argument handling' do
|
13
13
|
it "should exit if there is only one gem name" do
|
14
14
|
@diff.should_receive(:exit)
|
@@ -16,7 +16,7 @@ describe YARD::CLI::Diff do
|
|
16
16
|
@diff.run
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
describe 'Diffing' do
|
21
21
|
before do
|
22
22
|
@objects1 = nil
|
@@ -24,13 +24,16 @@ describe YARD::CLI::Diff do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def run(*args)
|
27
|
+
@all_call = -1
|
27
28
|
@data = StringIO.new
|
28
29
|
@objects1 ||= %w( C#fooey C#baz D.bar )
|
29
30
|
@objects2 ||= %w( A A::B A::B::C A.foo A#foo B C.foo C.bar C#baz )
|
31
|
+
@objects = [@objects1, @objects2]
|
30
32
|
@diff.should_receive(:load_gem_data).ordered.with('gem1').and_return(true)
|
31
33
|
@diff.should_receive(:load_gem_data).ordered.with('gem2').and_return(true)
|
32
|
-
Registry.should_receive(:all).
|
33
|
-
|
34
|
+
Registry.should_receive(:all).twice.and_return do
|
35
|
+
@objects[@all_call += 1].map {|o| P(o) }
|
36
|
+
end
|
34
37
|
@diff.stub!(:print) {|data| @data << data }
|
35
38
|
@diff.stub!(:puts) {|*args| @data << args.join("\n"); @data << "\n" }
|
36
39
|
@diff.run(*(args + ['gem1', 'gem2']))
|
@@ -78,12 +81,12 @@ eof
|
|
78
81
|
end
|
79
82
|
end
|
80
83
|
end
|
81
|
-
|
84
|
+
|
82
85
|
describe 'File searching' do
|
83
86
|
before do
|
84
87
|
@diff.stub!(:generate_yardoc)
|
85
88
|
end
|
86
|
-
|
89
|
+
|
87
90
|
it "should search for gem/.yardoc" do
|
88
91
|
File.should_receive(:directory?).with('gem1/.yardoc').and_return(true)
|
89
92
|
File.should_receive(:directory?).with('gem2/.yardoc').and_return(true)
|
@@ -91,7 +94,7 @@ eof
|
|
91
94
|
Registry.should_receive(:load_yardoc).with('gem2/.yardoc')
|
92
95
|
@diff.run('gem1', 'gem2')
|
93
96
|
end
|
94
|
-
|
97
|
+
|
95
98
|
it "should search for argument as yardoc" do
|
96
99
|
File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
|
97
100
|
File.should_receive(:directory?).with('gem2/.yardoc').and_return(false)
|
@@ -125,7 +128,7 @@ eof
|
|
125
128
|
Dir.stub!(:chdir)
|
126
129
|
@diff.run('gem1-1.0.0.gem', 'gem2-1.0.0')
|
127
130
|
end
|
128
|
-
|
131
|
+
|
129
132
|
it "should search for .gem file" do
|
130
133
|
iomock = mock(:io)
|
131
134
|
File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
|
@@ -143,7 +146,7 @@ eof
|
|
143
146
|
FileUtils.should_receive(:rm_rf)
|
144
147
|
@diff.run('gem1', 'gem2.gem')
|
145
148
|
end
|
146
|
-
|
149
|
+
|
147
150
|
it "should search for .gem file on rubygems.org" do
|
148
151
|
iomock = mock(:io)
|
149
152
|
File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
|
@@ -161,7 +164,7 @@ eof
|
|
161
164
|
FileUtils.should_receive(:rm_rf)
|
162
165
|
@diff.run('gem1', 'gem2.gem')
|
163
166
|
end
|
164
|
-
|
167
|
+
|
165
168
|
it "should error if gem is not found" do
|
166
169
|
log.should_receive(:error).with("Cannot find gem gem1")
|
167
170
|
log.should_receive(:error).with("Cannot find gem gem2.gem")
|
data/spec/cli/gems_spec.rb
CHANGED
@@ -9,14 +9,14 @@ describe YARD::CLI::Gems do
|
|
9
9
|
@gem2 = build_mock('gem2')
|
10
10
|
@gem3 = build_mock('gem3')
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def build_mock(name, version = '1.0')
|
14
|
-
OpenStruct.new :name => name,
|
15
|
-
:version => version,
|
16
|
-
:full_gem_path => "/path/to/gems/#{name}-#{version}",
|
14
|
+
OpenStruct.new :name => name,
|
15
|
+
:version => version,
|
16
|
+
:full_gem_path => "/path/to/gems/#{name}-#{version}",
|
17
17
|
:yardoc_file => "/path/to/yardoc/#{name}-#{version}"
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def build_specs(*specs)
|
21
21
|
specs.each do |themock|
|
22
22
|
Registry.should_receive(:yardoc_file_for_gem).with(themock.name, "= #{themock.version}").and_return(themock.yardoc_file)
|
@@ -28,33 +28,33 @@ describe YARD::CLI::Gems do
|
|
28
28
|
Registry.should_receive(:clear).exactly(specs.size).times
|
29
29
|
CLI::Yardoc.should_receive(:run).exactly(specs.size).times
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
describe '#run' do
|
33
33
|
it "should build all gem indexes if no gem is specified" do
|
34
34
|
build_specs(@gem1, @gem2)
|
35
35
|
Gem.source_index.should_receive(:find_name).with('').and_return([@gem1, @gem2])
|
36
36
|
CLI::Gems.run
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "should allow gem to be specified" do
|
40
40
|
build_specs(@gem1)
|
41
41
|
Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 0').and_return([@gem1])
|
42
42
|
CLI::Gems.run(@gem1.name)
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
it "should allow multiple gems to be specified for building" do
|
46
46
|
build_specs(@gem1, @gem2)
|
47
47
|
Gem.source_index.should_receive(:find_name).with(@gem1.name, @gem1.version).and_return([@gem1])
|
48
48
|
Gem.source_index.should_receive(:find_name).with(@gem2.name, '>= 0').and_return([@gem2])
|
49
49
|
CLI::Gems.run(@gem1.name, @gem1.version, @gem2.name)
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
it "should allow version to be specified with gem" do
|
53
53
|
build_specs(@gem1)
|
54
54
|
Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 1.0').and_return([@gem1])
|
55
55
|
CLI::Gems.run(@gem1.name, '>= 1.0')
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
it "should warn if one of the gems is not found, but it should process others" do
|
59
59
|
build_specs(@gem2)
|
60
60
|
Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
|
@@ -62,7 +62,7 @@ describe YARD::CLI::Gems do
|
|
62
62
|
log.should_receive(:warn).with(/#{@gem1.name} >= 2.0 could not be found/)
|
63
63
|
CLI::Gems.run(@gem1.name, '>= 2.0', @gem2.name)
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
it "should fail if specified gem(s) is/are not found" do
|
67
67
|
CLI::Yardoc.should_not_receive(:run)
|
68
68
|
Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
|
@@ -70,7 +70,7 @@ describe YARD::CLI::Gems do
|
|
70
70
|
log.should_receive(:error).with(/No specified gems could be found/)
|
71
71
|
CLI::Gems.run(@gem1.name, '>= 2.0')
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "should accept --rebuild" do
|
75
75
|
@rebuild = true
|
76
76
|
build_specs(@gem1)
|
data/spec/cli/help_spec.rb
CHANGED
@@ -6,12 +6,12 @@ describe YARD::CLI::Help do
|
|
6
6
|
CLI::Yardoc.should_receive(:run).with('--help')
|
7
7
|
CLI::Help.run('doc')
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should accept no arguments (lists all commands)" do
|
11
11
|
CLI::CommandParser.should_receive(:run).with('--help')
|
12
12
|
CLI::Help.run
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should show all commands if command isn't found" do
|
16
16
|
CLI::CommandParser.should_receive(:run).with('--help')
|
17
17
|
help = CLI::Help.new
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe YARD::CLI::I18n do
|
4
|
+
before do
|
5
|
+
@i18n = YARD::CLI::I18n.new
|
6
|
+
@i18n.use_document_file = false
|
7
|
+
@i18n.use_yardopts_file = false
|
8
|
+
output_path = File.expand_path(@i18n.options.serializer.basepath)
|
9
|
+
File.stub!(:open!).with(output_path, "wb")
|
10
|
+
YARD.stub!(:parse)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Defaults' do
|
14
|
+
before do
|
15
|
+
@i18n = YARD::CLI::I18n.new
|
16
|
+
@i18n.stub!(:yardopts).and_return([])
|
17
|
+
@i18n.stub!(:support_rdoc_document_file!).and_return([])
|
18
|
+
@i18n.parse_arguments
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should read .yardopts by default" do
|
22
|
+
@i18n.use_yardopts_file.should == true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should use {lib,app}/**/*.rb and ext/**/*.c as default file glob" do
|
26
|
+
@i18n.files.should == ['{lib,app}/**/*.rb', 'ext/**/*.c']
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should only show public visibility by default" do
|
30
|
+
@i18n.visibilities.should == [:public]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'General options' do
|
35
|
+
def self.should_accept(*args, &block)
|
36
|
+
@counter ||= 0
|
37
|
+
@counter += 1
|
38
|
+
counter = @counter
|
39
|
+
args.each do |arg|
|
40
|
+
define_method("test_options_#{@counter}", &block)
|
41
|
+
it("should accept #{arg}") { send("test_options_#{counter}", arg) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
should_accept('--yardopts') do |arg|
|
46
|
+
@i18n = YARD::CLI::I18n.new
|
47
|
+
@i18n.use_document_file = false
|
48
|
+
@i18n.should_receive(:yardopts).at_least(1).times.and_return([])
|
49
|
+
@i18n.parse_arguments(arg)
|
50
|
+
@i18n.use_yardopts_file.should == true
|
51
|
+
@i18n.parse_arguments('--no-yardopts', arg)
|
52
|
+
@i18n.use_yardopts_file.should == true
|
53
|
+
end
|
54
|
+
|
55
|
+
should_accept('--yardopts with filename') do |arg|
|
56
|
+
@i18n = YARD::CLI::I18n.new
|
57
|
+
File.should_receive(:read_binary).with('.yardopts_i18n').and_return('')
|
58
|
+
@i18n.use_document_file = false
|
59
|
+
@i18n.parse_arguments('--yardopts', '.yardopts_i18n')
|
60
|
+
@i18n.use_yardopts_file.should == true
|
61
|
+
@i18n.options_file.should == '.yardopts_i18n'
|
62
|
+
end
|
63
|
+
|
64
|
+
should_accept('--no-yardopts') do |arg|
|
65
|
+
@i18n = YARD::CLI::I18n.new
|
66
|
+
@i18n.use_document_file = false
|
67
|
+
@i18n.should_not_receive(:yardopts)
|
68
|
+
@i18n.parse_arguments(arg)
|
69
|
+
@i18n.use_yardopts_file.should == false
|
70
|
+
@i18n.parse_arguments('--yardopts', arg)
|
71
|
+
@i18n.use_yardopts_file.should == false
|
72
|
+
end
|
73
|
+
|
74
|
+
should_accept('--exclude') do |arg|
|
75
|
+
YARD.should_receive(:parse).with(['a'], ['nota', 'b'])
|
76
|
+
@i18n.run(arg, 'nota', arg, 'b', 'a')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '.yardopts handling' do
|
81
|
+
before do
|
82
|
+
@i18n.use_yardopts_file = true
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should search for and use yardopts file specified by #options_file" do
|
86
|
+
File.should_receive(:read_binary).with("test").and_return("-o \n\nMYPATH\nFILE1 FILE2")
|
87
|
+
@i18n.use_document_file = false
|
88
|
+
@i18n.options_file = "test"
|
89
|
+
File.should_receive(:open!).with(File.expand_path("MYPATH"), "wb")
|
90
|
+
@i18n.run
|
91
|
+
@i18n.files.should == ["FILE1", "FILE2"]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#run' do
|
96
|
+
it "should parse_arguments if run() is called" do
|
97
|
+
@i18n.should_receive(:parse_arguments)
|
98
|
+
@i18n.run
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should parse_arguments if run(arg1, arg2, ...) is called" do
|
102
|
+
@i18n.should_receive(:parse_arguments)
|
103
|
+
@i18n.run('--private', '-p', 'foo')
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should not parse_arguments if run(nil) is called" do
|
107
|
+
@i18n.should_not_receive(:parse_arguments)
|
108
|
+
@i18n.run(nil)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/spec/cli/server_spec.rb
CHANGED
@@ -13,15 +13,19 @@ describe YARD::CLI::Server do
|
|
13
13
|
@adapter.stub!(:setup)
|
14
14
|
@cli = YARD::CLI::Server.new
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def rack_required
|
18
18
|
begin; require 'rack'; rescue LoadError; pending "rack required for this test" end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
def bundler_required
|
22
|
+
begin; require 'bundler'; rescue LoadError; pending "bundler required for this test" end
|
23
|
+
end
|
24
|
+
|
21
25
|
def unstub_adapter
|
22
26
|
@no_adapter_mock = true
|
23
27
|
end
|
24
|
-
|
28
|
+
|
25
29
|
def run(*args)
|
26
30
|
if @libraries.empty?
|
27
31
|
library = Server::LibraryVersion.new(File.basename(Dir.pwd), nil, File.expand_path('.yardoc'))
|
@@ -36,6 +40,7 @@ describe YARD::CLI::Server do
|
|
36
40
|
@adapter.should_receive(:start)
|
37
41
|
end
|
38
42
|
@cli.run(*args.flatten)
|
43
|
+
@cli = YARD::CLI::Server.new
|
39
44
|
end
|
40
45
|
|
41
46
|
it "should default to current dir if no library is specified" do
|
@@ -43,65 +48,65 @@ describe YARD::CLI::Server do
|
|
43
48
|
@libraries['foo'] = [Server::LibraryVersion.new('foo', nil, File.expand_path('.yardoc'))]
|
44
49
|
run
|
45
50
|
end
|
46
|
-
|
51
|
+
|
47
52
|
it "should use .yardoc as yardoc file is library list is odd" do
|
48
53
|
@libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('.yardoc'))]
|
49
54
|
run 'a'
|
50
55
|
end
|
51
|
-
|
56
|
+
|
52
57
|
it "should force multi library if more than one library is listed" do
|
53
58
|
@options[:single_library] = false
|
54
59
|
@libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('b'))]
|
55
60
|
@libraries['c'] = [Server::LibraryVersion.new('c', nil, File.expand_path('.yardoc'))]
|
56
61
|
run %w(a b c)
|
57
62
|
end
|
58
|
-
|
63
|
+
|
59
64
|
it "should accept -m, --multi-library" do
|
60
65
|
@options[:single_library] = false
|
61
66
|
run '-m'
|
62
67
|
run '--multi-library'
|
63
68
|
end
|
64
|
-
|
69
|
+
|
65
70
|
it "should accept -c, --cache" do
|
66
71
|
@options[:caching] = true
|
67
72
|
run '-c'
|
68
73
|
run '--cache'
|
69
74
|
end
|
70
|
-
|
75
|
+
|
71
76
|
it "should accept -r, --reload" do
|
72
77
|
@options[:incremental] = true
|
73
78
|
run '-r'
|
74
79
|
run '--reload'
|
75
80
|
end
|
76
|
-
|
81
|
+
|
77
82
|
it "should accept -d, --daemon" do
|
78
83
|
@server_options[:daemonize] = true
|
79
84
|
run '-d'
|
80
85
|
run '--daemon'
|
81
86
|
end
|
82
|
-
|
87
|
+
|
83
88
|
it "should accept -p, --port" do
|
84
89
|
@server_options[:Port] = 10
|
85
90
|
run '-p', '10'
|
86
91
|
run '--port', '10'
|
87
92
|
end
|
88
|
-
|
93
|
+
|
89
94
|
it "should accept --docroot" do
|
90
95
|
@server_options[:DocumentRoot] = Dir.pwd + '/__foo/bar'
|
91
96
|
run '--docroot', '__foo/bar'
|
92
97
|
end
|
93
|
-
|
98
|
+
|
94
99
|
it "should accept -a webrick to create WEBrick adapter" do
|
95
100
|
@cli.should_receive(:adapter=).with(YARD::Server::WebrickAdapter)
|
96
101
|
run '-a', 'webrick'
|
97
102
|
end
|
98
|
-
|
103
|
+
|
99
104
|
it "should accept -a rack to create Rack adapter" do
|
100
105
|
rack_required
|
101
106
|
@cli.should_receive(:adapter=).with(YARD::Server::RackAdapter)
|
102
107
|
run '-a', 'rack'
|
103
108
|
end
|
104
|
-
|
109
|
+
|
105
110
|
it "should default to Rack adapter if exists on system" do
|
106
111
|
rack_required
|
107
112
|
@cli.should_receive(:require).with('rubygems').and_return(false)
|
@@ -116,13 +121,13 @@ describe YARD::CLI::Server do
|
|
116
121
|
@cli.should_receive(:adapter=).with(YARD::Server::WebrickAdapter)
|
117
122
|
@cli.send(:select_adapter)
|
118
123
|
end
|
119
|
-
|
124
|
+
|
120
125
|
it "should accept -s, --server" do
|
121
126
|
@server_options[:server] = 'thin'
|
122
127
|
run '-s', 'thin'
|
123
128
|
run '--server', 'thin'
|
124
129
|
end
|
125
|
-
|
130
|
+
|
126
131
|
it "should accept -g, --gems" do
|
127
132
|
@no_verify_libraries = true
|
128
133
|
@options[:single_library] = false
|
@@ -145,14 +150,57 @@ describe YARD::CLI::Server do
|
|
145
150
|
run '-g'
|
146
151
|
run '--gems'
|
147
152
|
end
|
148
|
-
|
153
|
+
|
154
|
+
it "should accept -G, --gemfile" do
|
155
|
+
bundler_required
|
156
|
+
@no_verify_libraries = true
|
157
|
+
@options[:single_library] = false
|
158
|
+
|
159
|
+
@libraries['gem1'] = [Server::LibraryVersion.new('gem1', '1.0.0', nil, :gem)]
|
160
|
+
@libraries['gem2'] = [Server::LibraryVersion.new('gem2', '1.0.0', nil, :gem)]
|
161
|
+
gem1 = mock(:gem1)
|
162
|
+
gem1.stub!(:name).and_return('gem1')
|
163
|
+
gem1.stub!(:version).and_return('1.0.0')
|
164
|
+
gem1.stub!(:full_gem_path).and_return('/path/to/foo')
|
165
|
+
gem2 = mock(:gem2)
|
166
|
+
gem2.stub!(:name).and_return('gem2')
|
167
|
+
gem2.stub!(:version).and_return('1.0.0')
|
168
|
+
gem2.stub!(:full_gem_path).and_return('/path/to/bar')
|
169
|
+
specs = {'gem1' => gem1, 'gem2' => gem2}
|
170
|
+
lockfile_parser = mock(:new)
|
171
|
+
lockfile_parser.stub!(:specs).and_return([gem1, gem2])
|
172
|
+
Bundler::LockfileParser.stub!(:new).and_return(lockfile_parser)
|
173
|
+
|
174
|
+
File.should_receive(:exists?).at_least(2).times.with("Gemfile.lock").and_return(true)
|
175
|
+
File.stub!(:read)
|
176
|
+
|
177
|
+
run '-G'
|
178
|
+
run '--gemfile'
|
179
|
+
|
180
|
+
File.should_receive(:exists?).with("different_name.lock").and_return(true)
|
181
|
+
run '--gemfile', 'different_name'
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should warn if lockfile is not found (with -G)" do
|
185
|
+
bundler_required
|
186
|
+
File.should_receive(:exists?).with('somefile.lock').and_return(false)
|
187
|
+
log.should_receive(:warn).with(/Cannot find somefile.lock/)
|
188
|
+
run '-G', 'somefile'
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should error if Bundler not available (with -G)" do
|
192
|
+
@cli.should_receive(:require).with('bundler').and_raise(LoadError)
|
193
|
+
log.should_receive(:error).with(/Bundler not available/)
|
194
|
+
run '-G'
|
195
|
+
end
|
196
|
+
|
149
197
|
it "should load template paths after adapter template paths" do
|
150
198
|
unstub_adapter
|
151
199
|
@cli.adapter = Server::WebrickAdapter
|
152
200
|
run '-t', 'foo'
|
153
201
|
Templates::Engine.template_paths.last.should == 'foo'
|
154
202
|
end
|
155
|
-
|
203
|
+
|
156
204
|
it "should load ruby code (-e) after adapter" do
|
157
205
|
unstub_adapter
|
158
206
|
@cli.adapter = Server::WebrickAdapter
|