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,85 +3,85 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe YARD::Docstring do
4
4
  before { YARD::Registry.clear }
5
5
 
6
- describe '#initialize' do
7
- it "should handle docstrings with empty newlines" do
8
- Docstring.new("\n\n").should == ""
6
+ describe "#initialize" do
7
+ it "handles docstrings with empty newlines" do
8
+ expect(Docstring.new("\n\n")).to eq ""
9
9
  end
10
10
  end
11
11
 
12
- describe '#+' do
13
- it "should add another Docstring" do
12
+ describe "#+" do
13
+ it "adds another Docstring" do
14
14
  d = Docstring.new("FOO") + Docstring.new("BAR")
15
- d.should == "FOO\nBAR"
15
+ expect(d).to eq "FOO\nBAR"
16
16
  end
17
17
 
18
- it "should copy over tags" do
18
+ it "copies over tags" do
19
19
  d1 = Docstring.new("FOO\n@api private\n")
20
20
  d2 = Docstring.new("BAR\n@param foo descr")
21
21
  d = (d1 + d2)
22
- d.should have_tag(:api)
23
- d.should have_tag(:param)
22
+ expect(d).to have_tag(:api)
23
+ expect(d).to have_tag(:param)
24
24
  end
25
25
 
26
- it "should add a String" do
26
+ it "adds a String" do
27
27
  d = Docstring.new("FOO") + "BAR"
28
- d.should == "FOOBAR"
28
+ expect(d).to eq "FOOBAR"
29
29
  end
30
30
  end
31
31
 
32
- describe '#line' do
33
- it "should return nil if #line_range is not set" do
34
- Docstring.new('foo').line.should be_nil
32
+ describe "#line" do
33
+ it "returns nil if #line_range is not set" do
34
+ expect(Docstring.new('foo').line).to be nil
35
35
  end
36
36
 
37
- it "should return line_range.first if #line_range is set" do
37
+ it "returns line_range.first if #line_range is set" do
38
38
  doc = Docstring.new('foo')
39
39
  doc.line_range = (1..10)
40
- doc.line.should == doc.line_range.first
40
+ expect(doc.line).to eq doc.line_range.first
41
41
  end
42
42
  end
43
43
 
44
- describe '#summary' do
45
- it "should handle empty docstrings" do
44
+ describe "#summary" do
45
+ it "handles empty docstrings" do
46
46
  o1 = Docstring.new
47
- o1.summary.should == ""
47
+ expect(o1.summary).to eq ""
48
48
  end
49
49
 
50
- it "should handle multiple calls" do
50
+ it "handles multiple calls" do
51
51
  o1 = Docstring.new("Hello. world")
52
- 5.times { o1.summary.should == "Hello." }
52
+ 5.times { expect(o1.summary).to eq "Hello." }
53
53
  end
54
54
 
55
- it "should strip HTML before summarizing" do
55
+ it "strips HTML before summarizing" do
56
56
  doc = Docstring.new("<p>Hello <b>world</b></p>.")
57
- doc.summary.should == 'Hello world.'
57
+ expect(doc.summary).to eq 'Hello world.'
58
58
  end
59
59
 
60
- it "should strip newlines in first paragraph before summarizing" do
60
+ it "strips newlines in first paragraph before summarizing" do
61
61
  doc = Docstring.new("Foo\n<code>==</code> bar.")
62
- doc.summary.should == 'Foo == bar.'
62
+ expect(doc.summary).to eq 'Foo == bar.'
63
63
  end
64
64
 
65
- it "should return the first sentence" do
65
+ it "returns the first sentence" do
66
66
  o = Docstring.new("DOCSTRING. Another sentence")
67
- o.summary.should == "DOCSTRING."
67
+ expect(o.summary).to eq "DOCSTRING."
68
68
  end
69
69
 
70
- it "should return the first paragraph" do
70
+ it "returns the first paragraph" do
71
71
  o = Docstring.new("DOCSTRING, and other stuff\n\nAnother sentence.")
72
- o.summary.should == "DOCSTRING, and other stuff."
72
+ expect(o.summary).to eq "DOCSTRING, and other stuff."
73
73
  end
74
74
 
75
- it "should return proper summary when docstring is changed" do
75
+ it "returns proper summary when docstring is changed" do
76
76
  o = Docstring.new "DOCSTRING, and other stuff\n\nAnother sentence."
77
- o.summary.should == "DOCSTRING, and other stuff."
77
+ expect(o.summary).to eq "DOCSTRING, and other stuff."
78
78
  o = Docstring.new "DOCSTRING."
79
- o.summary.should == "DOCSTRING."
79
+ expect(o.summary).to eq "DOCSTRING."
80
80
  end
81
81
 
82
- it "should not double the ending period" do
82
+ it "does not double the ending period" do
83
83
  o = Docstring.new("Returns a list of tags specified by +name+ or all tags if +name+ is not specified.\n\nTest")
84
- o.summary.should == "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
84
+ expect(o.summary).to eq "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
85
85
 
86
86
  doc = Docstring.new(<<-eof)
87
87
 
@@ -90,80 +90,87 @@ describe YARD::Docstring do
90
90
  @param name the tag name to return data for, or nil for all tags
91
91
  @return [Array<Tags::Tag>] the list of tags by the specified tag name
92
92
  eof
93
- doc.summary.should == "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
93
+ expect(doc.summary).to eq "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
94
94
  end
95
95
 
96
- it "should not attach period if entire summary is include" do
96
+ it "does not attach period if entire summary is include" do
97
97
  YARD.parse_string "# docstring\ndef foo; end"
98
- Docstring.new("{include:#foo}").summary.should == '{include:#foo}'
98
+ expect(Docstring.new("{include:#foo}").summary).to eq '{include:#foo}'
99
99
  Registry.clear
100
100
  end
101
101
 
102
- it "should handle references embedded in summary" do
103
- Docstring.new("Aliasing {Test.test}. Done.").summary.should == "Aliasing {Test.test}."
102
+ it "handles references embedded in summary" do
103
+ expect(Docstring.new("Aliasing {Test.test}. Done.").summary).to eq "Aliasing {Test.test}."
104
104
  end
105
105
 
106
- it "should only end first sentence when outside parentheses" do
107
- Docstring.new("Hello (the best.) world. Foo bar.").summary.should == "Hello (the best.) world."
108
- Docstring.new("A[b.]c.").summary.should == "A[b.]c."
106
+ it "only ends first sentence when outside parentheses" do
107
+ expect(Docstring.new("Hello (the best.) world. Foo bar.").summary).to eq "Hello (the best.) world."
108
+ expect(Docstring.new("A[b.]c.").summary).to eq "A[b.]c."
109
109
  end
110
110
 
111
- it "should only see '.' as period if whitespace (or eof) follows" do
112
- Docstring.new("hello 1.5 times.").summary.should == "hello 1.5 times."
113
- Docstring.new("hello... me").summary.should == "hello..."
114
- Docstring.new("hello.").summary.should == "hello."
111
+ it "only sees '.' as period if whitespace (or eof) follows" do
112
+ expect(Docstring.new("hello 1.5 times.").summary).to eq "hello 1.5 times."
113
+ expect(Docstring.new("hello... me").summary).to eq "hello..."
114
+ expect(Docstring.new("hello.").summary).to eq "hello."
115
+ end
116
+
117
+ it "returns summary if there is a newline and parentheses count doesn't match" do
118
+ expect(Docstring.new("Happy method call :-)\n\nCall any time.").summary).to eq "Happy method call :-)."
119
+ expect(Docstring.new("Sad method call :-(\n\nCall any time.").summary).to eq "Sad method call :-(."
120
+ expect(Docstring.new("Hello (World. Forget to close.\n\nNew text").summary).to eq "Hello (World. Forget to close."
121
+ expect(Docstring.new("Hello (World. Forget to close\n\nNew text").summary).to eq "Hello (World. Forget to close."
115
122
  end
116
123
  end
117
124
 
118
- describe '#ref_tags' do
119
- it "should parse reference tag into ref_tags" do
125
+ describe "#ref_tags" do
126
+ it "parses reference tag into ref_tags" do
120
127
  doc = Docstring.new("@return (see Foo#bar)")
121
- doc.ref_tags.size.should == 1
122
- doc.ref_tags.first.owner.should == P("Foo#bar")
123
- doc.ref_tags.first.tag_name.should == "return"
124
- doc.ref_tags.first.name.should be_nil
128
+ expect(doc.ref_tags.size).to eq 1
129
+ expect(doc.ref_tags.first.owner).to eq P("Foo#bar")
130
+ expect(doc.ref_tags.first.tag_name).to eq "return"
131
+ expect(doc.ref_tags.first.name).to be nil
125
132
  end
126
133
 
127
- it "should parse named reference tag into ref_tags" do
134
+ it "parses named reference tag into ref_tags" do
128
135
  doc = Docstring.new("@param blah \n (see Foo#bar )")
129
- doc.ref_tags.size.should == 1
130
- doc.ref_tags.first.owner.should == P("Foo#bar")
131
- doc.ref_tags.first.tag_name.should == "param"
132
- doc.ref_tags.first.name.should == "blah"
136
+ expect(doc.ref_tags.size).to eq 1
137
+ expect(doc.ref_tags.first.owner).to eq P("Foo#bar")
138
+ expect(doc.ref_tags.first.tag_name).to eq "param"
139
+ expect(doc.ref_tags.first.name).to eq "blah"
133
140
  end
134
141
 
135
- it "should fail to parse named reference tag into ref_tags" do
142
+ it "fails to parse named reference tag into ref_tags" do
136
143
  doc = Docstring.new("@param blah THIS_BREAKS_REFTAG (see Foo#bar)")
137
- doc.ref_tags.size.should == 0
144
+ expect(doc.ref_tags.size).to eq 0
138
145
  end
139
146
 
140
- it "should return all valid reference tags along with #tags" do
147
+ it "returns all valid reference tags along with #tags" do
141
148
  o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
142
149
  o.docstring.add_tag Tags::Tag.new('return', 'testing')
143
150
  doc = Docstring.new("@return (see Foo#bar)")
144
151
  tags = doc.tags
145
- tags.size.should == 1
146
- tags.first.text.should == 'testing'
147
- tags.first.should be_kind_of(Tags::RefTag)
148
- tags.first.owner.should == o
152
+ expect(tags.size).to eq 1
153
+ expect(tags.first.text).to eq 'testing'
154
+ expect(tags.first).to be_kind_of(Tags::RefTag)
155
+ expect(tags.first.owner).to eq o
149
156
  end
150
157
 
151
- it "should return all valid named reference tags along with #tags(name)" do
158
+ it "returns all valid named reference tags along with #tags(name)" do
152
159
  o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
153
160
  o.docstring.add_tag Tags::Tag.new('param', 'testing', nil, '*args')
154
161
  o.docstring.add_tag Tags::Tag.new('param', 'NOTtesting', nil, 'notargs')
155
162
  doc = Docstring.new("@param *args (see Foo#bar)")
156
163
  tags = doc.tags('param')
157
- tags.size.should == 1
158
- tags.first.text.should == 'testing'
159
- tags.first.should be_kind_of(Tags::RefTag)
160
- tags.first.owner.should == o
164
+ expect(tags.size).to eq 1
165
+ expect(tags.first.text).to eq 'testing'
166
+ expect(tags.first).to be_kind_of(Tags::RefTag)
167
+ expect(tags.first.owner).to eq o
161
168
  end
162
169
 
163
- it "should ignore invalid reference tags" do
170
+ it "ignores invalid reference tags" do
164
171
  doc = Docstring.new("@param *args (see INVALID::TAG#tag)")
165
172
  tags = doc.tags('param')
166
- tags.size.should == 0
173
+ expect(tags.size).to eq 0
167
174
  end
168
175
 
169
176
  it "resolves references to methods in the same class with #methname" do
@@ -174,147 +181,147 @@ describe YARD::Docstring do
174
181
  ref.docstring = "@param (see #bar)"
175
182
 
176
183
  tags = ref.docstring.tags("param")
177
- tags.size.should == 1
178
- tags.first.text.should == "testing"
179
- tags.first.should be_kind_of(Tags::RefTag)
180
- tags.first.owner.should == o
184
+ expect(tags.size).to eq 1
185
+ expect(tags.first.text).to eq "testing"
186
+ expect(tags.first).to be_kind_of(Tags::RefTag)
187
+ expect(tags.first.owner).to eq o
181
188
  end
182
189
  end
183
190
 
184
- describe '#empty?/#blank?' do
191
+ describe "#empty?/#blank?" do
185
192
  before(:all) do
186
193
  Tags::Library.define_tag "Invisible", :invisible_tag
187
194
  end
188
195
 
189
- it "should be blank and empty if it has no content and no tags" do
190
- Docstring.new.should be_blank
191
- Docstring.new.should be_empty
196
+ it "is blank and empty if it has no content and no tags" do
197
+ expect(Docstring.new).to be_blank
198
+ expect(Docstring.new).to be_empty
192
199
  end
193
200
 
194
- it "shouldn't be empty or blank if it has content" do
201
+ it "isn't empty or blank if it has content" do
195
202
  d = Docstring.new("foo bar")
196
- d.should_not be_empty
197
- d.should_not be_blank
203
+ expect(d).not_to be_empty
204
+ expect(d).not_to be_blank
198
205
  end
199
206
 
200
- it "should be empty but not blank if it has tags" do
207
+ it "is empty but not blank if it has tags" do
201
208
  d = Docstring.new("@param foo")
202
- d.should be_empty
203
- d.should_not be_blank
209
+ expect(d).to be_empty
210
+ expect(d).not_to be_blank
204
211
  end
205
212
 
206
- it "should be empty but not blank if it has ref tags" do
213
+ it "is empty but not blank if it has ref tags" do
207
214
  o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
208
215
  o.docstring.add_tag Tags::Tag.new('return', 'testing')
209
216
  d = Docstring.new("@return (see Foo#bar)")
210
- d.should be_empty
211
- d.should_not be_blank
217
+ expect(d).to be_empty
218
+ expect(d).not_to be_blank
212
219
  end
213
220
 
214
- it "should be blank if it has no visible tags" do
221
+ it "is blank if it has no visible tags" do
215
222
  d = Docstring.new("@invisible_tag value")
216
- d.should be_blank
223
+ expect(d).to be_blank
217
224
  end
218
225
 
219
- it "should not be blank if it has invisible tags and only_visible_tags = false" do
226
+ it "is not blank if it has invisible tags and only_visible_tags = false" do
220
227
  d = Docstring.new("@invisible_tag value")
221
228
  d.add_tag Tags::Tag.new('invisible_tag', nil, nil)
222
- d.blank?(false).should == false
229
+ expect(d.blank?(false)).to be false
223
230
  end
224
231
  end
225
232
 
226
- describe '#delete_tags' do
227
- it "should delete tags by a given tag name" do
233
+ describe "#delete_tags" do
234
+ it "deletes tags by a given tag name" do
228
235
  doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
229
236
  doc.delete_tags(:param)
230
- doc.tags.size.should == 1
237
+ expect(doc.tags.size).to eq 1
231
238
  end
232
239
  end
233
240
 
234
- describe '#delete_tag_if' do
235
- it "should delete tags for a given block" do
241
+ describe "#delete_tag_if" do
242
+ it "deletes tags for a given block" do
236
243
  doc = Docstring.new("@param name x\n@param name2 y\n@return foo")
237
244
  doc.delete_tag_if {|t| t.name == 'name2' }
238
- doc.tags.size.should == 2
245
+ expect(doc.tags.size).to eq 2
239
246
  end
240
247
  end
241
248
 
242
- describe '#to_raw' do
243
- it "should return a clean representation of tags" do
249
+ describe "#to_raw" do
250
+ it "returns a clean representation of tags" do
244
251
  doc = Docstring.new("Hello world\n@return [String, X] foobar\n@param name<Array> the name\nBYE!")
245
- doc.to_raw.should == "Hello world\nBYE!\n@param [Array] name\n the name\n@return [String, X] foobar"
252
+ expect(doc.to_raw).to eq "Hello world\nBYE!\n@param [Array] name\n the name\n@return [String, X] foobar"
246
253
  end
247
254
 
248
- it "should handle tags with newlines and indentation" do
255
+ it "handles tags with newlines and indentation" do
249
256
  doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
250
- doc.to_raw.should == "@example TITLE\n the \n example\n @foo\n@param [X] name\n the name"
257
+ expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo\n@param [X] name\n the name"
251
258
  end
252
259
 
253
- it "should handle deleted tags" do
260
+ it "handles deleted tags" do
254
261
  doc = Docstring.new("@example TITLE\n the \n example\n @foo\n@param [X] name\n the name")
255
262
  doc.delete_tags(:param)
256
- doc.to_raw.should == "@example TITLE\n the \n example\n @foo"
263
+ expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo"
257
264
  end
258
265
 
259
- it "should handle added tags" do
266
+ it "handles added tags" do
260
267
  doc = Docstring.new("@example TITLE\n the \n example\n @foo")
261
268
  doc.add_tag(Tags::Tag.new('foo', 'foo'))
262
- doc.to_raw.should == "@example TITLE\n the \n example\n @foo\n@foo foo"
269
+ expect(doc.to_raw).to eq "@example TITLE\n the \n example\n @foo\n@foo foo"
263
270
  end
264
271
 
265
- it "should be equal to .all if not modified" do
272
+ it "is equal to .all if not modified" do
266
273
  doc = Docstring.new("123\n@param")
267
- doc.to_raw.should == doc.all
274
+ expect(doc.to_raw).to eq doc.all
268
275
  end
269
276
 
270
277
  # @bug gh-563
271
- it "should handle full @option tags" do
278
+ it "handles full @option tags" do
272
279
  doc = Docstring.new("@option foo [String] bar (nil) baz")
273
- doc.to_raw.should == "@option foo [String] bar (nil) baz"
280
+ expect(doc.to_raw).to eq "@option foo [String] bar (nil) baz"
274
281
  end
275
282
 
276
283
  # @bug gh-563
277
- it "should handle simple @option tags" do
284
+ it "handles simple @option tags" do
278
285
  doc = Docstring.new("@option foo :key bar")
279
- doc.to_raw.should == "@option foo :key bar"
286
+ expect(doc.to_raw).to eq "@option foo :key bar"
280
287
  end
281
288
  end
282
289
 
283
- describe '#dup' do
284
- it "should duplicate docstring text" do
290
+ describe "#dup" do
291
+ it "duplicates docstring text" do
285
292
  doc = Docstring.new("foo")
286
- doc.dup.should == doc
287
- doc.dup.all.should == doc
293
+ expect(doc.dup).to eq doc
294
+ expect(doc.dup.all).to eq doc
288
295
  end
289
296
 
290
- it "should duplicate tags to new list" do
297
+ it "duplicates tags to new list" do
291
298
  doc = Docstring.new("@param x\n@return y")
292
299
  doc2 = doc.dup
293
300
  doc2.delete_tags(:param)
294
- doc.tags.size.should == 2
295
- doc2.tags.size.should == 1
301
+ expect(doc.tags.size).to eq 2
302
+ expect(doc2.tags.size).to eq 1
296
303
  end
297
304
 
298
- it "should preserve summary" do
305
+ it "preserves summary" do
299
306
  doc = Docstring.new("foo. bar")
300
- doc.dup.summary.should == doc.summary
307
+ expect(doc.dup.summary).to eq doc.summary
301
308
  end
302
309
 
303
- it "should preserve hash_flag" do
310
+ it "preserves hash_flag" do
304
311
  doc = Docstring.new
305
312
  doc.hash_flag = 'foo'
306
- doc.dup.hash_flag.should == doc.hash_flag
313
+ expect(doc.dup.hash_flag).to eq doc.hash_flag
307
314
  end
308
315
 
309
- it "should preserve line_range" do
316
+ it "preserves line_range" do
310
317
  doc = Docstring.new
311
318
  doc.line_range = (1..2)
312
- doc.dup.line_range.should == doc.line_range
319
+ expect(doc.dup.line_range).to eq doc.line_range
313
320
  end
314
321
  end
315
322
 
316
- describe 'reference docstrings' do
317
- it 'allows for construction of docstring with ref object' do
323
+ describe "reference docstrings" do
324
+ it "allows for construction of docstring with ref object" do
318
325
  YARD.parse_string <<-eof
319
326
  class A
320
327
  # Docstring
@@ -326,8 +333,8 @@ describe YARD::Docstring do
326
333
  eof
327
334
 
328
335
  object = YARD::Registry.at('A#b')
329
- object.docstring.should == 'Docstring'
330
- object.tags.map {|x| x.tag_name }.should == ['return']
336
+ expect(object.docstring).to eq 'Docstring'
337
+ expect(object.tags.map {|x| x.tag_name }).to eq ['return']
331
338
 
332
339
  YARD::Registry.clear
333
340
  end