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
@@ -3,11 +3,11 @@
3
3
 
4
4
 
5
5
  </h1>
6
-
7
- <dl class="box">
6
+ <div class="box_info">
8
7
 
9
- <dt class="r1">Inherits:</dt>
10
- <dd class="r1">
8
+ <dl>
9
+ <dt>Inherits:</dt>
10
+ <dd>
11
11
  <span class="inheritName">Object</span>
12
12
 
13
13
  <ul class="fullTree">
@@ -18,41 +18,47 @@
18
18
  </ul>
19
19
  <a href="#" class="inheritanceTree">show all</a>
20
20
 
21
- </dd>
22
-
21
+ </dd>
22
+ </dl>
23
23
 
24
+
24
25
 
25
-
26
- <dt class="r2">Extended by:</dt>
27
- <dd class="r2">Bar</dd>
28
-
29
-
30
26
 
31
-
32
- <dt class="r1">Includes:</dt>
33
- <dd class="r1">BarFooBar, Baz::ABC, Baz::XYZ, Foo</dd>
34
-
35
-
27
+ <dl>
28
+ <dt>Extended by:</dt>
29
+ <dd>Bar</dd>
30
+ </dl>
36
31
 
37
32
 
38
33
 
39
- <dt class="r2 last">Defined in:</dt>
40
- <dd class="r2 last">(stdin)</dd>
34
+ <dl>
35
+ <dt>Includes:</dt>
36
+ <dd>BarFooBar, Baz::ABC, Baz::XYZ, Foo</dd>
37
+ </dl>
41
38
 
42
- </dl>
43
- <div class="clear"></div>
39
+
40
+
41
+
42
+
43
+
44
+ <dl>
45
+ <dt>Defined in:</dt>
46
+ <dd>(stdin)</dd>
47
+ </dl>
48
+
49
+ </div>
44
50
 
45
51
 
46
52
 
47
53
 
48
54
 
49
- <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
55
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
50
56
  <ul class="summary">
51
57
 
52
58
  <li class="public ">
53
59
  <span class="summary_signature">
54
60
 
55
- <a title="#bar_attr (instance method)">- <strong>bar_attr</strong> </a>
61
+ <a title="#bar_attr (instance method)">#<strong>bar_attr</strong> </a>
56
62
 
57
63
 
58
64
 
@@ -87,7 +93,7 @@
87
93
 
88
94
  <h2>
89
95
  Booya
90
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
96
+ <small><a href="#" class="summary_toggle">collapse</a></small>
91
97
  </h2>
92
98
 
93
99
  <ul class="summary">
@@ -95,7 +101,7 @@
95
101
  <li class="public ">
96
102
  <span class="summary_signature">
97
103
 
98
- <a title="#baz (class method)">+ <strong>baz</strong> </a>
104
+ <a title="#baz (class method)">.<strong>baz</strong> </a>
99
105
 
100
106
 
101
107
 
@@ -122,7 +128,7 @@
122
128
  <li class="public ">
123
129
  <span class="summary_signature">
124
130
 
125
- <a title="#baz_abc (instance method)">- <strong>baz_abc</strong> </a>
131
+ <a title="#baz_abc (instance method)">#<strong>baz_abc</strong> </a>
126
132
 
127
133
 
128
134
 
@@ -150,7 +156,7 @@
150
156
 
151
157
  <h2>
152
158
  Instance Method Summary
153
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
159
+ <small><a href="#" class="summary_toggle">collapse</a></small>
154
160
  </h2>
155
161
 
156
162
  <ul class="summary">
@@ -158,7 +164,7 @@
158
164
  <li class="public ">
159
165
  <span class="summary_signature">
160
166
 
161
- <a title="#foo (instance method)">- <strong>foo</strong> </a>
167
+ <a title="#foo (instance method)">#<strong>foo</strong> </a>
162
168
 
163
169
 
164
170
 
@@ -180,7 +186,7 @@
180
186
  <li class="public ">
181
187
  <span class="summary_signature">
182
188
 
183
- <a title="#xyz (instance method)">- <strong>xyz</strong> </a>
189
+ <a title="#xyz (instance method)">#<strong>xyz</strong> </a>
184
190
 
185
191
 
186
192
 
@@ -244,7 +250,7 @@
244
250
  <div class="method_details first">
245
251
  <h3 class="signature first" id="bar_attr-instance_method">
246
252
 
247
- - <strong>bar_attr</strong>
253
+ #<strong>bar_attr</strong>
248
254
 
249
255
 
250
256
 
@@ -277,7 +283,7 @@
277
283
  <div class="method_details first">
278
284
  <h3 class="signature first" id="baz-class_method">
279
285
 
280
- + <strong>baz</strong>
286
+ .<strong>baz</strong>
281
287
 
282
288
 
283
289
 
@@ -309,7 +315,7 @@
309
315
  <div class="method_details first">
310
316
  <h3 class="signature first" id="baz_abc-instance_method">
311
317
 
312
- - <strong>baz_abc</strong>
318
+ #<strong>baz_abc</strong>
313
319
 
314
320
 
315
321
 
@@ -326,7 +332,7 @@
326
332
  <div class="method_details ">
327
333
  <h3 class="signature " id="foo-instance_method">
328
334
 
329
- - <strong>foo</strong>
335
+ #<strong>foo</strong>
330
336
 
331
337
 
332
338
 
@@ -361,7 +367,7 @@ def foo; end</pre>
361
367
  <div class="method_details ">
362
368
  <h3 class="signature " id="xyz-instance_method">
363
369
 
364
- - <strong>xyz</strong>
370
+ #<strong>xyz</strong>
365
371
 
366
372
 
367
373
 
@@ -385,3 +391,4 @@ def foo; end</pre>
385
391
  </div>
386
392
 
387
393
  </div>
394
+
@@ -3,173 +3,169 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe YARD::Templates::Helpers::BaseHelper do
4
4
  include YARD::Templates::Helpers::BaseHelper
5
5
 
6
- describe '#run_verifier' do
7
- it "should run verifier proc against list if provided" do
6
+ describe "#run_verifier" do
7
+ it "runs verifier proc against list if provided" do
8
8
  mock = Verifier.new
9
- mock.should_receive(:call).with(1)
10
- mock.should_receive(:call).with(2)
11
- mock.should_receive(:call).with(3)
12
- should_receive(:options).at_least(1).times.and_return(Options.new.update(:verifier => mock))
9
+ expect(mock).to receive(:call).with(1)
10
+ expect(mock).to receive(:call).with(2)
11
+ expect(mock).to receive(:call).with(3)
12
+ expect(self).to receive(:options).at_least(1).times.and_return(Options.new.update(:verifier => mock))
13
13
  run_verifier [1, 2, 3]
14
14
  end
15
15
 
16
- it "should prune list if lambda returns false and only false" do
16
+ it "prunes list if lambda returns false and only false" do
17
17
  mock = Verifier.new
18
- should_receive(:options).at_least(1).times.and_return(Options.new.update(:verifier => mock))
19
- mock.should_receive(:call).with(1).and_return(false)
20
- mock.should_receive(:call).with(2).and_return(true)
21
- mock.should_receive(:call).with(3).and_return(nil)
22
- mock.should_receive(:call).with(4).and_return("value")
23
- run_verifier([1, 2, 3, 4]).should == [2, 3, 4]
18
+ expect(self).to receive(:options).at_least(1).times.and_return(Options.new.update(:verifier => mock))
19
+ expect(mock).to receive(:call).with(1).and_return(false)
20
+ expect(mock).to receive(:call).with(2).and_return(true)
21
+ expect(mock).to receive(:call).with(3).and_return(nil)
22
+ expect(mock).to receive(:call).with(4).and_return("value")
23
+ expect(run_verifier([1, 2, 3, 4])).to eq [2, 3, 4]
24
24
  end
25
25
 
26
- it "should return list if no verifier exists" do
27
- should_receive(:options).at_least(1).times.and_return(Options.new)
28
- run_verifier([1, 2, 3]).should == [1, 2, 3]
26
+ it "returns list if no verifier exists" do
27
+ expect(self).to receive(:options).at_least(1).times.and_return(Options.new)
28
+ expect(run_verifier([1, 2, 3])).to eq [1, 2, 3]
29
29
  end
30
30
  end
31
31
 
32
- describe '#h' do
33
- it "should return just the text" do
34
- h("hello world").should == "hello world"
35
- h(nil).should == nil
32
+ describe "#h" do
33
+ it "returns just the text" do
34
+ expect(h("hello world")).to eq "hello world"
35
+ expect(h(nil)).to eq nil
36
36
  end
37
37
  end
38
38
 
39
- describe '#link_object' do
40
- it "should return the title if provided" do
41
- link_object(1, "title").should == "title"
42
- link_object(Registry.root, "title").should == "title"
39
+ describe "#link_object" do
40
+ it "returns the title if provided" do
41
+ expect(link_object(1, "title")).to eq "title"
42
+ expect(link_object(Registry.root, "title")).to eq "title"
43
43
  end
44
44
 
45
- it "should return a path if argument is a Proxy or object" do
46
- link_object(Registry.root).should == "Top Level Namespace"
47
- link_object(P("Array")).should == "Array"
45
+ it "returns a path if argument is a Proxy or object" do
46
+ expect(link_object(Registry.root)).to eq "Top Level Namespace"
47
+ expect(link_object(P("Array"))).to eq "Array"
48
48
  end
49
49
 
50
- it "should should return path of Proxified object if argument is a String or Symbol" do
51
- link_object("Array").should == "Array"
52
- link_object(:"A::B").should == "A::B"
50
+ it "returns path of Proxified object if argument is a String or Symbol" do
51
+ expect(link_object("Array")).to eq "Array"
52
+ expect(link_object(:"A::B")).to eq "A::B"
53
53
  end
54
54
 
55
- it "should return the argument if not an object, proxy, String or Symbol" do
56
- link_object(1).should == 1
55
+ it "returns the argument if not an object, proxy, String or Symbol" do
56
+ expect(link_object(1)).to eq 1
57
57
  end
58
58
  end
59
59
 
60
- describe '#link_url' do
61
- it "should return the URL" do
62
- link_url("http://url").should == "http://url"
60
+ describe "#link_url" do
61
+ it "returns the URL" do
62
+ expect(link_url("http://url")).to eq "http://url"
63
63
  end
64
64
  end
65
65
 
66
- describe '#linkify' do
67
- before do
68
- stub!(:object).and_return(Registry.root)
69
- end
66
+ describe "#linkify" do
67
+ let(:object) { Registry.root }
68
+ # before do
69
+ # stub!(:object).and_return(Registry.root)
70
+ # end
70
71
 
71
- it "should call #link_url for mailto: links" do
72
- should_receive(:link_url)
72
+ it "calls #link_url for mailto: links" do
73
+ expect(self).to receive(:link_url)
73
74
  linkify("mailto:steve@example.com")
74
75
  end
75
76
 
76
- it "should call #link_url for URL schemes (http://)" do
77
- should_receive(:link_url)
77
+ it "calls #link_url for URL schemes (http://)" do
78
+ expect(self).to receive(:link_url)
78
79
  linkify("http://example.com")
79
80
  end
80
81
 
81
- it "should call #link_file for file: links" do
82
- should_receive(:link_file).with('Filename', nil, 'anchor')
82
+ it "calls #link_file for file: links" do
83
+ expect(self).to receive(:link_file).with('Filename', nil, 'anchor')
83
84
  linkify("file:Filename#anchor")
84
85
  end
85
86
 
86
- it "should pass off to #link_object if argument is an object" do
87
+ it "passes off to #link_object if argument is an object" do
87
88
  obj = CodeObjects::NamespaceObject.new(nil, :YARD)
88
- should_receive(:link_object).with(obj)
89
+ expect(self).to receive(:link_object).with(obj)
89
90
  linkify obj
90
91
  end
91
92
 
92
- it "should return empty string and warn if object does not exist" do
93
- log.should_receive(:warn).with(/Cannot find object .* for inclusion/)
94
- linkify('include:NotExist').should == ''
93
+ it "returns empty string and warn if object does not exist" do
94
+ expect(log).to receive(:warn).with(/Cannot find object .* for inclusion/)
95
+ expect(linkify('include:NotExist')).to eq ''
95
96
  end
96
97
 
97
- it "should pass off to #link_url if argument is recognized as a URL" do
98
+ it "passes off to #link_url if argument is recognized as a URL" do
98
99
  url = "http://yardoc.org/"
99
- should_receive(:link_url).with(url, nil, {:target => '_parent'})
100
+ expect(self).to receive(:link_url).with(url, nil, {:target => '_parent'})
100
101
  linkify url
101
102
  end
102
103
 
103
- it "should call #link_include_object for include:ObjectName" do
104
+ it "calls #link_include_object for include:ObjectName" do
104
105
  obj = CodeObjects::NamespaceObject.new(:root, :Foo)
105
- should_receive(:link_include_object).with(obj)
106
+ expect(self).to receive(:link_include_object).with(obj)
106
107
  linkify 'include:Foo'
107
108
  end
108
109
 
109
- it "should call #link_include_file for include:file:path/to/file" do
110
- File.should_receive(:file?).with('path/to/file').and_return(true)
111
- File.should_receive(:read).with('path/to/file').and_return('FOO')
112
- linkify('include:file:path/to/file').should == 'FOO'
110
+ it "calls #link_include_file for include:file:path/to/file" do
111
+ expect(File).to receive(:file?).with('path/to/file').and_return(true)
112
+ expect(File).to receive(:read).with('path/to/file').and_return('FOO')
113
+ expect(linkify('include:file:path/to/file')).to eq 'FOO'
113
114
  end
114
115
 
115
- it "should not allow include:file for path above pwd" do
116
- log.should_receive(:warn).with("Cannot include file from path `a/b/../../../../file'")
117
- linkify('include:file:a/b/../../../../file').should == ''
116
+ it "does not allow include:file for path above pwd" do
117
+ expect(log).to receive(:warn).with("Cannot include file from path `a/b/../../../../file'")
118
+ expect(linkify('include:file:a/b/../../../../file')).to eq ''
118
119
  end
119
120
 
120
- it "should warn if include:file:path does not exist" do
121
- log.should_receive(:warn).with(/Cannot find file .+ for inclusion/)
122
- linkify('include:file:notexist').should == ''
121
+ it "warns if include:file:path does not exist" do
122
+ expect(log).to receive(:warn).with(/Cannot find file .+ for inclusion/)
123
+ expect(linkify('include:file:notexist')).to eq ''
123
124
  end
124
125
  end
125
126
 
126
- describe '#format_types' do
127
- it "should return the list of types separated by commas surrounded by brackets" do
128
- format_types(['a', 'b', 'c']).should == '(a, b, c)'
127
+ describe "#format_types" do
128
+ it "returns the list of types separated by commas surrounded by brackets" do
129
+ expect(format_types(['a', 'b', 'c'])).to eq '(a, b, c)'
129
130
  end
130
131
 
131
- it "should return the list of types without brackets if brackets=false" do
132
- format_types(['a', 'b', 'c'], false).should == 'a, b, c'
132
+ it "returns the list of types without brackets if brackets=false" do
133
+ expect(format_types(['a', 'b', 'c'], false)).to eq 'a, b, c'
133
134
  end
134
135
 
135
- it "should should return an empty string if list is empty or nil" do
136
- format_types(nil).should == ""
137
- format_types([]).should == ""
136
+ it "returns an empty string if list is empty or nil" do
137
+ expect(format_types(nil)).to eq ""
138
+ expect(format_types([])).to eq ""
138
139
  end
139
140
  end
140
141
 
141
- describe '#format_object_type' do
142
- it "should return Exception if type is Exception" do
143
- obj = mock(:object)
144
- obj.stub!(:is_a?).with(YARD::CodeObjects::ClassObject).and_return(true)
145
- obj.stub!(:is_exception?).and_return(true)
146
- format_object_type(obj).should == "Exception"
142
+ describe "#format_object_type" do
143
+ it "returns Exception if type is Exception" do
144
+ obj = double(:object, :is_exception? => true)
145
+ allow(obj).to receive(:is_a?) { |arg| arg == YARD::CodeObjects::ClassObject }
146
+ expect(format_object_type(obj)).to eq "Exception"
147
147
  end
148
148
 
149
- it "should return Class if type is Class" do
150
- obj = mock(:object)
151
- obj.stub!(:is_a?).with(YARD::CodeObjects::ClassObject).and_return(true)
152
- obj.stub!(:is_exception?).and_return(false)
153
- format_object_type(obj).should == "Class"
149
+ it "returns Class if type is Class" do
150
+ obj = double(:object, :is_exception? => false)
151
+ allow(obj).to receive(:is_a?) { |arg| arg == YARD::CodeObjects::ClassObject }
152
+ expect(format_object_type(obj)).to eq "Class"
154
153
  end
155
154
 
156
- it "should return object type in other cases" do
157
- obj = mock(:object)
158
- obj.stub!(:type).and_return("value")
159
- format_object_type(obj).should == "Value"
155
+ it "returns object type in other cases" do
156
+ obj = double(:object, :type => "value")
157
+ expect(format_object_type(obj)).to eq "Value"
160
158
  end
161
159
  end
162
160
 
163
- describe '#format_object_title' do
164
- it "should return Top Level Namespace for root object" do
165
- format_object_title(Registry.root).should == "Top Level Namespace"
161
+ describe "#format_object_title" do
162
+ it "returns Top Level Namespace for root object" do
163
+ expect(format_object_title(Registry.root)).to eq "Top Level Namespace"
166
164
  end
167
165
 
168
- it "should return 'type: title' in other cases" do
169
- obj = mock(:object)
170
- obj.stub!(:type).and_return(:class)
171
- obj.stub!(:title).and_return("A::B::C")
172
- format_object_title(obj).should == "Class: A::B::C"
166
+ it "returns 'type: title' in other cases" do
167
+ obj = double(:object, :type => :class, :title => "A::B::C")
168
+ expect(format_object_title(obj)).to eq "Class: A::B::C"
173
169
  end
174
170
  end
175
171
  end
@@ -14,71 +14,71 @@ describe YARD::Templates::Helpers::HtmlHelper do
14
14
  end
15
15
  end
16
16
 
17
- describe '#h' do
18
- it "should use #h to escape HTML" do
19
- h('Usage: foo "bar" <baz>').should == "Usage: foo &quot;bar&quot; &lt;baz&gt;"
17
+ describe "#h" do
18
+ it "uses #h to escape HTML" do
19
+ expect(h('Usage: foo "bar" <baz>')).to eq "Usage: foo &quot;bar&quot; &lt;baz&gt;"
20
20
  end
21
21
  end
22
22
 
23
- describe '#charset' do
24
- it "should return foo if LANG=foo" do
25
- ENV.should_receive(:[]).with('LANG').and_return('shift_jis') if YARD.ruby18?
26
- Encoding.default_external.should_receive(:name).and_return('shift_jis') if defined?(Encoding)
27
- charset.should == 'shift_jis'
23
+ describe "#charset" do
24
+ it "returns foo if LANG=foo" do
25
+ expect(ENV).to receive(:[]).with('LANG').and_return('shift_jis') if YARD.ruby18?
26
+ expect(Encoding.default_external).to receive(:name).and_return('shift_jis') if defined?(Encoding)
27
+ expect(charset).to eq 'shift_jis'
28
28
  end
29
29
 
30
30
  ['US-ASCII', 'ASCII-7BIT', 'ASCII-8BIT'].each do |type|
31
- it "should convert #{type} to iso-8859-1" do
32
- ENV.should_receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
33
- Encoding.default_external.should_receive(:name).and_return(type) if defined?(Encoding)
34
- charset.should == 'iso-8859-1'
31
+ it "converts #{type} to iso-8859-1" do
32
+ expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
33
+ expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
34
+ expect(charset).to eq 'iso-8859-1'
35
35
  end
36
36
  end
37
37
 
38
- it "should support utf8 as an encoding value for utf-8" do
38
+ it "supports utf8 as an encoding value for utf-8" do
39
39
  type = 'utf8'
40
- ENV.should_receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
41
- Encoding.default_external.should_receive(:name).and_return(type) if defined?(Encoding)
42
- charset.should == 'utf-8'
40
+ expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
41
+ expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
42
+ expect(charset).to eq 'utf-8'
43
43
  end
44
44
 
45
- it "should take file encoding if there is a file" do
45
+ it "takes file encoding if there is a file" do
46
46
  @file = OpenStruct.new(:contents => 'foo'.force_encoding('sjis'))
47
47
  # not the correct charset name, but good enough
48
- ['Shift_JIS', 'Windows-31J'].should include(charset)
48
+ expect(['Shift_JIS', 'Windows-31J']).to include(charset)
49
49
  end if YARD.ruby19?
50
50
 
51
- it "should take file encoding if there is a file" do
52
- ENV.stub!(:[]).with('LANG').and_return('utf-8') if YARD.ruby18?
51
+ it "takes file encoding if there is a file" do
52
+ allow(ENV).to receive(:[]).with('LANG').and_return('utf-8') if YARD.ruby18?
53
53
  @file = OpenStruct.new(:contents => 'foo')
54
- charset.should == 'utf-8'
54
+ expect(charset).to eq 'utf-8'
55
55
  end if YARD.ruby18?
56
56
 
57
57
  if YARD.ruby18?
58
- it "should return utf-8 if no LANG env is set" do
59
- ENV.should_receive(:[]).with('LANG').and_return(nil)
60
- charset.should == 'utf-8'
58
+ it "returns utf-8 if no LANG env is set" do
59
+ expect(ENV).to receive(:[]).with('LANG').and_return(nil)
60
+ expect(charset).to eq 'utf-8'
61
61
  end
62
62
 
63
- it "should only return charset part of lang" do
64
- ENV.should_receive(:[]).with('LANG').and_return('en_US.UTF-8')
65
- charset.should == 'utf-8'
63
+ it "only returns charset part of lang" do
64
+ expect(ENV).to receive(:[]).with('LANG').and_return('en_US.UTF-8')
65
+ expect(charset).to eq 'utf-8'
66
66
  end
67
67
  end
68
68
  end
69
69
 
70
- describe '#format_types' do
71
- it "should include brackets by default" do
70
+ describe "#format_types" do
71
+ it "includes brackets by default" do
72
72
  text = ["String"]
73
- should_receive(:linkify).at_least(1).times.with("String", "String").and_return("String")
74
- format_types(text).should == format_types(text, true)
75
- format_types(text).should == "(<tt>String</tt>)"
73
+ expect(self).to receive(:linkify).at_least(1).times.with("String", "String").and_return("String")
74
+ expect(format_types(text)).to eq format_types(text, true)
75
+ expect(format_types(text)).to eq "(<tt>String</tt>)"
76
76
  end
77
77
 
78
- it "should avoid brackets if brackets=false" do
79
- should_receive(:linkify).with("String", "String").and_return("String")
80
- should_receive(:linkify).with("Symbol", "Symbol").and_return("Symbol")
81
- format_types(["String", "Symbol"], false).should == "<tt>String</tt>, <tt>Symbol</tt>"
78
+ it "avoids brackets if brackets=false" do
79
+ expect(self).to receive(:linkify).with("String", "String").and_return("String")
80
+ expect(self).to receive(:linkify).with("Symbol", "Symbol").and_return("Symbol")
81
+ expect(format_types(["String", "Symbol"], false)).to eq "<tt>String</tt>, <tt>Symbol</tt>"
82
82
  end
83
83
 
84
84
  { "String" => [["String"],
@@ -93,28 +93,32 @@ describe YARD::Templates::Helpers::HtmlHelper do
93
93
  "<tt><a href=''>Array</a>&lt;{<a href=''>String</a> =&gt; " +
94
94
  "<a href=''>Array</a>&lt;<a href=''>Symbol</a>&gt;}&gt;</tt>"]
95
95
  }.each do |text, values|
96
- it "should link all classes in #{text}" do
97
- should_receive(:h).with('<').at_least(text.count('<')).times.and_return("&lt;")
98
- should_receive(:h).with('>').at_least(text.count('>')).times.and_return("&gt;")
99
- values[0].each {|v| should_receive(:linkify).with(v, v).and_return("<a href=''>#{v}</a>") }
100
- format_types([text], false).should == values[1]
96
+ it "links all classes in #{text}" do
97
+ if text.count('<') > 0
98
+ expect(self).to receive(:h).with('<').at_least(text.count('<')).times.and_return("&lt;")
99
+ end
100
+ if text.count('>') > 0
101
+ expect(self).to receive(:h).with('>').at_least(text.count('>')).times.and_return("&gt;")
102
+ end
103
+ values[0].each {|v| expect(self).to receive(:linkify).with(v, v).and_return("<a href=''>#{v}</a>") }
104
+ expect(format_types([text], false)).to eq values[1]
101
105
  end
102
106
  end
103
107
  end
104
108
 
105
- describe '#htmlify' do
106
- it "should not use hard breaks for textile markup (RedCloth specific)" do
109
+ describe "#htmlify" do
110
+ it "does not use hard breaks for textile markup (RedCloth specific)" do
107
111
  begin; require 'redcloth'; rescue LoadError; pending 'test requires redcloth gem' end
108
- htmlify("A\nB", :textile).should_not include("<br")
112
+ expect(htmlify("A\nB", :textile)).not_to include("<br")
109
113
  end
110
114
 
111
- it "should use hard breaks for textile_strict markup (RedCloth specific)" do
115
+ it "uses hard breaks for textile_strict markup (RedCloth specific)" do
112
116
  begin; require 'redcloth'; rescue LoadError; pending 'test requires redcloth gem' end
113
- htmlify("A\nB", :textile_strict).should include("<br")
117
+ expect(htmlify("A\nB", :textile_strict)).to include("<br")
114
118
  end
115
119
 
116
- it "should handle various encodings" do
117
- stub!(:object).and_return(Registry.root)
120
+ it "handles various encodings" do
121
+ allow(self).to receive(:object).and_return(Registry.root)
118
122
  text = "\xB0\xB1"
119
123
  if defined?(Encoding)
120
124
  Encoding.default_internal = 'utf-8'
@@ -124,53 +128,53 @@ describe YARD::Templates::Helpers::HtmlHelper do
124
128
  # TODO: add more encoding tests
125
129
  end
126
130
 
127
- it "should return pre-formatted text with :pre markup" do
128
- htmlify("fo\no\n\nbar<>", :pre).should == "<pre>fo\no\n\nbar&lt;&gt;</pre>"
131
+ it "returns pre-formatted text with :pre markup" do
132
+ expect(htmlify("fo\no\n\nbar<>", :pre)).to eq "<pre>fo\no\n\nbar&lt;&gt;</pre>"
129
133
  end
130
134
 
131
- it "should return regular text with :text markup" do
132
- htmlify("fo\no\n\nbar<>", :text).should == "fo<br/>o<br/><br/>bar&lt;&gt;"
135
+ it "returns regular text with :text markup" do
136
+ expect(htmlify("fo\no\n\nbar<>", :text)).to eq "fo<br/>o<br/><br/>bar&lt;&gt;"
133
137
  end
134
138
 
135
- it "should return unmodified text with :none markup" do
136
- htmlify("fo\no\n\nbar<>", :none).should == "fo\no\n\nbar&lt;&gt;"
139
+ it "returns unmodified text with :none markup" do
140
+ expect(htmlify("fo\no\n\nbar<>", :none)).to eq "fo\no\n\nbar&lt;&gt;"
137
141
  end
138
142
 
139
- it "should highlight ruby if markup is :ruby" do
140
- htmlify("class Foo; end", :ruby).should =~ /\A<pre class="code ruby"><span/
143
+ it "highlights ruby if markup is :ruby" do
144
+ expect(htmlify("class Foo; end", :ruby)).to match /\A<pre class="code ruby"><span/
141
145
  end
142
146
 
143
- it "should include file and htmlify it" do
147
+ it "includes file and htmlifies it" do
144
148
  load_markup_provider(:rdoc)
145
- File.should_receive(:file?).with('foo.rdoc').and_return(true)
146
- File.should_receive(:read).with('foo.rdoc').and_return('HI')
147
- htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/\s+/, '').should == "<p><p>HI</p></p>"
149
+ expect(File).to receive(:file?).with('foo.rdoc').and_return(true)
150
+ expect(File).to receive(:read).with('foo.rdoc').and_return('HI')
151
+ expect(htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/\s+/, '')).to eq "<p><p>HI</p></p>"
148
152
  end
149
153
 
150
- it "should autolink URLs (markdown specific)" do
154
+ it "autolinks URLs (markdown specific)" do
151
155
  log.enter_level(Logger::FATAL) do
152
156
  unless markup_class(:markdown).to_s == "RedcarpetCompat"
153
157
  pending 'This test depends on a markdown engine that supports autolinking'
154
158
  end
155
159
  end
156
- htmlify('http://example.com', :markdown).chomp.gsub('&#47;', '/').should ==
157
- '<p><a href="http://example.com">http://example.com</a></p>'
160
+ expect(htmlify('http://example.com', :markdown).chomp.gsub('&#47;', '/')).to eq(
161
+ '<p><a href="http://example.com">http://example.com</a></p>')
158
162
  end
159
163
 
160
- it "should not autolink URLs inside of {} (markdown specific)" do
164
+ it "does not autolink URLs inside of {} (markdown specific)" do
161
165
  log.enter_level(Logger::FATAL) do
162
166
  pending 'This test depends on markdown' unless markup_class(:markdown)
163
167
  end
164
- htmlify('{http://example.com Title}', :markdown).chomp.should =~
165
- %r{<p><a href="http://example.com".*>Title</a></p>}
166
- htmlify('{http://example.com}', :markdown).chomp.should =~
167
- %r{<p><a href="http://example.com".*>http://example.com</a></p>}
168
+ expect(htmlify('{http://example.com Title}', :markdown).chomp).to match(
169
+ %r{<p><a href="http://example.com".*>Title</a></p>})
170
+ expect(htmlify('{http://example.com}', :markdown).chomp).to match(
171
+ %r{<p><a href="http://example.com".*>http://example.com</a></p>})
168
172
  end
169
173
 
170
- it "should create tables (markdown specific)" do
174
+ it "creates tables (markdown specific)" do
171
175
  log.enter_level(Logger::FATAL) do
172
176
  unless markup_class(:markdown).to_s == "RedcarpetCompat"
173
- pending 'This test depends on a markdown engine that supports tables'
177
+ skip "This test depends on a markdown engine that supports tables"
174
178
  end
175
179
  end
176
180
 
@@ -182,12 +186,12 @@ describe YARD::Templates::Helpers::HtmlHelper do
182
186
  EOF
183
187
 
184
188
  html = htmlify(markdown, :markdown)
185
- html.should =~ %r{<table>}
186
- html.should =~ %r{<th>City</th>}
187
- html.should =~ %r{<td>NC</td>}
189
+ expect(html).to match %r{<table>}
190
+ expect(html).to match %r{<th>City</th>}
191
+ expect(html).to match %r{<td>NC</td>}
188
192
  end
189
193
 
190
- it 'should handle fenced code blocks (Redcarpet specific)' do
194
+ it "handles fenced code blocks (Redcarpet specific)" do
191
195
  log.enter_level(Logger::FATAL) do
192
196
  unless markup_class(:markdown).to_s == 'RedcarpetCompat'
193
197
  pending 'This test is Redcarpet specific'
@@ -196,26 +200,24 @@ describe YARD::Templates::Helpers::HtmlHelper do
196
200
 
197
201
  markdown = "Introduction:\n```ruby\nputs\n\nputs\n```"
198
202
  html = htmlify(markdown, :markdown)
199
- html.should =~ %r{^<p>Introduction:</p>.*<code class="ruby">}m
203
+ expect(html).to match %r{^<p>Introduction:</p>.*<code class="ruby">}m
200
204
  end
201
205
  end
202
206
 
203
207
  describe "#link_object" do
204
- before do
205
- stub!(:object).and_return(CodeObjects::NamespaceObject.new(nil, :YARD))
206
- end
208
+ let(:object) { CodeObjects::NamespaceObject.new(nil, :YARD) }
207
209
 
208
- it "should return the object path if there's no serializer and no title" do
209
- stub!(:serializer).and_return nil
210
- link_object(CodeObjects::NamespaceObject.new(nil, :YARD)).should == "YARD"
210
+ it "returns the object path if there's no serializer and no title" do
211
+ allow(self).to receive(:serializer).and_return(nil)
212
+ expect(link_object(CodeObjects::NamespaceObject.new(nil, :YARD))).to eq "YARD"
211
213
  end
212
214
 
213
- it "should return the title if there's a title but no serializer" do
214
- stub!(:serializer).and_return nil
215
- link_object(CodeObjects::NamespaceObject.new(nil, :YARD), 'title').should == "title"
215
+ it "returns the title if there's a title but no serializer" do
216
+ allow(self).to receive(:serializer).and_return(nil)
217
+ expect(link_object(CodeObjects::NamespaceObject.new(nil, :YARD), 'title')).to eq "title"
216
218
  end
217
219
 
218
- it "should link objects from overload tag" do
220
+ it "links objects from overload tag" do
219
221
  YARD.parse_string <<-'eof'
220
222
  module Foo
221
223
  class Bar; def a; end end
@@ -228,50 +230,46 @@ describe YARD::Templates::Helpers::HtmlHelper do
228
230
  obj = Registry.at('Foo::Baz#a').tag(:overload)
229
231
  foobar = Registry.at('Foo::Bar')
230
232
  foobaz = Registry.at('Foo::Baz')
231
- serializer = Serializers::FileSystemSerializer.new
232
- stub!(:serializer).and_return(serializer)
233
- stub!(:object).and_return(obj)
234
- link_object("Bar#a").should =~ %r{href="Bar.html#a-instance_method"}
233
+ allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
234
+ allow(self).to receive(:object).and_return(obj)
235
+ expect(link_object("Bar#a")).to match %r{href="Bar.html#a-instance_method"}
235
236
  end
236
237
 
237
- it "should use relative path in title" do
238
+ it "uses relative path in title" do
238
239
  CodeObjects::ModuleObject.new(:root, :YARD)
239
240
  CodeObjects::ClassObject.new(P('YARD'), :Bar)
240
- stub!(:object).and_return(CodeObjects::ModuleObject.new(P('YARD'), :Foo))
241
- serializer = Serializers::FileSystemSerializer.new
242
- stub!(:serializer).and_return(serializer)
243
- link_object("Bar").should =~ %r{>Bar</a>}
241
+ allow(self).to receive(:object).and_return(CodeObjects::ModuleObject.new(P('YARD'), :Foo))
242
+ allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
243
+ expect(link_object("Bar")).to match %r{>Bar</a>}
244
244
  end
245
245
 
246
- it "should use #title if overridden" do
246
+ it "uses #title if overridden" do
247
247
  CodeObjects::ModuleObject.new(:root, :YARD)
248
248
  CodeObjects::ClassObject.new(P('YARD'), :Bar)
249
- Registry.at('YARD::Bar').stub(:title).and_return('TITLE!')
250
- stub!(:object).and_return(Registry.at('YARD::Bar'))
249
+ allow(Registry.at('YARD::Bar')).to receive(:title).and_return('TITLE!')
250
+ allow(self).to receive(:object).and_return(Registry.at('YARD::Bar'))
251
251
  serializer = Serializers::FileSystemSerializer.new
252
- stub!(:serializer).and_return(serializer)
253
- link_object("Bar").should =~ %r{>TITLE!</a>}
252
+ allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
253
+ expect(link_object("Bar")).to match %r{>TITLE!</a>}
254
254
  end
255
255
 
256
- it "should use relative path to parent class in title" do
256
+ it "uses relative path to parent class in title" do
257
257
  root = CodeObjects::ModuleObject.new(:root, :YARD)
258
258
  obj = CodeObjects::ModuleObject.new(root, :SubModule)
259
- stub!(:object).and_return(obj)
260
- serializer = Serializers::FileSystemSerializer.new
261
- stub!(:serializer).and_return(serializer)
262
- link_object("YARD").should =~ %r{>YARD</a>}
259
+ allow(self).to receive(:object).and_return(obj)
260
+ allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
261
+ expect(link_object("YARD")).to match %r{>YARD</a>}
263
262
  end
264
263
 
265
- it "should use Klass.foo when linking to class method in current namespace" do
264
+ it "uses Klass.foo when linking to class method in current namespace" do
266
265
  root = CodeObjects::ModuleObject.new(:root, :Klass)
267
266
  obj = CodeObjects::MethodObject.new(root, :foo, :class)
268
- stub!(:object).and_return(root)
269
- serializer = Serializers::FileSystemSerializer.new
270
- stub!(:serializer).and_return(serializer)
271
- link_object("foo").should =~ %r{>Klass.foo</a>}
267
+ allow(self).to receive(:object).and_return(root)
268
+ allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
269
+ expect(link_object("foo")).to match %r{>Klass.foo</a>}
272
270
  end
273
271
 
274
- it "should escape method name in title" do
272
+ it "escapes method name in title" do
275
273
  YARD.parse_string <<-'eof'
276
274
  class Array
277
275
  def &(other)
@@ -279,73 +277,71 @@ describe YARD::Templates::Helpers::HtmlHelper do
279
277
  end
280
278
  eof
281
279
  obj = Registry.at('Array#&')
282
- serializer = Serializers::FileSystemSerializer.new
283
- stub!(:serializer).and_return(serializer)
284
- stub!(:object).and_return(obj)
285
- link_object("Array#&").should =~ %r{title="Array#&amp; \(method\)"}
280
+ allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
281
+ allow(self).to receive(:object).and_return(obj)
282
+ expect(link_object("Array#&")).to match %r{title="Array#&amp; \(method\)"}
286
283
  end
287
284
  end
288
285
 
289
- describe '#url_for' do
286
+ describe "#url_for" do
290
287
  before { Registry.clear }
291
288
 
292
- it "should return nil if serializer is nil" do
293
- stub!(:serializer).and_return nil
294
- stub!(:object).and_return Registry.root
295
- url_for(P("Mod::Class#meth")).should be_nil
289
+ it "returns nil if serializer is nil" do
290
+ allow(self).to receive(:serializer).and_return nil
291
+ allow(self).to receive(:object).and_return Registry.root
292
+ expect(url_for(P("Mod::Class#meth"))).to be nil
296
293
  end
297
294
 
298
- it "should return nil if object is hidden" do
295
+ it "returns nil if object is hidden" do
299
296
  yard = CodeObjects::ModuleObject.new(:root, :YARD)
300
297
 
301
- stub!(:serializer).and_return Serializers::FileSystemSerializer.new
302
- stub!(:object).and_return Registry.root
303
- stub!(:options).and_return OpenStruct.new(:verifier => Verifier.new('false'))
298
+ allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
299
+ allow(self).to receive(:object).and_return Registry.root
300
+ allow(self).to receive(:options).and_return OpenStruct.new(:verifier => Verifier.new('false'))
304
301
 
305
- url_for(yard).should be_nil
302
+ expect(url_for(yard)).to be nil
306
303
  end
307
304
 
308
- it "should return nil if serializer does not implement #serialized_path" do
309
- stub!(:serializer).and_return Serializers::Base.new
310
- stub!(:object).and_return Registry.root
311
- url_for(P("Mod::Class#meth")).should be_nil
305
+ it "returns nil if serializer does not implement #serialized_path" do
306
+ allow(self).to receive(:serializer).and_return Serializers::Base.new
307
+ allow(self).to receive(:object).and_return Registry.root
308
+ expect(url_for(P("Mod::Class#meth"))).to be nil
312
309
  end
313
310
 
314
- it "should link to a path/file for a namespace object" do
315
- stub!(:serializer).and_return Serializers::FileSystemSerializer.new
316
- stub!(:object).and_return Registry.root
311
+ it "links to a path/file for a namespace object" do
312
+ allow(self).to receive(:serializer).and_return Serializers::FileSystemSerializer.new
313
+ allow(self).to receive(:object).and_return Registry.root
317
314
 
318
315
  yard = CodeObjects::ModuleObject.new(:root, :YARD)
319
- url_for(yard).should == 'YARD.html'
316
+ expect(url_for(yard)).to eq 'YARD.html'
320
317
  end
321
318
 
322
- it "should link to the object's namespace path/file and use the object as the anchor" do
323
- stub!(:serializer).and_return Serializers::FileSystemSerializer.new
324
- stub!(:object).and_return Registry.root
319
+ it "links to the object's namespace path/file and use the object as the anchor" do
320
+ allow(self).to receive(:serializer).and_return Serializers::FileSystemSerializer.new
321
+ allow(self).to receive(:object).and_return Registry.root
325
322
 
326
323
  yard = CodeObjects::ModuleObject.new(:root, :YARD)
327
324
  meth = CodeObjects::MethodObject.new(yard, :meth)
328
- url_for(meth).should == 'YARD.html#meth-instance_method'
325
+ expect(url_for(meth)).to eq 'YARD.html#meth-instance_method'
329
326
  end
330
327
 
331
- it "should properly urlencode methods with punctuation in links" do
328
+ it "properly urlencodes methods with punctuation in links" do
332
329
  obj = CodeObjects::MethodObject.new(nil, :/)
333
- serializer = mock(:serializer)
334
- serializer.stub!(:serialized_path).and_return("file.html")
335
- stub!(:serializer).and_return(serializer)
336
- stub!(:object).and_return(obj)
337
- url_for(obj).should == "#%2F-instance_method"
330
+ serializer = double(:serializer, :serialized_path => "file.html")
331
+ allow(self).to receive(:serializer).and_return serializer
332
+ allow(self).to receive(:object).and_return obj
333
+ expect(url_for(obj)).to eq "#%2F-instance_method"
338
334
  end
339
335
  end
340
336
 
341
- describe '#anchor_for' do
342
- it "should not urlencode data when called directly" do
337
+ describe "#anchor_for" do
338
+ it "does not urlencode data when called directly" do
343
339
  obj = CodeObjects::MethodObject.new(nil, :/)
344
- anchor_for(obj).should == "/-instance_method"
340
+ expect(anchor_for(obj)).to eq "/-instance_method"
345
341
  end
346
342
  end
347
343
 
348
- describe '#resolve_links' do
344
+ describe "#resolve_links" do
349
345
  def parse_link(link)
350
346
  results = {}
351
347
  link =~ /<a (.+?)>(.+?)<\/a>/m
@@ -356,119 +352,119 @@ describe YARD::Templates::Helpers::HtmlHelper do
356
352
  results
357
353
  end
358
354
 
359
- it "should escape {} syntax with backslash (\\{foo bar})" do
355
+ it "escapes {} syntax with backslash (\\{foo bar})" do
360
356
  input = '\{foo bar} \{XYZ} \{file:FOO} $\{N-M}'
361
357
  output = '{foo bar} {XYZ} {file:FOO} ${N-M}'
362
- resolve_links(input).should == output
358
+ expect(resolve_links(input)).to eq output
363
359
  end
364
360
 
365
- it "should escape {} syntax with ! (!{foo bar})" do
361
+ it "escapes {} syntax with ! (!{foo bar})" do
366
362
  input = '!{foo bar} !{XYZ} !{file:FOO} $!{N-M}'
367
363
  output = '{foo bar} {XYZ} {file:FOO} ${N-M}'
368
- resolve_links(input).should == output
364
+ expect(resolve_links(input)).to eq output
369
365
  end
370
366
 
371
- it "should link static files with file: prefix" do
372
- stub!(:serializer).and_return Serializers::FileSystemSerializer.new
373
- stub!(:object).and_return Registry.root
367
+ it "links static files with file: prefix" do
368
+ allow(self).to receive(:serializer).and_return Serializers::FileSystemSerializer.new
369
+ allow(self).to receive(:object).and_return Registry.root
374
370
 
375
- parse_link(resolve_links("{file:TEST.txt#abc}")).should == {
371
+ expect(parse_link(resolve_links("{file:TEST.txt#abc}"))).to eq({
376
372
  :inner_text => "TEST",
377
373
  :title => "TEST",
378
374
  :href => "file.TEST.html#abc"
379
- }
380
- parse_link(resolve_links("{file:TEST.txt title}")).should == {
375
+ })
376
+ expect(parse_link(resolve_links("{file:TEST.txt title}"))).to eq({
381
377
  :inner_text => "title",
382
378
  :title => "title",
383
379
  :href => "file.TEST.html"
384
- }
380
+ })
385
381
  end
386
382
 
387
- it "should create regular links with http:// or https:// prefixes" do
388
- parse_link(resolve_links("{http://example.com}")).should == {
383
+ it "creates regular links with http:// or https:// prefixes" do
384
+ expect(parse_link(resolve_links("{http://example.com}"))).to eq({
389
385
  :inner_text => "http://example.com",
390
386
  :target => "_parent",
391
387
  :href => "http://example.com",
392
388
  :title => "http://example.com"
393
- }
394
- parse_link(resolve_links("{http://example.com title}")).should == {
389
+ })
390
+ expect(parse_link(resolve_links("{http://example.com title}"))).to eq({
395
391
  :inner_text => "title",
396
392
  :target => "_parent",
397
393
  :href => "http://example.com",
398
394
  :title => "title"
399
- }
395
+ })
400
396
  end
401
397
 
402
- it "should create mailto links with mailto: prefixes" do
403
- parse_link(resolve_links('{mailto:joanna@example.com}')).should == {
398
+ it "creates mailto links with mailto: prefixes" do
399
+ expect(parse_link(resolve_links('{mailto:joanna@example.com}'))).to eq({
404
400
  :inner_text => 'mailto:joanna@example.com',
405
401
  :target => '_parent',
406
402
  :href => 'mailto:joanna@example.com',
407
403
  :title => 'mailto:joanna@example.com'
408
- }
409
- parse_link(resolve_links('{mailto:steve@example.com Steve}')).should == {
404
+ })
405
+ expect(parse_link(resolve_links('{mailto:steve@example.com Steve}'))).to eq({
410
406
  :inner_text => 'Steve',
411
407
  :target => '_parent',
412
408
  :href => 'mailto:steve@example.com',
413
409
  :title => 'Steve'
414
- }
410
+ })
415
411
  end
416
412
 
417
- it "should ignore {links} that begin with |...|" do
418
- resolve_links("{|x|x == 1}").should == "{|x|x == 1}"
413
+ it "ignores {links} that begin with |...|" do
414
+ expect(resolve_links("{|x|x == 1}")).to eq "{|x|x == 1}"
419
415
  end
420
416
 
421
- it "should gracefully ignore {} in links" do
422
- should_receive(:linkify).with('Foo', 'Foo').and_return('FOO')
423
- resolve_links("{} {} {Foo Foo}").should == '{} {} FOO'
417
+ it "gracefully ignores {} in links" do
418
+ allow(self).to receive(:linkify).with('Foo', 'Foo').and_return('FOO')
419
+ expect(resolve_links("{} {} {Foo Foo}")).to eq '{} {} FOO'
424
420
  end
425
421
 
426
422
  %w(tt code pre).each do |tag|
427
- it "should ignore links in <#{tag}>" do
423
+ it "ignores links in <#{tag}>" do
428
424
  text = "<#{tag}>{Foo}</#{tag}>"
429
- resolve_links(text).should == text
425
+ expect(resolve_links(text)).to eq text
430
426
  end
431
427
  end
432
428
 
433
- it "should resolve {Name}" do
434
- should_receive(:link_file).with('TEST', nil, nil).and_return('')
429
+ it "resolves {Name}" do
430
+ expect(self).to receive(:link_file).with('TEST', nil, nil).and_return('')
435
431
  resolve_links("{file:TEST}")
436
432
  end
437
433
 
438
- it "should resolve ({Name})" do
439
- should_receive(:link_file).with('TEST', nil, nil).and_return('')
434
+ it "resolves ({Name})" do
435
+ expect(self).to receive(:link_file).with('TEST', nil, nil).and_return('')
440
436
  resolve_links("({file:TEST})")
441
437
  end
442
438
 
443
- it "should resolve link with newline in title-part" do
444
- parse_link(resolve_links("{http://example.com foo\nbar}")).should == {
439
+ it "resolves link with newline in title-part" do
440
+ expect(parse_link(resolve_links("{http://example.com foo\nbar}"))).to eq({
445
441
  :inner_text => "foo bar",
446
442
  :target => "_parent",
447
443
  :href => "http://example.com",
448
444
  :title => "foo bar"
449
- }
445
+ })
450
446
  end
451
447
 
452
- it "should resolve links to methods whose names have been escaped" do
453
- should_receive(:linkify).with('Object#<<', nil).and_return('')
448
+ it "resolves links to methods whose names have been escaped" do
449
+ expect(self).to receive(:linkify).with('Object#<<', nil).and_return('')
454
450
  resolve_links("{Object#&lt;&lt;}")
455
451
  end
456
452
 
457
- it "should warn about missing reference at right file location for object" do
453
+ it "warns about missing reference at right file location for object" do
458
454
  YARD.parse_string <<-eof
459
455
  # Comments here
460
456
  # And a reference to {InvalidObject}
461
457
  class MyObject; end
462
458
  eof
463
- logger = mock(:log)
464
- logger.should_receive(:warn).ordered.with("In file `(stdin)':2: Cannot resolve link to InvalidObject from text:")
465
- logger.should_receive(:warn).ordered.with("...{InvalidObject}")
466
- stub!(:log).and_return(logger)
467
- stub!(:object).and_return(Registry.at('MyObject'))
459
+ logger = double(:log)
460
+ expect(logger).to receive(:warn).ordered.with("In file `(stdin)':2: Cannot resolve link to InvalidObject from text:")
461
+ expect(logger).to receive(:warn).ordered.with("...{InvalidObject}")
462
+ allow(self).to receive(:log).and_return(logger)
463
+ allow(self).to receive(:object).and_return(Registry.at('MyObject'))
468
464
  resolve_links(object.docstring)
469
465
  end
470
466
 
471
- it "should show ellipsis on either side if there is more on the line in a reference warning" do
467
+ it "shows ellipsis on either side if there is more on the line in a reference warning" do
472
468
  YARD.parse_string <<-eof
473
469
  # {InvalidObject1} beginning of line
474
470
  # end of line {InvalidObject2}
@@ -476,27 +472,27 @@ describe YARD::Templates::Helpers::HtmlHelper do
476
472
  # {InvalidObject4}
477
473
  class MyObject; end
478
474
  eof
479
- logger = mock(:log)
480
- logger.should_receive(:warn).ordered.with("In file `(stdin)':1: Cannot resolve link to InvalidObject1 from text:")
481
- logger.should_receive(:warn).ordered.with("{InvalidObject1}...")
482
- logger.should_receive(:warn).ordered.with("In file `(stdin)':2: Cannot resolve link to InvalidObject2 from text:")
483
- logger.should_receive(:warn).ordered.with("...{InvalidObject2}")
484
- logger.should_receive(:warn).ordered.with("In file `(stdin)':3: Cannot resolve link to InvalidObject3 from text:")
485
- logger.should_receive(:warn).ordered.with("...{InvalidObject3}...")
486
- logger.should_receive(:warn).ordered.with("In file `(stdin)':4: Cannot resolve link to InvalidObject4 from text:")
487
- logger.should_receive(:warn).ordered.with("{InvalidObject4}")
488
- stub!(:log).and_return(logger)
489
- stub!(:object).and_return(Registry.at('MyObject'))
475
+ logger = double(:log)
476
+ expect(logger).to receive(:warn).ordered.with("In file `(stdin)':1: Cannot resolve link to InvalidObject1 from text:")
477
+ expect(logger).to receive(:warn).ordered.with("{InvalidObject1}...")
478
+ expect(logger).to receive(:warn).ordered.with("In file `(stdin)':2: Cannot resolve link to InvalidObject2 from text:")
479
+ expect(logger).to receive(:warn).ordered.with("...{InvalidObject2}")
480
+ expect(logger).to receive(:warn).ordered.with("In file `(stdin)':3: Cannot resolve link to InvalidObject3 from text:")
481
+ expect(logger).to receive(:warn).ordered.with("...{InvalidObject3}...")
482
+ expect(logger).to receive(:warn).ordered.with("In file `(stdin)':4: Cannot resolve link to InvalidObject4 from text:")
483
+ expect(logger).to receive(:warn).ordered.with("{InvalidObject4}")
484
+ allow(self).to receive(:log).and_return(logger)
485
+ allow(self).to receive(:object).and_return(Registry.at('MyObject'))
490
486
  resolve_links(object.docstring)
491
487
  end
492
488
 
493
- it "should warn about missing reference for file template (no object)" do
489
+ it "warns about missing reference for file template (no object)" do
494
490
  @file = CodeObjects::ExtraFileObject.new('myfile.txt', '')
495
- logger = mock(:log)
496
- logger.should_receive(:warn).ordered.with("In file `myfile.txt':3: Cannot resolve link to InvalidObject from text:")
497
- logger.should_receive(:warn).ordered.with("...{InvalidObject Some Title}")
498
- stub!(:log).and_return(logger)
499
- stub!(:object).and_return(Registry.root)
491
+ logger = double(:log)
492
+ expect(logger).to receive(:warn).ordered.with("In file `myfile.txt':3: Cannot resolve link to InvalidObject from text:")
493
+ expect(logger).to receive(:warn).ordered.with("...{InvalidObject Some Title}")
494
+ allow(self).to receive(:log).and_return(logger)
495
+ allow(self).to receive(:object).and_return(Registry.root)
500
496
  resolve_links(<<-eof)
501
497
  Hello world
502
498
  This is a line
@@ -506,23 +502,24 @@ describe YARD::Templates::Helpers::HtmlHelper do
506
502
  end
507
503
  end
508
504
 
509
- describe '#signature' do
505
+ describe "#signature" do
510
506
  before do
507
+ arrow = "&#x21d2;"
511
508
  @results = {
512
- :regular => "- (Object) <strong>foo</strong>",
513
- :default_return => "- (Hello) <strong>foo</strong>",
514
- :no_default_return => "- <strong>foo</strong>",
515
- :private_class => "+ (Object) <strong>foo</strong> <span class=\"extras\">(private)</span>",
516
- :single => "- (String) <strong>foo</strong>",
517
- :two_types => "- (String, Symbol) <strong>foo</strong>",
518
- :two_types_multitag => "- (String, Symbol) <strong>foo</strong>",
519
- :type_nil => "- (Type<sup>?</sup>) <strong>foo</strong>",
520
- :type_array => "- (Type<sup>+</sup>) <strong>foo</strong>",
521
- :multitype => "- (Type, ...) <strong>foo</strong>",
522
- :void => "- (void) <strong>foo</strong>",
523
- :hide_void => "- <strong>foo</strong>",
524
- :block => "- (Object) <strong>foo</strong> {|a, b, c| ... }",
525
- :empty_overload => '- (String) <strong>foobar</strong>'
509
+ :regular => "#<strong>foo</strong> #{arrow} Object",
510
+ :default_return => "#<strong>foo</strong> #{arrow} Hello",
511
+ :no_default_return => "#<strong>foo</strong>",
512
+ :private_class => ".<strong>foo</strong> #{arrow} Object <span class=\"extras\">(private)</span>",
513
+ :single => "#<strong>foo</strong> #{arrow} String",
514
+ :two_types => "#<strong>foo</strong> #{arrow} String, Symbol",
515
+ :two_types_multitag => "#<strong>foo</strong> #{arrow} String, Symbol",
516
+ :type_nil => "#<strong>foo</strong> #{arrow} Type<sup>?</sup>",
517
+ :type_array => "#<strong>foo</strong> #{arrow} Type<sup>+</sup>",
518
+ :multitype => "#<strong>foo</strong> #{arrow} Type, ...",
519
+ :void => "#<strong>foo</strong> #{arrow} void",
520
+ :hide_void => "#<strong>foo</strong>",
521
+ :block => "#<strong>foo</strong> {|a, b, c| ... } #{arrow} Object",
522
+ :empty_overload => "#<strong>foobar</strong> #{arrow} String"
526
523
  }
527
524
  end
528
525
 
@@ -531,23 +528,23 @@ describe YARD::Templates::Helpers::HtmlHelper do
531
528
 
532
529
  it_should_behave_like "signature"
533
530
 
534
- it "should link to regular method if overload name does not have the same method name" do
531
+ it "links to regular method if overload name does not have the same method name" do
535
532
  YARD.parse_string <<-eof
536
533
  class Foo
537
534
  # @overload bar(a, b, c)
538
535
  def foo; end
539
536
  end
540
537
  eof
541
- serializer = mock(:serializer)
542
- serializer.stub!(:serialized_path).with(Registry.at('Foo')).and_return('')
543
- stub!(:serializer).and_return(serializer)
544
- stub!(:object).and_return(Registry.at('Foo'))
545
- signature(Registry.at('Foo#foo').tag(:overload), true).should ==
546
- "<a href=\"#foo-instance_method\" title=\"#bar (instance method)\">- <strong>bar</strong>(a, b, c) </a>"
538
+ serializer = double(:serializer)
539
+ allow(serializer).to receive(:serialized_path).with(Registry.at('Foo')).and_return('')
540
+ allow(self).to receive(:serializer).and_return(serializer)
541
+ allow(self).to receive(:object).and_return(Registry.at('Foo'))
542
+ expect(signature(Registry.at('Foo#foo').tag(:overload), true)).to eq(
543
+ "<a href=\"#foo-instance_method\" title=\"#bar (instance method)\">#<strong>bar</strong>(a, b, c) </a>")
547
544
  end
548
545
  end
549
546
 
550
- describe '#html_syntax_highlight' do
547
+ describe "#html_syntax_highlight" do
551
548
  subject do
552
549
  obj = OpenStruct.new
553
550
  obj.options = options
@@ -556,89 +553,89 @@ describe YARD::Templates::Helpers::HtmlHelper do
556
553
  obj
557
554
  end
558
555
 
559
- it "should return empty string on nil input" do
560
- subject.html_syntax_highlight(nil).should == ''
556
+ it "returns empty string on nil input" do
557
+ expect(subject.html_syntax_highlight(nil)).to eq ''
561
558
  end
562
559
 
563
- it "should call #html_syntax_highlight_ruby by default" do
560
+ it "calls #html_syntax_highlight_ruby by default" do
564
561
  Registry.root.source_type = nil
565
- subject.should_receive(:html_syntax_highlight_ruby).with('def x; end')
562
+ expect(subject).to receive(:html_syntax_highlight_ruby).with('def x; end')
566
563
  subject.html_syntax_highlight('def x; end')
567
564
  end
568
565
 
569
- it "should call #html_syntax_highlight_NAME if there's an object with a #source_type" do
566
+ it "calls #html_syntax_highlight_NAME if there's an object with a #source_type" do
570
567
  subject.object = OpenStruct.new(:source_type => :NAME)
571
- subject.should_receive(:respond_to?).with('html_markup_html').and_return(true)
572
- subject.should_receive(:respond_to?).with('html_syntax_highlight_NAME').and_return(true)
573
- subject.should_receive(:html_syntax_highlight_NAME).and_return("foobar")
574
- subject.htmlify('<pre><code>def x; end</code></pre>', :html).should ==
575
- '<pre class="code NAME"><code class="NAME">foobar</code></pre>'
568
+ expect(subject).to receive(:html_markup_html) { |text| text }
569
+ expect(subject).to receive(:html_syntax_highlight_NAME).and_return("foobar")
570
+ expect(subject.htmlify('<pre><code>def x; end</code></pre>', :html)).to eq(
571
+ '<pre class="code NAME"><code class="NAME">foobar</code></pre>')
576
572
  end
577
573
 
578
- it "should add !!!LANG to className in outputted pre tag" do
574
+ it "adds !!!LANG to className in outputted pre tag" do
579
575
  subject.object = OpenStruct.new(:source_type => :LANG)
580
- subject.should_receive(:respond_to?).with('html_markup_html').and_return(true)
581
- subject.should_receive(:respond_to?).with('html_syntax_highlight_LANG').and_return(true)
582
- subject.should_receive(:html_syntax_highlight_LANG).and_return("foobar")
583
- subject.htmlify("<pre><code>!!!LANG\ndef x; end</code></pre>", :html).should ==
584
- '<pre class="code LANG"><code class="LANG">foobar</code></pre>'
576
+ expect(subject).to receive(:html_markup_html) { |text| text }
577
+ expect(subject).to receive(:html_syntax_highlight_LANG).and_return("foobar")
578
+ expect(subject.htmlify("<pre><code>!!!LANG\ndef x; end</code></pre>", :html)).to eq(
579
+ '<pre class="code LANG"><code class="LANG">foobar</code></pre>')
585
580
  end
586
581
 
587
- it "should call html_syntax_highlight_NAME if source starts with !!!NAME" do
588
- subject.should_receive(:respond_to?).with('html_syntax_highlight_NAME').and_return(true)
589
- subject.should_receive(:html_syntax_highlight_NAME).and_return("foobar")
590
- subject.html_syntax_highlight(<<-eof
582
+ it "calls html_syntax_highlight_NAME if source starts with !!!NAME" do
583
+ expect(subject).to receive(:html_syntax_highlight_NAME).and_return("foobar")
584
+ expect(subject.html_syntax_highlight(<<-eof
591
585
  !!!NAME
592
586
  def x; end
593
587
  eof
594
- ).should == "foobar"
588
+ )).to eq "foobar"
595
589
  end
596
590
 
597
- it "should not highlight if highlight option is false" do
591
+ it "does not highlight if highlight option is false" do
598
592
  subject.options.highlight = false
599
- subject.should_not_receive(:html_syntax_highlight_ruby)
600
- subject.html_syntax_highlight('def x; end').should == 'def x; end'
593
+ expect(subject).not_to receive(:html_syntax_highlight_ruby)
594
+ expect(subject.html_syntax_highlight('def x; end')).to eq 'def x; end'
601
595
  end
602
596
 
603
- it "should not highlight if there is no highlight method specified by !!!NAME" do
604
- subject.should_receive(:respond_to?).with('html_syntax_highlight_NAME').and_return(false)
605
- subject.should_not_receive(:html_syntax_highlight_NAME)
606
- subject.html_syntax_highlight("!!!NAME\ndef x; end").should == "def x; end"
597
+ it "does not highlight if there is no highlight method specified by !!!NAME" do
598
+ def subject.respond_to?(method, include_all=false)
599
+ return false if method == 'html_syntax_highlight_NAME'
600
+ super
601
+ end
602
+ expect(subject).not_to receive(:html_syntax_highlight_NAME)
603
+ expect(subject.html_syntax_highlight("!!!NAME\ndef x; end")).to eq "def x; end"
607
604
  end
608
605
 
609
- it "should highlight as ruby if htmlify(text, :ruby) is called" do
610
- subject.should_receive(:html_syntax_highlight_ruby).with('def x; end').and_return('x')
611
- subject.htmlify('def x; end', :ruby).should == '<pre class="code ruby">x</pre>'
606
+ it "highlights as ruby if htmlify(text, :ruby) is called" do
607
+ expect(subject).to receive(:html_syntax_highlight_ruby).with('def x; end').and_return('x')
608
+ expect(subject.htmlify('def x; end', :ruby)).to eq '<pre class="code ruby">x</pre>'
612
609
  end
613
610
 
614
- it "should not prioritize object source type when called directly" do
615
- subject.should_receive(:html_syntax_highlight_ruby).with('def x; end').and_return('x')
611
+ it "does not prioritize object source type when called directly" do
612
+ expect(subject).to receive(:html_syntax_highlight_ruby).with('def x; end').and_return('x')
616
613
  subject.object = OpenStruct.new(:source_type => :c)
617
- subject.html_syntax_highlight("def x; end").should == "x"
614
+ expect(subject.html_syntax_highlight("def x; end")).to eq "x"
618
615
  end
619
616
 
620
- it "shouldn't escape code snippets twice" do
621
- subject.htmlify('<pre lang="foo"><code>{"foo" => 1}</code></pre>', :html).should ==
622
- '<pre class="code foo"><code class="foo">{&quot;foo&quot; =&gt; 1}</code></pre>'
617
+ it "doesn't escape code snippets twice" do
618
+ expect(subject.htmlify('<pre lang="foo"><code>{"foo" => 1}</code></pre>', :html)).to eq(
619
+ '<pre class="code foo"><code class="foo">{&quot;foo&quot; =&gt; 1}</code></pre>')
623
620
  end
624
621
 
625
- it "should highlight source when matching a pre lang= tag" do
626
- subject.htmlify('<pre lang="foo"><code>x = 1</code></pre>', :html).should ==
627
- '<pre class="code foo"><code class="foo">x = 1</code></pre>'
622
+ it "highlights source when matching a pre lang= tag" do
623
+ expect(subject.htmlify('<pre lang="foo"><code>x = 1</code></pre>', :html)).to eq(
624
+ '<pre class="code foo"><code class="foo">x = 1</code></pre>')
628
625
  end
629
626
 
630
- it "should highlight source when matching a code class= tag" do
631
- subject.htmlify('<pre><code class="foo">x = 1</code></pre>', :html).should ==
632
- '<pre class="code foo"><code class="foo">x = 1</code></pre>'
627
+ it "highlights source when matching a code class= tag" do
628
+ expect(subject.htmlify('<pre><code class="foo">x = 1</code></pre>', :html)).to eq(
629
+ '<pre class="code foo"><code class="foo">x = 1</code></pre>')
633
630
  end
634
631
  end
635
632
 
636
- describe '#link_url' do
637
- it "should add target if scheme is provided" do
638
- link_url("http://url.com").should include(" target=\"_parent\"")
639
- link_url("https://url.com").should include(" target=\"_parent\"")
640
- link_url("irc://url.com").should include(" target=\"_parent\"")
641
- link_url("../not/scheme").should_not include("target")
633
+ describe "#link_url" do
634
+ it "adds target if scheme is provided" do
635
+ expect(link_url("http://url.com")).to include(" target=\"_parent\"")
636
+ expect(link_url("https://url.com")).to include(" target=\"_parent\"")
637
+ expect(link_url("irc://url.com")).to include(" target=\"_parent\"")
638
+ expect(link_url("../not/scheme")).not_to include("target")
642
639
  end
643
640
  end
644
641
  end