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.

Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/LICENSE +2 -2
  4. data/README.md +2 -2
  5. data/Rakefile +1 -1
  6. data/bin/yard +0 -0
  7. data/bin/yardoc +0 -0
  8. data/bin/yri +0 -0
  9. data/docs/GettingStarted.md +88 -6
  10. data/docs/images/handlers-class-diagram.png +0 -0
  11. data/docs/images/overview-class-diagram.png +0 -0
  12. data/docs/images/parser-class-diagram.png +0 -0
  13. data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
  14. data/lib/yard/autoload.rb +3 -0
  15. data/lib/yard/cli/yardoc.rb +1 -1
  16. data/lib/yard/code_objects/base.rb +4 -1
  17. data/lib/yard/code_objects/extra_file_object.rb +3 -1
  18. data/lib/yard/code_objects/proxy.rb +2 -2
  19. data/lib/yard/docstring.rb +11 -6
  20. data/lib/yard/handlers/base.rb +1 -2
  21. data/lib/yard/handlers/c/base.rb +19 -0
  22. data/lib/yard/handlers/c/handler_methods.rb +42 -8
  23. data/lib/yard/handlers/c/init_handler.rb +1 -1
  24. data/lib/yard/handlers/c/method_handler.rb +3 -3
  25. data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
  26. data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
  27. data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
  28. data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
  29. data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
  30. data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
  31. data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
  32. data/lib/yard/logging.rb +1 -0
  33. data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
  34. data/lib/yard/parser/source_parser.rb +6 -6
  35. data/lib/yard/rake/yardoc_task.rb +2 -2
  36. data/lib/yard/serializers/file_system_serializer.rb +33 -1
  37. data/lib/yard/server/commands/display_file_command.rb +8 -3
  38. data/lib/yard/server/commands/display_object_command.rb +7 -3
  39. data/lib/yard/server/doc_server_helper.rb +2 -8
  40. data/lib/yard/server/doc_server_serializer.rb +2 -4
  41. data/lib/yard/server/router.rb +1 -1
  42. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
  43. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
  44. data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
  45. data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
  46. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
  47. data/lib/yard/tags/directives.rb +1 -0
  48. data/lib/yard/tags/library.rb +9 -7
  49. data/lib/yard/tags/overload_tag.rb +4 -1
  50. data/lib/yard/templates/helpers/html_helper.rb +4 -3
  51. data/lib/yard/templates/template_options.rb +3 -0
  52. data/lib/yard/version.rb +1 -1
  53. data/spec/cli/command_parser_spec.rb +14 -14
  54. data/spec/cli/command_spec.rb +11 -11
  55. data/spec/cli/config_spec.rb +32 -32
  56. data/spec/cli/diff_spec.rb +86 -90
  57. data/spec/cli/display_spec.rb +6 -6
  58. data/spec/cli/gems_spec.rb +28 -28
  59. data/spec/cli/graph_spec.rb +8 -8
  60. data/spec/cli/help_spec.rb +8 -8
  61. data/spec/cli/i18n_spec.rb +33 -37
  62. data/spec/cli/list_spec.rb +2 -2
  63. data/spec/cli/markup_types_spec.rb +3 -3
  64. data/spec/cli/server_spec.rb +74 -88
  65. data/spec/cli/stats_spec.rb +14 -14
  66. data/spec/cli/yardoc_spec.rb +316 -321
  67. data/spec/cli/yri_spec.rb +45 -45
  68. data/spec/code_objects/base_spec.rb +174 -173
  69. data/spec/code_objects/class_object_spec.rb +65 -65
  70. data/spec/code_objects/code_object_list_spec.rb +13 -11
  71. data/spec/code_objects/constants_spec.rb +68 -58
  72. data/spec/code_objects/extra_file_object_spec.rb +71 -59
  73. data/spec/code_objects/macro_object_spec.rb +64 -64
  74. data/spec/code_objects/method_object_spec.rb +80 -72
  75. data/spec/code_objects/module_object_spec.rb +47 -47
  76. data/spec/code_objects/namespace_object_spec.rb +51 -51
  77. data/spec/code_objects/proxy_spec.rb +54 -54
  78. data/spec/config_spec.rb +104 -104
  79. data/spec/core_ext/array_spec.rb +5 -5
  80. data/spec/core_ext/file_spec.rb +33 -33
  81. data/spec/core_ext/hash_spec.rb +5 -5
  82. data/spec/core_ext/insertion_spec.rb +18 -18
  83. data/spec/core_ext/module_spec.rb +6 -6
  84. data/spec/core_ext/string_spec.rb +17 -17
  85. data/spec/core_ext/symbol_hash_spec.rb +42 -39
  86. data/spec/docstring_parser_spec.rb +65 -65
  87. data/spec/docstring_spec.rb +137 -130
  88. data/spec/handlers/alias_handler_spec.rb +39 -39
  89. data/spec/handlers/attribute_handler_spec.rb +35 -35
  90. data/spec/handlers/base_spec.rb +60 -51
  91. data/spec/handlers/c/alias_handler_spec.rb +6 -6
  92. data/spec/handlers/c/attribute_handler_spec.rb +12 -12
  93. data/spec/handlers/c/class_handler_spec.rb +35 -22
  94. data/spec/handlers/c/constant_handler_spec.rb +24 -22
  95. data/spec/handlers/c/init_handler_spec.rb +10 -10
  96. data/spec/handlers/c/method_handler_spec.rb +150 -65
  97. data/spec/handlers/c/mixin_handler_spec.rb +5 -5
  98. data/spec/handlers/c/module_handler_spec.rb +27 -15
  99. data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
  100. data/spec/handlers/c/path_handler_spec.rb +8 -8
  101. data/spec/handlers/c/spec_helper.rb +10 -0
  102. data/spec/handlers/c/struct_handler_spec.rb +3 -3
  103. data/spec/handlers/class_condition_handler_spec.rb +18 -18
  104. data/spec/handlers/class_handler_spec.rb +97 -97
  105. data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
  106. data/spec/handlers/class_variable_handler_spec.rb +3 -3
  107. data/spec/handlers/constant_handler_spec.rb +32 -29
  108. data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
  109. data/spec/handlers/dsl_handler_spec.rb +108 -109
  110. data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
  111. data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
  112. data/spec/handlers/exception_handler_spec.rb +23 -23
  113. data/spec/handlers/extend_handler_spec.rb +9 -9
  114. data/spec/handlers/legacy_base_spec.rb +60 -60
  115. data/spec/handlers/method_condition_handler_spec.rb +5 -5
  116. data/spec/handlers/method_handler_spec.rb +92 -92
  117. data/spec/handlers/mixin_handler_spec.rb +25 -25
  118. data/spec/handlers/module_function_handler_spec.rb +24 -24
  119. data/spec/handlers/module_handler_spec.rb +15 -15
  120. data/spec/handlers/private_class_method_handler_spec.rb +4 -48
  121. data/spec/handlers/private_constant_handler_spec.rb +8 -8
  122. data/spec/handlers/processor_spec.rb +12 -12
  123. data/spec/handlers/public_class_method_handler_spec.rb +10 -0
  124. data/spec/handlers/ruby/base_spec.rb +16 -16
  125. data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
  126. data/spec/handlers/spec_helper.rb +1 -1
  127. data/spec/handlers/visibility_handler_spec.rb +25 -21
  128. data/spec/handlers/yield_handler_spec.rb +28 -28
  129. data/spec/i18n/locale_spec.rb +16 -16
  130. data/spec/i18n/message_spec.rb +8 -8
  131. data/spec/i18n/messages_spec.rb +14 -14
  132. data/spec/i18n/pot_generator_spec.rb +32 -32
  133. data/spec/i18n/text_spec.rb +22 -22
  134. data/spec/logging_spec.rb +12 -12
  135. data/spec/options_spec.rb +56 -56
  136. data/spec/parser/base_spec.rb +9 -9
  137. data/spec/parser/c_parser_spec.rb +50 -50
  138. data/spec/parser/ruby/ast_node_spec.rb +7 -7
  139. data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
  140. data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
  141. data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
  142. data/spec/parser/source_parser_spec.rb +224 -224
  143. data/spec/parser/tag_parsing_spec.rb +6 -7
  144. data/spec/rake/yardoc_task_spec.rb +38 -48
  145. data/spec/registry_spec.rb +143 -143
  146. data/spec/registry_store_spec.rb +165 -165
  147. data/spec/rubygems/doc_manager_spec.rb +38 -38
  148. data/spec/serializers/file_system_serializer_spec.rb +53 -33
  149. data/spec/serializers/yardoc_serializer_spec.rb +15 -15
  150. data/spec/server/adapter_spec.rb +15 -15
  151. data/spec/server/commands/base_spec.rb +29 -29
  152. data/spec/server/commands/library_command_spec.rb +12 -12
  153. data/spec/server/commands/static_file_command_spec.rb +28 -28
  154. data/spec/server/doc_server_helper_spec.rb +8 -8
  155. data/spec/server/doc_server_serializer_spec.rb +23 -18
  156. data/spec/server/rack_adapter_spec.rb +6 -6
  157. data/spec/server/router_spec.rb +39 -39
  158. data/spec/server/static_caching_spec.rb +16 -16
  159. data/spec/server/webrick_servlet_spec.rb +6 -7
  160. data/spec/server_spec.rb +3 -3
  161. data/spec/spec_helper.rb +11 -2
  162. data/spec/tags/default_factory_spec.rb +64 -64
  163. data/spec/tags/default_tag_spec.rb +5 -5
  164. data/spec/tags/directives_spec.rb +121 -121
  165. data/spec/tags/library_spec.rb +14 -14
  166. data/spec/tags/overload_tag_spec.rb +24 -24
  167. data/spec/tags/ref_tag_list_spec.rb +12 -12
  168. data/spec/templates/class_spec.rb +3 -3
  169. data/spec/templates/constant_spec.rb +4 -4
  170. data/spec/templates/engine_spec.rb +47 -48
  171. data/spec/templates/examples/class001.html +129 -101
  172. data/spec/templates/examples/class002.html +31 -27
  173. data/spec/templates/examples/method001.html +54 -47
  174. data/spec/templates/examples/method002.html +33 -28
  175. data/spec/templates/examples/method003.html +70 -64
  176. data/spec/templates/examples/method004.html +13 -9
  177. data/spec/templates/examples/method005.html +38 -32
  178. data/spec/templates/examples/module001.html +343 -339
  179. data/spec/templates/examples/module002.html +147 -124
  180. data/spec/templates/examples/module003.html +94 -81
  181. data/spec/templates/examples/module004.html +40 -33
  182. data/spec/templates/helpers/base_helper_spec.rb +91 -95
  183. data/spec/templates/helpers/html_helper_spec.rb +276 -279
  184. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
  185. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
  186. data/spec/templates/helpers/markup_helper_spec.rb +57 -57
  187. data/spec/templates/helpers/method_helper_spec.rb +20 -20
  188. data/spec/templates/helpers/shared_signature_examples.rb +33 -31
  189. data/spec/templates/helpers/text_helper_spec.rb +6 -6
  190. data/spec/templates/method_spec.rb +7 -7
  191. data/spec/templates/module_spec.rb +7 -7
  192. data/spec/templates/onefile_spec.rb +7 -7
  193. data/spec/templates/section_spec.rb +66 -69
  194. data/spec/templates/spec_helper.rb +1 -1
  195. data/spec/templates/tag_spec.rb +5 -5
  196. data/spec/templates/template_spec.rb +158 -158
  197. data/spec/verifier_spec.rb +52 -52
  198. data/templates/default/fulldoc/html/css/full_list.css +32 -31
  199. data/templates/default/fulldoc/html/css/style.css +212 -77
  200. data/templates/default/fulldoc/html/frames.erb +6 -15
  201. data/templates/default/fulldoc/html/full_list.erb +14 -21
  202. data/templates/default/fulldoc/html/full_list_class.erb +1 -1
  203. data/templates/default/fulldoc/html/full_list_file.erb +6 -4
  204. data/templates/default/fulldoc/html/full_list_method.erb +8 -6
  205. data/templates/default/fulldoc/html/js/app.js +100 -76
  206. data/templates/default/fulldoc/html/js/full_list.js +170 -135
  207. data/templates/default/fulldoc/html/setup.rb +50 -7
  208. data/templates/default/layout/html/breadcrumb.erb +0 -2
  209. data/templates/default/layout/html/headers.erb +2 -1
  210. data/templates/default/layout/html/layout.erb +16 -10
  211. data/templates/default/layout/html/script_setup.erb +1 -2
  212. data/templates/default/layout/html/search.erb +7 -2
  213. data/templates/default/layout/html/setup.rb +16 -0
  214. data/templates/default/method/html/header.erb +7 -6
  215. data/templates/default/module/html/attribute_summary.erb +1 -1
  216. data/templates/default/module/html/box_info.erb +24 -18
  217. data/templates/default/module/html/constant_summary.erb +9 -11
  218. data/templates/default/module/html/item_summary.erb +1 -1
  219. data/templates/default/module/html/method_summary.erb +1 -1
  220. data/templates/guide/fulldoc/html/setup.rb +1 -1
  221. data/yard.gemspec +1 -2
  222. metadata +10 -7
  223. data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
  224. data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
  225. data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
@@ -1,17 +1,17 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe YARD::CLI::Graph do
4
- it "should serialize output" do
5
- Registry.should_receive(:load).at_least(1).times
6
- subject.stub(:yardopts) { [] }
7
- subject.options.serializer.should_receive(:serialize).once
4
+ it "serializes output" do
5
+ expect(Registry).to receive(:load).at_least(1).times
6
+ allow(subject).to receive(:yardopts) { [] }
7
+ expect(subject.options.serializer).to receive(:serialize).once
8
8
  subject.run
9
9
  end
10
10
 
11
- it 'should read yardoc file from .yardopts' do
12
- subject.stub(:yardopts) { %w(--db /path/to/db) }
13
- subject.options.serializer.should_receive(:serialize).once
11
+ it "reads yardoc file from .yardopts" do
12
+ allow(subject).to receive(:yardopts) { %w(--db /path/to/db) }
13
+ expect(subject.options.serializer).to receive(:serialize).once
14
14
  subject.run
15
- Registry.yardoc_file.should == '/path/to/db'
15
+ expect(Registry.yardoc_file).to eq '/path/to/db'
16
16
  end
17
17
  end
@@ -1,21 +1,21 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe YARD::CLI::Help do
4
- describe '#run' do
5
- it "should accept 'help command'" do
6
- CLI::Yardoc.should_receive(:run).with('--help')
4
+ describe "#run" do
5
+ it "accepts help command" do
6
+ expect(CLI::Yardoc).to receive(:run).with('--help')
7
7
  CLI::Help.run('doc')
8
8
  end
9
9
 
10
- it "should accept no arguments (lists all commands)" do
11
- CLI::CommandParser.should_receive(:run).with('--help')
10
+ it "accepts no arguments (and lists all commands)" do
11
+ expect(CLI::CommandParser).to receive(:run).with('--help')
12
12
  CLI::Help.run
13
13
  end
14
14
 
15
- it "should show all commands if command isn't found" do
16
- CLI::CommandParser.should_receive(:run).with('--help')
15
+ it "shows all commands if command isn't found" do
16
+ expect(CLI::CommandParser).to receive(:run).with('--help')
17
17
  help = CLI::Help.new
18
- log.should_receive(:puts).with(/not found/)
18
+ expect(log).to receive(:puts).with(/not found/)
19
19
  help.run('unknown')
20
20
  end
21
21
  end
@@ -6,105 +6,101 @@ describe YARD::CLI::I18n do
6
6
  @i18n.use_document_file = false
7
7
  @i18n.use_yardopts_file = false
8
8
  output_path = File.expand_path(@i18n.options.serializer.basepath)
9
- File.stub!(:open!).with(output_path, "wb")
10
- YARD.stub!(:parse)
9
+ allow(File).to receive(:open!).with(output_path, "wb")
10
+ allow(YARD).to receive(:parse)
11
11
  end
12
12
 
13
- describe 'Defaults' do
13
+ describe "Defaults" do
14
14
  before do
15
15
  @i18n = YARD::CLI::I18n.new
16
- @i18n.stub!(:yardopts).and_return([])
17
- @i18n.stub!(:support_rdoc_document_file!).and_return([])
16
+ allow(@i18n).to receive(:yardopts).and_return([])
17
+ allow(@i18n).to receive(:support_rdoc_document_file!).and_return([])
18
18
  @i18n.parse_arguments
19
19
  end
20
20
 
21
- it "should read .yardopts by default" do
22
- @i18n.use_yardopts_file.should == true
21
+ it "reads .yardopts by default" do
22
+ expect(@i18n.use_yardopts_file).to be true
23
23
  end
24
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]
25
+ it "only shows public visibility by default" do
26
+ expect(@i18n.visibilities).to eq [:public]
31
27
  end
32
28
  end
33
29
 
34
- describe 'General options' do
30
+ describe "General options" do
35
31
  def self.should_accept(*args, &block)
36
32
  @counter ||= 0
37
33
  @counter += 1
38
34
  counter = @counter
39
35
  args.each do |arg|
40
36
  define_method("test_options_#{@counter}", &block)
41
- it("should accept #{arg}") { send("test_options_#{counter}", arg) }
37
+ it("accepts #{arg}") { send("test_options_#{counter}", arg) }
42
38
  end
43
39
  end
44
40
 
45
41
  should_accept('--yardopts') do |arg|
46
42
  @i18n = YARD::CLI::I18n.new
47
43
  @i18n.use_document_file = false
48
- @i18n.should_receive(:yardopts).at_least(1).times.and_return([])
44
+ expect(@i18n).to receive(:yardopts).at_least(1).times.and_return([])
49
45
  @i18n.parse_arguments(arg)
50
- @i18n.use_yardopts_file.should == true
46
+ expect(@i18n.use_yardopts_file).to be true
51
47
  @i18n.parse_arguments('--no-yardopts', arg)
52
- @i18n.use_yardopts_file.should == true
48
+ expect(@i18n.use_yardopts_file).to be true
53
49
  end
54
50
 
55
51
  should_accept('--yardopts with filename') do |arg|
56
52
  @i18n = YARD::CLI::I18n.new
57
- File.should_receive(:read_binary).with('.yardopts_i18n').and_return('')
53
+ expect(File).to receive(:read_binary).with('.yardopts_i18n').and_return('')
58
54
  @i18n.use_document_file = false
59
55
  @i18n.parse_arguments('--yardopts', '.yardopts_i18n')
60
- @i18n.use_yardopts_file.should == true
61
- @i18n.options_file.should == '.yardopts_i18n'
56
+ expect(@i18n.use_yardopts_file).to be true
57
+ expect(@i18n.options_file).to eq '.yardopts_i18n'
62
58
  end
63
59
 
64
60
  should_accept('--no-yardopts') do |arg|
65
61
  @i18n = YARD::CLI::I18n.new
66
62
  @i18n.use_document_file = false
67
- @i18n.should_not_receive(:yardopts)
63
+ expect(@i18n).not_to receive(:yardopts)
68
64
  @i18n.parse_arguments(arg)
69
- @i18n.use_yardopts_file.should == false
65
+ expect(@i18n.use_yardopts_file).to be false
70
66
  @i18n.parse_arguments('--yardopts', arg)
71
- @i18n.use_yardopts_file.should == false
67
+ expect(@i18n.use_yardopts_file).to be false
72
68
  end
73
69
 
74
70
  should_accept('--exclude') do |arg|
75
- YARD.should_receive(:parse).with(['a'], ['nota', 'b'])
71
+ expect(YARD).to receive(:parse).with(['a'], ['nota', 'b'])
76
72
  @i18n.run(arg, 'nota', arg, 'b', 'a')
77
73
  end
78
74
  end
79
75
 
80
- describe '.yardopts handling' do
76
+ describe ".yardopts handling" do
81
77
  before do
82
78
  @i18n.use_yardopts_file = true
83
79
  end
84
80
 
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")
81
+ it "searches for and uses yardopts file specified by #options_file" do
82
+ expect(File).to receive(:read_binary).with("test").and_return("-o \n\nMYPATH\nFILE1 FILE2")
87
83
  @i18n.use_document_file = false
88
84
  @i18n.options_file = "test"
89
- File.should_receive(:open!).with(File.expand_path("MYPATH"), "wb")
85
+ expect(File).to receive(:open!).with(File.expand_path("MYPATH"), "wb")
90
86
  @i18n.run
91
- @i18n.files.should == ["FILE1", "FILE2"]
87
+ expect(@i18n.files).to eq ["FILE1", "FILE2"]
92
88
  end
93
89
  end
94
90
 
95
- describe '#run' do
96
- it "should parse_arguments if run() is called" do
97
- @i18n.should_receive(:parse_arguments)
91
+ describe "#run" do
92
+ it "calls parse_arguments if run() is called" do
93
+ expect(@i18n).to receive(:parse_arguments)
98
94
  @i18n.run
99
95
  end
100
96
 
101
- it "should parse_arguments if run(arg1, arg2, ...) is called" do
102
- @i18n.should_receive(:parse_arguments)
97
+ it "calls parse_arguments if run(arg1, arg2, ...) is called" do
98
+ expect(@i18n).to receive(:parse_arguments)
103
99
  @i18n.run('--private', '-p', 'foo')
104
100
  end
105
101
 
106
- it "should not parse_arguments if run(nil) is called" do
107
- @i18n.should_not_receive(:parse_arguments)
102
+ it "doesn't call parse_arguments if run(nil) is called" do
103
+ expect(@i18n).not_to receive(:parse_arguments)
108
104
  @i18n.run(nil)
109
105
  end
110
106
  end
@@ -1,8 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe YARD::CLI::List do
4
- it "should pass command off to Yardoc with --list" do
5
- YARD::CLI::Yardoc.should_receive(:run).with('-c', '--list', '--foo')
4
+ it "passes command off to Yardoc with --list" do
5
+ expect(YARD::CLI::Yardoc).to receive(:run).with('-c', '--list', '--foo')
6
6
  YARD::CLI::List.run('--foo')
7
7
  end
8
8
  end
@@ -6,16 +6,16 @@ describe YARD::CLI::MarkupTypes do
6
6
  data = log.io.string
7
7
  exts = YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS
8
8
  YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS.each do |name, providers|
9
- data.should match(/\b#{name}\b/)
9
+ expect(data).to match(/\b#{name}\b/)
10
10
 
11
11
  # Match all extensions
12
12
  exts[name].each do |ext|
13
- data.should include(".#{ext}")
13
+ expect(data).to include(".#{ext}")
14
14
  end if exts[name]
15
15
 
16
16
  # Match all provider libs
17
17
  providers.each do |provider|
18
- data.should match(/\b#{provider[:lib]}\b/)
18
+ expect(data).to match(/\b#{provider[:lib]}\b/)
19
19
  end
20
20
  end
21
21
  end
@@ -4,15 +4,14 @@ class Server::WebrickAdapter; def start; end end
4
4
 
5
5
  describe YARD::CLI::Server do
6
6
  before do
7
- CLI::Yardoc.stub!(:run)
7
+ allow(CLI::Yardoc).to receive(:run)
8
8
  @no_verify_libraries = false
9
9
  @set_libraries = true
10
10
  @no_adapter_mock = false
11
11
  @libraries = {}
12
12
  @options = {:single_library => true, :caching => false}
13
13
  @server_options = {:Port => 8808}
14
- @adapter = mock(:adapter)
15
- @adapter.stub!(:setup)
14
+ @adapter = double(:adapter, :setup => nil)
16
15
  new_cli
17
16
  end
18
17
 
@@ -46,15 +45,15 @@ describe YARD::CLI::Server do
46
45
  @libraries.values.each do |libs|
47
46
  libs.each do |lib|
48
47
  yfile = File.expand_path(lib.yardoc_file)
49
- File.stub!(:exist?).with(yfile).and_return(true)
48
+ allow(File).to receive(:exist?).with(yfile).and_return(true)
50
49
  end
51
50
  end
52
51
  end
53
52
  unless @no_adapter_mock
54
- @cli.stub!(:adapter).and_return(@adapter)
55
- @adapter.should_receive(:new).
53
+ allow(@cli).to receive(:adapter).and_return(@adapter)
54
+ expect(@adapter).to receive(:new).
56
55
  with(@libraries, @options, @server_options).and_return(@adapter)
57
- @adapter.should_receive(:start)
56
+ expect(@adapter).to receive(:start)
58
57
  end
59
58
 
60
59
  @cli.run(*args.flatten)
@@ -62,12 +61,12 @@ describe YARD::CLI::Server do
62
61
  end
63
62
 
64
63
  def assert_libraries(expected_libs, actual_libs)
65
- actual_libs.should == expected_libs
64
+ expect(actual_libs).to eq expected_libs
66
65
  expected_libs.each do |name, libs|
67
66
  libs.each_with_index do |expected,i|
68
67
  actual = actual_libs[name][i]
69
68
  [:source, :source_path, :yardoc_file].each do |m|
70
- actual.send(m).should == expected.send(m)
69
+ expect(actual.send(m)).to eq expected.send(m)
71
70
  end
72
71
  end
73
72
  end
@@ -75,34 +74,34 @@ describe YARD::CLI::Server do
75
74
 
76
75
  # Mocks the existence of a file.
77
76
  def mock_file(filename, content = nil)
78
- File.stub!(:exist?).with(filename).and_return(true)
79
- File.stub!(:read_binary).with(filename).and_return(content) if content
77
+ allow(File).to receive(:exist?).with(filename).and_return(true)
78
+ allow(File).to receive(:read_binary).with(filename).and_return(content) if content
80
79
  filename_e = File.expand_path(filename)
81
80
  mock_file(filename_e) unless filename_e == filename
82
81
  end
83
82
 
84
- describe 'when .yardopts file exists' do
83
+ context 'when .yardopts file exists' do
85
84
  before :each do
86
85
  Registry.yardoc_file = Registry::DEFAULT_YARDOC_FILE
87
- Dir.stub!(:pwd).and_return('/path/to/bar')
86
+ allow(Dir).to receive(:pwd).and_return('/path/to/bar')
88
87
  @name = 'bar'
89
88
  end
90
89
 
91
- it "should use .yardoc as the yardoc db if .yardopts doesn't specify an alternate path" do
90
+ it "uses .yardoc as the yardoc db if .yardopts doesn't specify an alternate path" do
92
91
  mock_file '/path/to/bar/.yardopts', '--protected'
93
92
  @libraries[@name] = [Server::LibraryVersion.new(@name, nil, File.expand_path('/path/to/bar/.yardoc'))]
94
93
  @libraries.values[0][0].source_path = File.expand_path('/path/to/bar')
95
94
  run
96
95
  end
97
96
 
98
- it "should use the yardoc db location specified by .yardopts" do
97
+ it "uses the yardoc db location specified by .yardopts" do
99
98
  mock_file '/path/to/bar/.yardopts', '--db foo'
100
99
  @libraries[@name] = [Server::LibraryVersion.new(@name, nil, File.expand_path('/path/to/bar/foo'))]
101
100
  @libraries.values[0][0].source_path = File.expand_path('/path/to/bar')
102
101
  run
103
102
  end
104
103
 
105
- it "should parse .yardopts when the library list is odd" do
104
+ it "parses .yardopts when the library list is odd" do
106
105
  mock_file '/path/to/bar/.yardopts', '--db foo'
107
106
  @libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('/path/to/bar/foo'))]
108
107
  @libraries.values[0][0].source_path = File.expand_path('/path/to/bar')
@@ -110,203 +109,190 @@ describe YARD::CLI::Server do
110
109
  end
111
110
  end
112
111
 
113
- describe "when .yardopts file doesn't exist" do
112
+ context "when .yardopts file doesn't exist" do
114
113
  before :each do
115
- File.stub(:exist?).with(/^(.*[\\\/])?\.yardopts$/).and_return(false)
114
+ allow(File).to receive(:exist?).with(/^(.*[\\\/])?\.yardopts$/).and_return(false)
116
115
  end
117
116
 
118
- it "should default to .yardoc if no library is specified" do
119
- Dir.should_receive(:pwd).at_least(:once).and_return(File.expand_path('/path/to/foo'))
117
+ it "defaults to .yardoc if no library is specified" do
118
+ expect(Dir).to receive(:pwd).at_least(:once).and_return(File.expand_path('/path/to/foo'))
120
119
  @libraries['foo'] = [Server::LibraryVersion.new('foo', nil, File.expand_path('/path/to/foo/.yardoc'))]
121
120
  run
122
121
  end
123
122
 
124
- it "should use .yardoc as yardoc file if library list is odd" do
123
+ it "uses .yardoc as yardoc file if library list is odd" do
125
124
  @libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('.yardoc'))]
126
125
  run 'a'
127
126
  end
128
127
 
129
- it "should force multi library if more than one library is listed" do
130
- File.stub(:exist?).with('b').and_return(true)
128
+ it "forces multi library if more than one library is listed" do
129
+ allow(File).to receive(:exist?).with('b').and_return(true)
131
130
  @options[:single_library] = false
132
131
  @libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('b'))]
133
132
  @libraries['c'] = [Server::LibraryVersion.new('c', nil, File.expand_path('.yardoc'))]
134
133
  run %w(a b c)
135
134
  end
136
135
 
137
- it "should fail if specified directory does not exist" do
136
+ it "fails if specified directory does not exist" do
138
137
  @set_libraries = false
139
- File.stub(:exist?).with('b').and_return(false)
140
- log.should_receive(:warn).with(/Cannot find yardoc db for a: "b"/)
138
+ allow(File).to receive(:exist?).with('b').and_return(false)
139
+ expect(log).to receive(:warn).with(/Cannot find yardoc db for a: "b"/)
141
140
  run %w(a b)
142
141
  end
143
142
  end
144
143
 
145
- describe 'General options' do
144
+ describe "General options" do
146
145
  before do
147
- File.stub(:exist?).with(/\.yardopts$/).and_return(false)
146
+ allow(File).to receive(:exist?).with(/\.yardopts$/).and_return(false)
148
147
  end
149
148
 
150
- it "should accept -m, --multi-library" do
149
+ it "accepts -m, --multi-library" do
151
150
  @options[:single_library] = false
152
151
  run '-m'
153
152
  run '--multi-library'
154
153
  end
155
154
 
156
- it "should accept -c, --cache" do
155
+ it "accepts -c, --cache" do
157
156
  @options[:caching] = true
158
157
  run '-c'
159
158
  run '--cache'
160
159
  end
161
160
 
162
- it "should accept -r, --reload" do
161
+ it "accepts -r, --reload" do
163
162
  @options[:incremental] = true
164
163
  run '-r'
165
164
  run '--reload'
166
165
  end
167
166
 
168
- it "should accept -d, --daemon" do
167
+ it "accepts -d, --daemon" do
169
168
  @server_options[:daemonize] = true
170
169
  run '-d'
171
170
  run '--daemon'
172
171
  end
173
172
 
174
- it "should accept -B, --bind" do
173
+ it "accepts -B, --bind" do
175
174
  @server_options[:Host] = 'example.com'
176
175
  run '-B', 'example.com'
177
176
  run '--bind', 'example.com'
178
177
  end
179
178
 
180
- it "should bind address with WebRick adapter" do
179
+ it "binds address with WebRick adapter" do
181
180
  @server_options[:Host] = 'example.com'
182
181
  run '-B', 'example.com', '-a', 'webrick'
183
182
  run '--bind', 'example.com', '-a', 'webrick'
184
183
  end
185
184
 
186
- it "should bind address with Rack adapter" do
185
+ it "binds address with Rack adapter" do
187
186
  @server_options[:Host] = 'example.com'
188
187
  run '-B', 'example.com', '-a', 'rack'
189
188
  run '--bind', 'example.com', '-a', 'rack'
190
189
  end
191
190
 
192
- it "should accept -p, --port" do
191
+ it "accepts -p, --port" do
193
192
  @server_options[:Port] = 10
194
193
  run '-p', '10'
195
194
  run '--port', '10'
196
195
  end
197
196
 
198
- it "should accept --docroot" do
197
+ it "accepts --docroot" do
199
198
  @server_options[:DocumentRoot] = Dir.pwd + '/__foo/bar'
200
199
  run '--docroot', '__foo/bar'
201
200
  end
202
201
 
203
- it "should accept -a webrick to create WEBrick adapter" do
204
- @cli.should_receive(:adapter=).with(YARD::Server::WebrickAdapter)
202
+ it "accepts -a webrick to create WEBrick adapter" do
203
+ expect(@cli).to receive(:adapter=).with(YARD::Server::WebrickAdapter)
205
204
  run '-a', 'webrick'
206
205
  end
207
206
 
208
- it "should accept -a rack to create Rack adapter" do
207
+ it "accepts -a rack to create Rack adapter" do
209
208
  rack_required
210
- @cli.should_receive(:adapter=).with(YARD::Server::RackAdapter)
209
+ expect(@cli).to receive(:adapter=).with(YARD::Server::RackAdapter)
211
210
  run '-a', 'rack'
212
211
  end
213
212
 
214
- it "should default to Rack adapter if exists on system" do
213
+ it "defaults to Rack adapter if exists on system" do
215
214
  rack_required
216
- @cli.should_receive(:require).with('rubygems').and_return(false)
217
- @cli.should_receive(:require).with('rack').and_return(true)
218
- @cli.should_receive(:adapter=).with(YARD::Server::RackAdapter)
215
+ expect(@cli).to receive(:require).with('rubygems').and_return(false)
216
+ expect(@cli).to receive(:require).with('rack').and_return(true)
217
+ expect(@cli).to receive(:adapter=).with(YARD::Server::RackAdapter)
219
218
  @cli.send(:select_adapter)
220
219
  end
221
220
 
222
- it "should fall back to WEBrick adapter if Rack is not on system" do
223
- @cli.should_receive(:require).with('rubygems').and_return(false)
224
- @cli.should_receive(:require).with('rack').and_raise(LoadError)
225
- @cli.should_receive(:adapter=).with(YARD::Server::WebrickAdapter)
221
+ it "falls back to WEBrick adapter if Rack is not on system" do
222
+ expect(@cli).to receive(:require).with('rubygems').and_return(false)
223
+ expect(@cli).to receive(:require).with('rack').and_raise(LoadError)
224
+ expect(@cli).to receive(:adapter=).with(YARD::Server::WebrickAdapter)
226
225
  @cli.send(:select_adapter)
227
226
  end
228
227
 
229
- it "should accept -s, --server" do
228
+ it "accepts -s, --server" do
230
229
  @server_options[:server] = 'thin'
231
230
  run '-s', 'thin'
232
231
  run '--server', 'thin'
233
232
  end
234
233
 
235
- it "should accept -g, --gems" do
234
+ it "accepts -g, --gems" do
236
235
  @no_verify_libraries = true
237
236
  @options[:single_library] = false
238
237
  @libraries['gem1'] = [Server::LibraryVersion.new('gem1', '1.0.0', nil, :gem)]
239
238
  @libraries['gem2'] = [Server::LibraryVersion.new('gem2', '1.0.0', nil, :gem)]
240
- gem1 = mock(:gem1)
241
- gem1.stub!(:name).and_return('gem1')
242
- gem1.stub!(:version).and_return('1.0.0')
243
- gem1.stub!(:full_gem_path).and_return('/path/to/foo')
244
- gem2 = mock(:gem2)
245
- gem2.stub!(:name).and_return('gem2')
246
- gem2.stub!(:version).and_return('1.0.0')
247
- gem2.stub!(:full_gem_path).and_return('/path/to/bar')
239
+ gem1 = double(:gem1, :name => 'gem1', :version => '1.0.0', :full_gem_path => '/path/to/foo')
240
+ gem2 = double(:gem2, :name => 'gem2', :version => '1.0.0', :full_gem_path => '/path/to/bar')
248
241
  specs = {'gem1' => gem1, 'gem2' => gem2}
249
- source = mock(:source_index)
250
- source.stub!(:find_name).and_return do |k, ver|
242
+ source = double(:source_index)
243
+ allow(source).to receive(:find_name) do |k, ver|
251
244
  k == '' ? specs.values : specs.grep(k).map {|name| specs[name] }
252
245
  end
253
- Gem.stub!(:source_index).and_return(source)
246
+ allow(Gem).to receive(:source_index).and_return(source)
254
247
  run '-g'
255
248
  run '--gems'
256
249
  end
257
250
 
258
- it "should accept -G, --gemfile" do
251
+ it "accepts -G, --gemfile" do
259
252
  bundler_required
260
253
  @no_verify_libraries = true
261
254
  @options[:single_library] = false
262
255
 
263
256
  @libraries['gem1'] = [Server::LibraryVersion.new('gem1', '1.0.0', nil, :gem)]
264
257
  @libraries['gem2'] = [Server::LibraryVersion.new('gem2', '1.0.0', nil, :gem)]
265
- gem1 = mock(:gem1)
266
- gem1.stub!(:name).and_return('gem1')
267
- gem1.stub!(:version).and_return('1.0.0')
268
- gem1.stub!(:full_gem_path).and_return('/path/to/foo')
269
- gem2 = mock(:gem2)
270
- gem2.stub!(:name).and_return('gem2')
271
- gem2.stub!(:version).and_return('1.0.0')
272
- gem2.stub!(:full_gem_path).and_return('/path/to/bar')
258
+ gem1 = double(:gem1, :name => 'gem1', :version => '1.0.0', :full_gem_path => '/path/to/foo')
259
+ gem2 = double(:gem2, :name => 'gem2', :version => '1.0.0', :full_gem_path => '/path/to/bar')
273
260
  specs = {'gem1' => gem1, 'gem2' => gem2}
274
- lockfile_parser = mock(:new)
275
- lockfile_parser.stub!(:specs).and_return([gem1, gem2])
276
- Bundler::LockfileParser.stub!(:new).and_return(lockfile_parser)
261
+ lockfile_parser = double(:new, :specs => [gem1, gem2])
262
+ allow(Bundler::LockfileParser).to receive(:new).and_return(lockfile_parser)
277
263
 
278
- File.should_receive(:exist?).at_least(2).times.with("Gemfile.lock").and_return(true)
279
- File.stub!(:read)
264
+ expect(File).to receive(:exist?).at_least(2).times.with("Gemfile.lock").and_return(true)
265
+ allow(File).to receive(:read)
280
266
 
281
267
  run '-G'
282
268
  run '--gemfile'
283
269
 
284
- File.should_receive(:exist?).with("different_name.lock").and_return(true)
270
+ expect(File).to receive(:exist?).with("different_name.lock").and_return(true)
285
271
  run '--gemfile', 'different_name'
286
272
  end
287
273
 
288
- it "should warn if lockfile is not found (with -G)" do
274
+ it "warns if lockfile is not found (with -G)" do
289
275
  bundler_required
290
- File.should_receive(:exist?).with(/\.yardopts$/).at_least(:once).and_return(false)
291
- File.should_receive(:exist?).with('somefile.lock').and_return(false)
292
- log.should_receive(:warn).with(/Cannot find somefile.lock/)
276
+ expect(File).to receive(:exist?).with(/\.yardopts$/).at_least(:once).and_return(false)
277
+ expect(File).to receive(:exist?).with('somefile.lock').and_return(false)
278
+ expect(log).to receive(:warn).with(/Cannot find somefile.lock/)
293
279
  run '-G', 'somefile'
294
280
  end
295
281
 
296
- it "should error if Bundler not available (with -G)" do
297
- @cli.should_receive(:require).with('bundler').and_raise(LoadError)
298
- log.should_receive(:error).with(/Bundler not available/)
282
+ it "displays an error if Bundler not available (with -G)" do
283
+ expect(@cli).to receive(:require).with('bundler').and_raise(LoadError)
284
+ expect(log).to receive(:error).with(/Bundler not available/)
299
285
  run '-G'
300
286
  end
301
287
 
302
- it "should load template paths after adapter template paths" do
288
+ it "loads template paths after adapter template paths" do
303
289
  unstub_adapter
304
290
  @cli.adapter = Server::WebrickAdapter
305
291
  run '-t', 'foo'
306
- Templates::Engine.template_paths.last.should == 'foo'
292
+ expect(Templates::Engine.template_paths.last).to eq 'foo'
307
293
  end
308
294
 
309
- it "should load ruby code (-e) after adapter" do
295
+ it "loads ruby code (-e) after adapter" do
310
296
  unstub_adapter
311
297
  @cli.adapter = Server::WebrickAdapter
312
298
  path = File.dirname(__FILE__) + '/tmp.adapterscript.rb'
@@ -315,7 +301,7 @@ describe YARD::CLI::Server do
315
301
  f.puts "YARD::Templates::Engine.register_template_path 'foo'"
316
302
  f.flush
317
303
  run '-e', f.path
318
- Templates::Engine.template_paths.last.should == 'foo'
304
+ expect(Templates::Engine.template_paths.last).to eq 'foo'
319
305
  end
320
306
  ensure
321
307
  File.unlink(path)