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
@@ -4,21 +4,22 @@ describe YARD::Templates::Helpers::HtmlSyntaxHighlightHelper do
4
4
  include YARD::Templates::Helpers::HtmlHelper
5
5
  include YARD::Templates::Helpers::HtmlSyntaxHighlightHelper
6
6
 
7
- describe '#html_syntax_highlight' do
7
+ describe "#html_syntax_highlight" do
8
+ let(:object) { Registry.root }
9
+
8
10
  before do
9
- stub!(:object).and_return Registry.root
10
11
  Registry.root.source_type = :ruby
11
12
  end
12
13
 
13
- it "should not highlight source if options.highlight is false" do
14
- should_receive(:options).and_return(Options.new.update(:highlight => false))
15
- html_syntax_highlight("def x\nend").should == "def x\nend"
14
+ it "does not highlight source if options.highlight is false" do
15
+ expect(self).to receive(:options).and_return(Options.new.update(:highlight => false))
16
+ expect(html_syntax_highlight("def x\nend")).to eq "def x\nend"
16
17
  end
17
18
 
18
- it "should highlight source (legacy)" do
19
+ it "highlights source (legacy)" do
19
20
  type = Parser::SourceParser.parser_type
20
21
  Parser::SourceParser.parser_type = :ruby18
21
- should_receive(:options).and_return(Options.new.update(:highlight => true))
22
+ expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
22
23
  expect = "<span class='rubyid_def def kw'>def</span><span class='rubyid_x identifier id'>x</span>
23
24
  <span class='string val'>'x'</span><span class='plus op'>+</span>
24
25
  <span class='regexp val'>/x/i</span><span class='rubyid_end end kw'>end</span>"
@@ -27,8 +28,8 @@ describe YARD::Templates::Helpers::HtmlSyntaxHighlightHelper do
27
28
  Parser::SourceParser.parser_type = type
28
29
  end
29
30
 
30
- it "should highlight source (ripper)" do
31
- should_receive(:options).and_return(Options.new.update(:highlight => true))
31
+ it "highlights source (ripper)" do
32
+ expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
32
33
  Parser::SourceParser.parser_type = :ruby
33
34
  expect = "<span class='kw'>def</span> <span class='id identifier rubyid_x'>x</span>
34
35
  <span class='tstring'><span class='tstring_beg'>'</span>
@@ -40,14 +41,14 @@ describe YARD::Templates::Helpers::HtmlSyntaxHighlightHelper do
40
41
  html_equals_string(result, expect)
41
42
  end if HAVE_RIPPER
42
43
 
43
- it "should return escaped unhighlighted source if a syntax error is found (ripper)" do
44
- should_receive(:options).and_return(Options.new.update(:highlight => true))
45
- html_syntax_highlight("def &x; ... end").should == "def &amp;x; ... end"
44
+ it "returns escaped unhighlighted source if a syntax error is found (ripper)" do
45
+ expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
46
+ expect(html_syntax_highlight("def &x; ... end")).to eq "def &amp;x; ... end"
46
47
  end if HAVE_RIPPER
47
48
 
48
- it "should return escaped unhighlighted source if a syntax error is found (ripper)" do
49
- should_receive(:options).and_return(Options.new.update(:highlight => true))
50
- html_syntax_highlight("$ git clone http://url").should == "$ git clone http://url"
49
+ it "returns escaped unhighlighted source if a syntax error is found (ripper)" do
50
+ expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
51
+ expect(html_syntax_highlight("$ git clone http://url")).to eq "$ git clone http://url"
51
52
  end if HAVE_RIPPER
52
53
  end
53
54
  end
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + "/../../spec_helper"
2
2
 
3
3
  describe YARD::Templates::Helpers::Markup::RDocMarkup do
4
- describe 'loading mechanism' do
4
+ describe "loading mechanism" do
5
5
  before { @good_libs = [] }
6
6
 
7
7
  def require(lib)
@@ -25,69 +25,62 @@ describe YARD::Templates::Helpers::Markup::RDocMarkup do
25
25
  end
26
26
  end
27
27
 
28
- it "should load RDoc2.x if rdoc/markup is present" do
28
+ it "loads RDoc2.x if rdoc/markup is present" do
29
29
  @good_libs += ['rdoc/markup', 'rdoc/markup/to_html']
30
- load_markup.should == :RDoc2
30
+ expect(load_markup).to eq :RDoc2
31
31
  end
32
32
 
33
- it "should fail on RDoc2.x if rdoc/markup/to_html is not present" do
33
+ it "fails on RDoc2.x if rdoc/markup/to_html is not present" do
34
34
  @good_libs += ['rdoc/markup']
35
- lambda { load_markup }.should raise_error(NameError)
35
+ expect { load_markup }.to raise_error(NameError)
36
36
  end
37
37
 
38
- it "should load RDoc1.x if RDoc2 fails and rdoc/markup/simple_markup is present" do
38
+ it "loads RDoc1.x if RDoc2 fails and rdoc/markup/simple_markup is present" do
39
39
  @good_libs += ['rdoc/markup/simple_markup', 'rdoc/markup/simple_markup/to_html']
40
- load_markup.should == :RDoc1
40
+ expect(load_markup).to eq :RDoc1
41
41
  end
42
42
 
43
- it "should error on loading if neither lib is present" do
44
- lambda { load_markup }.should raise_error(NameError)
43
+ it "raises an error on loading if neither lib is present" do
44
+ expect { load_markup }.to raise_error(NameError)
45
45
  end
46
46
  end
47
47
 
48
- describe '#to_html' do
48
+ describe "#to_html" do
49
49
  def to_html(text)
50
50
  html = YARD::Templates::Helpers::Markup::RDocMarkup.new(text).to_html
51
51
  html.strip.gsub(/\r?\n/, '')
52
52
  end
53
53
 
54
- it 'handles typewriter text' do
55
- to_html('Hello +<code>+').should == '<p>Hello <tt>&lt;code&gt;</tt></p>'
54
+ it "handles typewriter text" do
55
+ expect(to_html('Hello +<code>+')).to eq '<p>Hello <tt>&lt;code&gt;</tt></p>'
56
56
  end
57
57
  end
58
58
 
59
- describe '#fix_typewriter' do
59
+ describe "#fix_typewriter" do
60
60
  def fix_typewriter(text)
61
61
  YARD::Templates::Helpers::Markup::RDocMarkup.new('').send(:fix_typewriter, text)
62
62
  end
63
63
 
64
- it "should use #fix_typewriter to convert +text+ to <tt>text</tt>" do
65
- fix_typewriter("Some +typewriter text &lt;+.").should ==
66
- "Some <tt>typewriter text &lt;</tt>."
67
- fix_typewriter("Not +typewriter text.").should ==
68
- "Not +typewriter text."
69
- fix_typewriter("Alternating +type writer+ text +here+.").should ==
70
- "Alternating <tt>type writer</tt> text <tt>here</tt>."
71
- fix_typewriter("No ++problem.").should ==
72
- "No ++problem."
73
- fix_typewriter("Math + stuff +is ok+").should ==
74
- "Math + stuff <tt>is ok</tt>"
75
- fix_typewriter("Hello +{Foo}+ World").should == "Hello <tt>{Foo}</tt> World"
64
+ it "converts +text+ to <tt>text</tt>" do
65
+ expect(fix_typewriter("Some +typewriter text &lt;+.")).to eq "Some <tt>typewriter text &lt;</tt>."
66
+ expect(fix_typewriter("Not +typewriter text.")).to eq "Not +typewriter text."
67
+ expect(fix_typewriter("Alternating +type writer+ text +here+.")).to eq "Alternating <tt>type writer</tt> text <tt>here</tt>."
68
+ expect(fix_typewriter("No ++problem.")).to eq "No ++problem."
69
+ expect(fix_typewriter("Math + stuff +is ok+")).to eq "Math + stuff <tt>is ok</tt>"
70
+ expect(fix_typewriter("Hello +{Foo}+ World")).to eq "Hello <tt>{Foo}</tt> World"
76
71
  end
77
72
 
78
- it "should not apply to code blocks" do
79
- fix_typewriter("<code>Hello +hello+</code>").should == "<code>Hello +hello+</code>"
73
+ it "does not apply to code blocks" do
74
+ expect(fix_typewriter("<code>Hello +hello+</code>")).to eq "<code>Hello +hello+</code>"
80
75
  end
81
76
 
82
- it "should not apply to HTML tag attributes" do
83
- fix_typewriter("<a href='http://foo.com/A+b+c'>A+b+c</a>").should ==
84
- "<a href='http://foo.com/A+b+c'>A+b+c</a>"
85
- fix_typewriter("<foo class='foo+bar+baz'/>").should ==
86
- "<foo class='foo+bar+baz'/>"
77
+ it "does not apply to HTML tag attributes" do
78
+ expect(fix_typewriter("<a href='http://foo.com/A+b+c'>A+b+c</a>")).to eq "<a href='http://foo.com/A+b+c'>A+b+c</a>"
79
+ expect(fix_typewriter("<foo class='foo+bar+baz'/>")).to eq "<foo class='foo+bar+baz'/>"
87
80
  end
88
81
 
89
- it "should still apply inside of other tags" do
90
- fix_typewriter("<p>+foo+</p>").should == "<p><tt>foo</tt></p>"
82
+ it "still applies inside of other tags" do
83
+ expect(fix_typewriter("<p>+foo+</p>")).to eq "<p><tt>foo</tt></p>"
91
84
  end
92
85
  end
93
86
  end
@@ -17,117 +17,117 @@ describe YARD::Templates::Helpers::MarkupHelper do
17
17
  YARD::Templates::Helpers::MarkupHelper.clear_markup_cache
18
18
  end
19
19
 
20
- describe '#load_markup_provider' do
20
+ describe "#load_markup_provider" do
21
21
  before do
22
- log.stub!(:error)
22
+ allow(log).to receive(:error)
23
23
  @gen = GeneratorMock.new
24
24
  @gen.options.reset_defaults
25
25
  end
26
26
 
27
- it "should exit on an invalid markup type" do
27
+ it "exits on an invalid markup type" do
28
28
  @gen.options.markup = :invalid
29
- @gen.load_markup_provider.should == false
29
+ expect(@gen.load_markup_provider).to be false
30
30
  end
31
31
 
32
- it "should fail on when an invalid markup provider is specified" do
32
+ it "fails when an invalid markup provider is specified" do
33
33
  @gen.options.update(:markup => :markdown, :markup_provider => :invalid)
34
- @gen.load_markup_provider.should == false
35
- @gen.markup_class.should == nil
34
+ expect(@gen.load_markup_provider).to be false
35
+ expect(@gen.markup_class).to eq nil
36
36
  end
37
37
 
38
- it "should load RDocMarkup if rdoc is specified and it is installed" do
38
+ it "loads RDocMarkup if rdoc is specified and it is installed" do
39
39
  @gen.options.markup = :rdoc
40
- @gen.load_markup_provider.should == true
41
- @gen.markup_class.should == YARD::Templates::Helpers::Markup::RDocMarkup
40
+ expect(@gen.load_markup_provider).to be true
41
+ expect(@gen.markup_class).to eq YARD::Templates::Helpers::Markup::RDocMarkup
42
42
  end
43
43
 
44
- it "should fail if RDoc cannot be loaded" do
44
+ it "fails if RDoc cannot be loaded" do
45
45
  @gen.options.markup = :rdoc
46
- @gen.should_receive(:eval).with('::YARD::Templates::Helpers::Markup::RDocMarkup').and_raise(NameError)
47
- @gen.load_markup_provider.should == false
48
- @gen.markup_provider.should == nil
46
+ expect(@gen).to receive(:eval).with('::YARD::Templates::Helpers::Markup::RDocMarkup').and_raise(NameError)
47
+ expect(@gen.load_markup_provider).to be false
48
+ expect(@gen.markup_provider).to eq nil
49
49
  end
50
50
 
51
- it "should search through available markup providers for the markup type if none is set" do
52
- @gen.should_receive(:eval).with('::RedcarpetCompat').and_return(mock(:bluecloth))
53
- @gen.should_receive(:require).with('redcarpet').and_return(true)
54
- @gen.should_not_receive(:require).with('maruku')
51
+ it "searches through available markup providers for the markup type if none is set" do
52
+ expect(@gen).to receive(:eval).with('::RedcarpetCompat').and_return(double(:bluecloth))
53
+ expect(@gen).to receive(:require).with('redcarpet').and_return(true)
54
+ expect(@gen).not_to receive(:require).with('maruku')
55
55
  @gen.options.markup = :markdown
56
56
  # this only raises an exception because we mock out require to avoid
57
57
  # loading any libraries but our implementation tries to return the library
58
58
  # name as a constant
59
- @gen.load_markup_provider.should == true
60
- @gen.markup_provider.should == :redcarpet
59
+ expect(@gen.load_markup_provider).to be true
60
+ expect(@gen.markup_provider).to eq :redcarpet
61
61
  end
62
62
 
63
- it "should continue searching if some of the providers are unavailable" do
64
- @gen.should_receive(:require).with('redcarpet').and_raise(LoadError)
65
- @gen.should_receive(:require).with('rdiscount').and_raise(LoadError)
66
- @gen.should_receive(:require).with('kramdown').and_raise(LoadError)
67
- @gen.should_receive(:require).with('bluecloth').and_raise(LoadError)
68
- @gen.should_receive(:require).with('maruku').and_raise(LoadError)
69
- @gen.should_receive(:require).with('rpeg-markdown').and_return(true)
70
- @gen.should_receive(:eval).with('::PEGMarkdown').and_return(true)
63
+ it "continues searching if some of the providers are unavailable" do
64
+ expect(@gen).to receive(:require).with('redcarpet').and_raise(LoadError)
65
+ expect(@gen).to receive(:require).with('rdiscount').and_raise(LoadError)
66
+ expect(@gen).to receive(:require).with('kramdown').and_raise(LoadError)
67
+ expect(@gen).to receive(:require).with('bluecloth').and_raise(LoadError)
68
+ expect(@gen).to receive(:require).with('maruku').and_raise(LoadError)
69
+ expect(@gen).to receive(:require).with('rpeg-markdown').and_return(true)
70
+ expect(@gen).to receive(:eval).with('::PEGMarkdown').and_return(true)
71
71
  @gen.options.markup = :markdown
72
72
  # this only raises an exception because we mock out require to avoid
73
73
  # loading any libraries but our implementation tries to return the library
74
74
  # name as a constant
75
- @gen.load_markup_provider.should rescue nil
76
- @gen.markup_provider.should == :"rpeg-markdown"
75
+ @gen.load_markup_provider
76
+ expect(@gen.markup_provider).to eq :"rpeg-markdown"
77
77
  end
78
78
 
79
- it "should override the search if `:markup_provider` is set in options" do
80
- @gen.should_receive(:require).with('rdiscount').and_return(true)
81
- @gen.should_receive(:eval).with('::RDiscount').and_return(true)
79
+ it "overrides the search if `:markup_provider` is set in options" do
80
+ expect(@gen).to receive(:require).with('rdiscount').and_return(true)
81
+ expect(@gen).to receive(:eval).with('::RDiscount').and_return(true)
82
82
  @gen.options.update(:markup => :markdown, :markup_provider => :rdiscount)
83
- @gen.load_markup_provider.should rescue nil
84
- @gen.markup_provider.should == :rdiscount
83
+ @gen.load_markup_provider
84
+ expect(@gen.markup_provider).to eq :rdiscount
85
85
  end
86
86
 
87
- it "should fail if no provider is found" do
87
+ it "fails if no provider is found" do
88
88
  YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS[:markdown].each do |p|
89
- @gen.should_receive(:require).with(p[:lib].to_s).and_raise(LoadError)
89
+ expect(@gen).to receive(:require).with(p[:lib].to_s).and_raise(LoadError)
90
90
  end
91
91
  @gen.options.markup = :markdown
92
- @gen.load_markup_provider.should == false
93
- @gen.markup_provider.should == nil
92
+ expect(@gen.load_markup_provider).to be false
93
+ expect(@gen.markup_provider).to eq nil
94
94
  end
95
95
 
96
- it "should fail if overridden provider is not found" do
97
- @gen.should_receive(:require).with('rdiscount').and_raise(LoadError)
96
+ it "fails if overridden provider is not found" do
97
+ expect(@gen).to receive(:require).with('rdiscount').and_raise(LoadError)
98
98
  @gen.options.update(:markup => :markdown, :markup_provider => :rdiscount)
99
- @gen.load_markup_provider.should == false
100
- @gen.markup_provider.should == nil
99
+ expect(@gen.load_markup_provider).to be false
100
+ expect(@gen.markup_provider).to eq nil
101
101
  end
102
102
 
103
- it "should fail if the markup type is not found" do
104
- log.should_receive(:error).with(/Invalid markup/)
103
+ it "fails if the markup type is not found" do
104
+ expect(log).to receive(:error).with(/Invalid markup/)
105
105
  @gen.options.markup = :xxx
106
- @gen.load_markup_provider.should == false
107
- @gen.markup_provider.should == nil
106
+ expect(@gen.load_markup_provider).to be false
107
+ expect(@gen.markup_provider).to eq nil
108
108
  end
109
109
  end
110
110
 
111
- describe '#markup_for_file' do
111
+ describe "#markup_for_file" do
112
112
  include YARD::Templates::Helpers::MarkupHelper
113
113
 
114
- it "should look for a shebang line" do
115
- markup_for_file("#!text\ntext here", 'file.rdoc').should == :text
114
+ it "looks for a shebang line" do
115
+ expect(markup_for_file("#!text\ntext here", 'file.rdoc')).to eq :text
116
116
  end
117
117
 
118
- it "should return the default markup type if no shebang is found or no valid ext is found" do
119
- stub!(:options).and_return(Options.new.update(:markup => :default_type))
120
- markup_for_file('', 'filename').should == :default_type
118
+ it "returns the default markup type if no shebang is found or no valid ext is found" do
119
+ allow(self).to receive(:options).and_return(Options.new.update(:markup => :default_type))
120
+ expect(markup_for_file('', 'filename')).to eq :default_type
121
121
  end
122
122
 
123
- it "should look for a file extension if no shebang is found" do
124
- markup_for_file('', 'filename.MD').should == :markdown
123
+ it "looks for a file extension if no shebang is found" do
124
+ expect(markup_for_file('', 'filename.MD')).to eq :markdown
125
125
  end
126
126
 
127
127
  Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS.each do |type, exts|
128
128
  exts.each do |ext|
129
- it "should recognize .#{ext} as #{type} markup type" do
130
- markup_for_file('', "filename.#{ext}").should == type
129
+ it "recognizes .#{ext} as #{type} markup type" do
130
+ expect(markup_for_file('', "filename.#{ext}")).to eq type
131
131
  end
132
132
  end
133
133
  end
@@ -4,60 +4,60 @@ describe YARD::Templates::Helpers::MethodHelper do
4
4
  include YARD::Templates::Helpers::BaseHelper
5
5
  include YARD::Templates::Helpers::MethodHelper
6
6
 
7
- describe '#format_args' do
8
- it "should display keyword arguments" do
7
+ describe "#format_args" do
8
+ it "displays keyword arguments" do
9
9
  params = [['a:', '1'], ['b:', '2'], ['**kwargs', nil]]
10
10
  YARD.parse_string 'def foo; end'
11
- Registry.at('#foo').stub(:parameters) { params }
12
- format_args(Registry.at('#foo')).should == '(a: 1, b: 2, **kwargs)'
11
+ allow(Registry.at('#foo')).to receive(:parameters) { params }
12
+ expect(format_args(Registry.at('#foo'))).to eq '(a: 1, b: 2, **kwargs)'
13
13
  end
14
14
 
15
- it "should not show &blockarg if no @param tag and has @yield" do
15
+ it "does not show &blockarg if no @param tag and has @yield" do
16
16
  YARD.parse_string <<-'eof'
17
17
  # @yield blah
18
18
  def foo(&block); end
19
19
  eof
20
- format_args(Registry.at('#foo')).should == ''
20
+ expect(format_args(Registry.at('#foo'))).to eq ''
21
21
  end
22
22
 
23
- it "should not show &blockarg if no @param tag and has @yieldparam" do
23
+ it "does not show &blockarg if no @param tag and has @yieldparam" do
24
24
  YARD.parse_string <<-'eof'
25
25
  # @yieldparam blah test
26
26
  def foo(&block); end
27
27
  eof
28
- format_args(Registry.at('#foo')).should == ''
28
+ expect(format_args(Registry.at('#foo'))).to eq ''
29
29
  end
30
30
 
31
- it "should show &blockarg if @param block is documented (even with @yield)" do
31
+ it "shows &blockarg if @param block is documented (even with @yield)" do
32
32
  YARD.parse_string <<-'eof'
33
33
  # @yield [a,b]
34
34
  # @yieldparam a test
35
35
  # @param block test
36
36
  def foo(&block) end
37
37
  eof
38
- format_args(Registry.at('#foo')).should == '(&block)'
38
+ expect(format_args(Registry.at('#foo'))).to eq '(&block)'
39
39
  end
40
40
  end
41
41
 
42
- describe '#format_block' do
42
+ describe "#format_block" do
43
43
  before { YARD::Registry.clear }
44
44
 
45
- it "should show block for method with yield" do
45
+ it "shows block for method with yield" do
46
46
  YARD.parse_string <<-'eof'
47
47
  def foo; yield(a, b, c) end
48
48
  eof
49
- format_block(Registry.at('#foo')).should == "{|a, b, c| ... }"
49
+ expect(format_block(Registry.at('#foo'))).to eq "{|a, b, c| ... }"
50
50
  end
51
51
 
52
- it "should show block for method with @yieldparam tags" do
52
+ it "shows block for method with @yieldparam tags" do
53
53
  YARD.parse_string <<-'eof'
54
54
  # @yieldparam _self me!
55
55
  def foo; end
56
56
  eof
57
- format_block(Registry.at('#foo')).should == "{|_self| ... }"
57
+ expect(format_block(Registry.at('#foo'))).to eq "{|_self| ... }"
58
58
  end
59
59
 
60
- it "should show block for method with @yield but no types" do
60
+ it "shows block for method with @yield but no types" do
61
61
  YARD.parse_string <<-'eof'
62
62
  # @yield blah
63
63
  # @yieldparam a
@@ -66,17 +66,17 @@ describe YARD::Templates::Helpers::MethodHelper do
66
66
  # @yield blah
67
67
  def foo2; end
68
68
  eof
69
- format_block(Registry.at('#foo')).should == "{|a| ... }"
70
- format_block(Registry.at('#foo2')).should == "{ ... }"
69
+ expect(format_block(Registry.at('#foo'))).to eq "{|a| ... }"
70
+ expect(format_block(Registry.at('#foo2'))).to eq "{ ... }"
71
71
  end
72
72
 
73
- it "should show block for method with @yield and types" do
73
+ it "shows block for method with @yield and types" do
74
74
  YARD.parse_string <<-'eof'
75
75
  # @yield [a, b, c] blah
76
76
  # @yieldparam a
77
77
  def foo; end
78
78
  eof
79
- format_block(Registry.at('#foo')).should == "{|a, b, c| ... }"
79
+ expect(format_block(Registry.at('#foo'))).to eq "{|a, b, c| ... }"
80
80
  end
81
81
  end
82
82
  end
@@ -3,121 +3,123 @@ shared_examples_for "signature" do
3
3
  YARD::Registry.clear
4
4
  @options = Templates::TemplateOptions.new
5
5
  @options.reset_defaults
6
- stub!(:options).and_return(@options)
6
+ allow(self).to receive(:options).and_return(@options)
7
7
  end
8
8
 
9
- it "should show signature for regular instance method" do
9
+ def trim(sig) sig.gsub(/\s+/, ' ') end
10
+
11
+ it "shows signature for regular instance method" do
10
12
  YARD.parse_string "def foo; end"
11
- signature(Registry.at('#foo')).should == @results[:regular]
13
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:regular]
12
14
  end
13
15
 
14
- it "should allow default return type to be changed" do
16
+ it "allows default return type to be changed" do
15
17
  @options.default_return = "Hello"
16
18
  YARD.parse_string "def foo; end"
17
- signature(Registry.at('#foo')).should == @results[:default_return]
19
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:default_return]
18
20
  end
19
21
 
20
- it "should allow default return type to be omitted" do
22
+ it "allows default return type to be omitted" do
21
23
  @options.default_return = ""
22
24
  YARD.parse_string "def foo; end"
23
- signature(Registry.at('#foo')).should == @results[:no_default_return]
25
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:no_default_return]
24
26
  end
25
27
 
26
- it "should show signature for private class method" do
28
+ it "shows signature for private class method" do
27
29
  YARD.parse_string "class A; private; def self.foo; end end"
28
- signature(Registry.at('A.foo')).should == @results[:private_class]
30
+ expect(trim(signature(Registry.at('A.foo')))).to eq @results[:private_class]
29
31
  end
30
32
 
31
- it "should show return type for single type" do
33
+ it "shows return type for single type" do
32
34
  YARD.parse_string <<-'eof'
33
35
  # @return [String]
34
36
  def foo; end
35
37
  eof
36
- signature(Registry.at('#foo')).should == @results[:single]
38
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:single]
37
39
  end
38
40
 
39
- it "should show return type for 2 types" do
41
+ it "shows return type for 2 types" do
40
42
  YARD.parse_string <<-'eof'
41
43
  # @return [String, Symbol]
42
44
  def foo; end
43
45
  eof
44
- signature(Registry.at('#foo')).should == @results[:two_types]
46
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:two_types]
45
47
  end
46
48
 
47
- it "should show return type for 2 types over multiple tags" do
49
+ it "shows return type for 2 types over multiple tags" do
48
50
  YARD.parse_string <<-'eof'
49
51
  # @return [String]
50
52
  # @return [Symbol]
51
53
  def foo; end
52
54
  eof
53
- signature(Registry.at('#foo')).should == @results[:two_types_multitag]
55
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:two_types_multitag]
54
56
  end
55
57
 
56
- it "should show 'Type?' if return types are [Type, nil]" do
58
+ it "shows 'Type?' if return types are [Type, nil]" do
57
59
  YARD.parse_string <<-'eof'
58
60
  # @return [Type, nil]
59
61
  def foo; end
60
62
  eof
61
- signature(Registry.at('#foo')).should == @results[:type_nil]
63
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_nil]
62
64
  end
63
65
 
64
- it "should show 'Type?' if return types are [Type, nil, nil] (extra nil)" do
66
+ it "shows 'Type?' if return types are [Type, nil, nil] (extra nil)" do
65
67
  YARD.parse_string <<-'eof'
66
68
  # @return [Type, nil]
67
69
  # @return [nil]
68
70
  def foo; end
69
71
  eof
70
- signature(Registry.at('#foo')).should == @results[:type_nil]
72
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_nil]
71
73
  end
72
74
 
73
- it "should show 'Type+' if return types are [Type, Array<Type>]" do
75
+ it "shows 'Type+' if return types are [Type, Array<Type>]" do
74
76
  YARD.parse_string <<-'eof'
75
77
  # @return [Type, <Type>]
76
78
  def foo; end
77
79
  eof
78
- signature(Registry.at('#foo')).should == @results[:type_array]
80
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_array]
79
81
  end
80
82
 
81
- it "should (Type, ...) for more than 2 return types" do
83
+ it "shows (Type, ...) for more than 2 return types" do
82
84
  YARD.parse_string <<-'eof'
83
85
  # @return [Type, <Type>]
84
86
  # @return [AnotherType]
85
87
  def foo; end
86
88
  eof
87
- signature(Registry.at('#foo')).should == @results[:multitype]
89
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:multitype]
88
90
  end
89
91
 
90
- it "should show (void) for @return [void] by default" do
92
+ it "shows (void) for @return [void] by default" do
91
93
  YARD.parse_string <<-'eof'
92
94
  # @return [void]
93
95
  def foo; end
94
96
  eof
95
- signature(Registry.at('#foo')).should == @results[:void]
97
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:void]
96
98
  end
97
99
 
98
- it "should not show return for @return [void] if :hide_void_return is true" do
100
+ it "does not show return for @return [void] if :hide_void_return is true" do
99
101
  @options.hide_void_return = true
100
102
  YARD.parse_string <<-'eof'
101
103
  # @return [void]
102
104
  def foo; end
103
105
  eof
104
- signature(Registry.at('#foo')).should == @results[:hide_void]
106
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:hide_void]
105
107
  end
106
108
 
107
- it "should show block for method with yield" do
109
+ it "shows block for method with yield" do
108
110
  YARD.parse_string <<-'eof'
109
111
  def foo; yield(a, b, c) end
110
112
  eof
111
- signature(Registry.at('#foo')).should == @results[:block]
113
+ expect(trim(signature(Registry.at('#foo')))).to eq @results[:block]
112
114
  end
113
115
 
114
- it "should use regular return tag if the @overload is empty" do
116
+ it "uses regular return tag if the @overload is empty" do
115
117
  YARD.parse_string <<-'eof'
116
118
  # @overload foobar
117
119
  # Hello world
118
120
  # @return [String]
119
121
  def foo; end
120
122
  eof
121
- signature(Registry.at('#foo').tag(:overload)).should == @results[:empty_overload]
123
+ expect(trim(signature(Registry.at('#foo').tag(:overload)))).to eq @results[:empty_overload]
122
124
  end
123
125
  end