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
@@ -13,16 +13,16 @@ describe YARD::Parser::Ruby::RubyParser do
13
13
  YARD::Parser::Ruby::RubyParser.new(stmt, nil).parse.tokens
14
14
  end
15
15
 
16
- describe '#parse' do
17
- it "should get comment line numbers" do
16
+ describe "#parse" do
17
+ it "gets comment line numbers" do
18
18
  s = stmt <<-eof
19
19
  # comment
20
20
  # comment
21
21
  # comment
22
22
  def method; end
23
23
  eof
24
- s.comments.should == "comment\ncomment\ncomment"
25
- s.comments_range.should == (1..3)
24
+ expect(s.comments).to eq "comment\ncomment\ncomment"
25
+ expect(s.comments_range).to eq (1..3)
26
26
 
27
27
  s = stmt <<-eof
28
28
 
@@ -30,8 +30,8 @@ describe YARD::Parser::Ruby::RubyParser do
30
30
  # comment
31
31
  def method; end
32
32
  eof
33
- s.comments.should == "comment\ncomment"
34
- s.comments_range.should == (2..3)
33
+ expect(s.comments).to eq "comment\ncomment"
34
+ expect(s.comments_range).to eq (2..3)
35
35
 
36
36
  s = stmt <<-eof
37
37
  # comment
@@ -39,24 +39,24 @@ describe YARD::Parser::Ruby::RubyParser do
39
39
 
40
40
  def method; end
41
41
  eof
42
- s.comments.should == "comment\ncomment"
43
- s.comments_range.should == (1..2)
42
+ expect(s.comments).to eq "comment\ncomment"
43
+ expect(s.comments_range).to eq (1..2)
44
44
 
45
45
  s = stmt <<-eof
46
46
  # comment
47
47
  def method; end
48
48
  eof
49
- s.comments.should == "comment"
50
- s.comments_range.should == (1..1)
49
+ expect(s.comments).to eq "comment"
50
+ expect(s.comments_range).to eq (1..1)
51
51
 
52
52
  s = stmt <<-eof
53
53
  def method; end # comment
54
54
  eof
55
- s.comments.should == "comment"
56
- s.comments_range.should == (1..1)
55
+ expect(s.comments).to eq "comment"
56
+ expect(s.comments_range).to eq (1..1)
57
57
  end
58
58
 
59
- it "should only look up to two lines back for comments" do
59
+ it "only looks up to two lines back for comments" do
60
60
  s = stmts <<-eof
61
61
  # comments
62
62
 
@@ -64,7 +64,7 @@ describe YARD::Parser::Ruby::RubyParser do
64
64
 
65
65
  def method; end
66
66
  eof
67
- s[1].comments.should == "comments"
67
+ expect(s[1].comments).to eq "comments"
68
68
 
69
69
  s = stmts <<-eof
70
70
  # comments
@@ -72,7 +72,7 @@ describe YARD::Parser::Ruby::RubyParser do
72
72
 
73
73
  def method; end
74
74
  eof
75
- s[1].comments.should == nil
75
+ expect(s[1].comments).to eq nil
76
76
 
77
77
  ss = stmts <<-eof
78
78
  # comments
@@ -83,11 +83,11 @@ describe YARD::Parser::Ruby::RubyParser do
83
83
  # hello
84
84
  def method2; end
85
85
  eof
86
- ss[1].comments.should == nil
87
- ss[2].comments.should == 'hello'
86
+ expect(ss[1].comments).to eq nil
87
+ expect(ss[2].comments).to eq 'hello'
88
88
  end
89
89
 
90
- it "should handle block comment followed by line comment" do
90
+ it "handles block comment followed by line comment" do
91
91
  ss = stmts <<-eof
92
92
  # comments1
93
93
 
@@ -97,10 +97,10 @@ comments2
97
97
  # comments3
98
98
  def hello; end
99
99
  eof
100
- ss.last.comments.should == "comments3"
100
+ expect(ss.last.comments).to eq "comments3"
101
101
  end
102
102
 
103
- it "should handle block comment followed by block comment" do
103
+ it "handles block comment followed by block comment" do
104
104
  ss = stmts <<-eof
105
105
  =begin
106
106
  comments1
@@ -110,222 +110,222 @@ comments2
110
110
  =end
111
111
  def hello; end
112
112
  eof
113
- ss.last.comments.strip.should == "comments2"
113
+ expect(ss.last.comments.strip).to eq "comments2"
114
114
  end
115
115
 
116
- it "should handle 1.9 lambda syntax with args" do
116
+ it "handles 1.9 lambda syntax with args" do
117
117
  src = "->(a,b,c=1,*args,&block) { hello_world }"
118
- stmt(src).source.should == src
118
+ expect(stmt(src).source).to eq src
119
119
  end
120
120
 
121
- it "should handle 1.9 lambda syntax" do
121
+ it "handles 1.9 lambda syntax" do
122
122
  src = "-> { hello_world }"
123
- stmt(src).source.should == src
123
+ expect(stmt(src).source).to eq src
124
124
  end
125
125
 
126
- it "should handle standard lambda syntax" do
126
+ it "handles standard lambda syntax" do
127
127
  src = "lambda { hello_world }"
128
- stmt(src).source.should == src
128
+ expect(stmt(src).source).to eq src
129
129
  end
130
130
 
131
- it "should throw a ParserSyntaxError on invalid code" do
132
- lambda { stmt("Foo, bar.") }.should raise_error(YARD::Parser::ParserSyntaxError)
131
+ it "throws a ParserSyntaxError on invalid code" do
132
+ expect { stmt("Foo, bar.") }.to raise_error(YARD::Parser::ParserSyntaxError)
133
133
  end
134
134
 
135
- it "should handle bare hashes as method parameters" do
135
+ it "handles bare hashes as method parameters" do
136
136
  src = "command :a => 1, :b => 2, :c => 3"
137
- stmt(src).jump(:command)[1].source.should == ":a => 1, :b => 2, :c => 3"
137
+ expect(stmt(src).jump(:command)[1].source).to eq ":a => 1, :b => 2, :c => 3"
138
138
 
139
139
  src = "command a: 1, b: 2, c: 3"
140
- stmt(src).jump(:command)[1].source.should == "a: 1, b: 2, c: 3"
140
+ expect(stmt(src).jump(:command)[1].source).to eq "a: 1, b: 2, c: 3"
141
141
  end
142
142
 
143
- it "should handle source for hash syntax" do
143
+ it "handles source for hash syntax" do
144
144
  src = "{ :a => 1, :b => 2, :c => 3 }"
145
- stmt(src).jump(:hash).source.should == "{ :a => 1, :b => 2, :c => 3 }"
145
+ expect(stmt(src).jump(:hash).source).to eq "{ :a => 1, :b => 2, :c => 3 }"
146
146
  end
147
147
 
148
- it "should handle an empty hash" do
149
- stmt("{}").jump(:hash).source.should == "{}"
148
+ it "handles an empty hash" do
149
+ expect(stmt("{}").jump(:hash).source).to eq "{}"
150
150
  end
151
151
 
152
152
  it "new hash label syntax should show label without colon" do
153
153
  ast = stmt("{ a: 1 }").jump(:label)
154
- ast[0].should == "a"
155
- ast.source.should == "a:"
154
+ expect(ast[0]).to eq "a"
155
+ expect(ast.source).to eq "a:"
156
156
  end
157
157
 
158
- it "should handle begin/rescue blocks" do
158
+ it "handles begin/rescue blocks" do
159
159
  ast = stmt("begin; X; rescue => e; Y end").jump(:rescue)
160
- ast.source.should == "rescue => e; Y end"
160
+ expect(ast.source).to eq "rescue => e; Y end"
161
161
 
162
162
  ast = stmt("begin; X; rescue A => e; Y end").jump(:rescue)
163
- ast.source.should == "rescue A => e; Y end"
163
+ expect(ast.source).to eq "rescue A => e; Y end"
164
164
 
165
165
  ast = stmt("begin; X; rescue A, B => e; Y end").jump(:rescue)
166
- ast.source.should == "rescue A, B => e; Y end"
166
+ expect(ast.source).to eq "rescue A, B => e; Y end"
167
167
  end
168
168
 
169
- it "should handle method rescue blocks" do
169
+ it "handles method rescue blocks" do
170
170
  ast = stmt("def x; A; rescue Y; B end")
171
- ast.source.should == "def x; A; rescue Y; B end"
172
- ast.jump(:rescue).source.should == "rescue Y; B end"
171
+ expect(ast.source).to eq "def x; A; rescue Y; B end"
172
+ expect(ast.jump(:rescue).source).to eq "rescue Y; B end"
173
173
  end
174
174
 
175
- it "should handle defs with keywords as method name" do
175
+ it "handles defs with keywords as method name" do
176
176
  ast = stmt("# docstring\nclass A;\ndef class; end\nend")
177
- ast.jump(:class).docstring.should == "docstring"
178
- ast.jump(:class).line_range.should == (2..4)
177
+ expect(ast.jump(:class).docstring).to eq "docstring"
178
+ expect(ast.jump(:class).line_range).to eq (2..4)
179
179
  end
180
180
 
181
- it 'should handle defs with unnamed argument with default values' do
181
+ it "handles defs with unnamed argument with default values" do
182
182
  ast = stmt('def hello(one, two = 2, three = 3) end').jump(:params)
183
- ast.source.should == 'one, two = 2, three = 3'
183
+ expect(ast.source).to eq 'one, two = 2, three = 3'
184
184
  end
185
185
 
186
- it 'should handle defs with splats' do
186
+ it "handles defs with splats" do
187
187
  ast = stmt('def hello(one, *two) end').jump(:params)
188
- ast.source.should == 'one, *two'
188
+ expect(ast.source).to eq 'one, *two'
189
189
  end
190
190
 
191
191
  if YARD.ruby2?
192
- it 'should handle defs with named arguments with default values' do
192
+ it "handles defs with named arguments with default values" do
193
193
  ast = stmt('def hello(one, two: 2, three: 3) end').jump(:params)
194
- ast.source.should == 'one, two: 2, three: 3'
194
+ expect(ast.source).to eq 'one, two: 2, three: 3'
195
195
  end
196
196
  end
197
197
 
198
198
  if NAMED_OPTIONAL_ARGUMENTS
199
- it 'should handle defs with named arguments without default values' do
199
+ it "handles defs with named arguments without default values" do
200
200
  ast = stmt('def hello(one, two:, three:) end').jump(:params)
201
- ast.source.should == 'one, two:, three:'
201
+ expect(ast.source).to eq 'one, two:, three:'
202
202
  end
203
203
 
204
- it 'should handle defs with double splats' do
204
+ it "handles defs with double splats" do
205
205
  ast = stmt('def hello(one, **two) end').jump(:params)
206
- ast.source.should == 'one, **two'
206
+ expect(ast.source).to eq 'one, **two'
207
207
  end
208
208
  end
209
209
 
210
- it "should end source properly on array reference" do
210
+ it "ends source properly on array reference" do
211
211
  ast = stmt("AS[0, 1 ] ")
212
- ast.source.should == 'AS[0, 1 ]'
212
+ expect(ast.source).to eq 'AS[0, 1 ]'
213
213
 
214
214
  ast = stmt('def x(a = S[1]) end').jump(:params)
215
- ast.source.should == 'a = S[1]'
215
+ expect(ast.source).to eq 'a = S[1]'
216
216
  end
217
217
 
218
- it "should end source properly on if/unless mod" do
218
+ it "ends source properly on if/unless mod" do
219
219
  %w(if unless while).each do |mod|
220
- stmt("A=1 #{mod} true").source.should == "A=1 #{mod} true"
220
+ expect(stmt("A=1 #{mod} true").source).to eq "A=1 #{mod} true"
221
221
  end
222
222
  end
223
223
 
224
- it "should show proper source for assignment" do
225
- stmt("A=1").jump(:assign).source.should == "A=1"
224
+ it "shows proper source for assignment" do
225
+ expect(stmt("A=1").jump(:assign).source).to eq "A=1"
226
226
  end
227
227
 
228
- it "should show proper source for a top_const_ref" do
228
+ it "shows proper source for a top_const_ref" do
229
229
  s = stmt("::\nFoo::Bar")
230
- s.jump(:top_const_ref).source.should == "::\nFoo"
231
- s.should be_ref
232
- s.jump(:top_const_ref).should be_ref
233
- s.source.should == "::\nFoo::Bar"
234
- s.line_range.to_a.should == [1, 2]
230
+ expect(s.jump(:top_const_ref).source).to eq "::\nFoo"
231
+ expect(s).to be_ref
232
+ expect(s.jump(:top_const_ref)).to be_ref
233
+ expect(s.source).to eq "::\nFoo::Bar"
234
+ expect(s.line_range.to_a).to eq [1, 2]
235
235
  end
236
236
 
237
- it "should show proper source for inline heredoc" do
237
+ it "shows proper source for inline heredoc" do
238
238
  src = "def foo\n foo(<<-XML, 1, 2)\n bar\n\n XML\nend"
239
239
  s = stmt(src)
240
240
  t = tokenize(src)
241
- s.source.should == src
242
- t.map {|x| x[1] }.join.should == src
241
+ expect(s.source).to eq src
242
+ expect(t.map { |x| x[1] }.join).to eq src
243
243
  end
244
244
 
245
- it "should show proper source for regular heredoc" do
245
+ it "shows proper source for regular heredoc" do
246
246
  src = "def foo\n x = <<-XML\n Hello \#{name}!\n Bye!\n XML\nend"
247
247
  s = stmt(src)
248
248
  t = tokenize(src)
249
- s.source.should == src
250
- t.map {|x| x[1] }.join.should == src
249
+ expect(s.source).to eq src
250
+ expect(t.map { |x| x[1] }.join).to eq src
251
251
  end
252
252
 
253
- it "should show proper source for heredoc with comment" do
253
+ it "shows proper source for heredoc with comment" do
254
254
  src = "def foo\n x = <<-XML # HI!\n Hello \#{name}!\n Bye!\n XML\nend"
255
255
  s = stmt(src)
256
256
  t = tokenize(src)
257
- s.source.should == src
258
- t.map {|x| x[1] }.join.should == src
257
+ expect(s.source).to eq src
258
+ expect(t.map {|x| x[1] }.join).to eq src
259
259
  end
260
260
 
261
- it "should show proper source for string" do
261
+ it "shows proper source for string" do
262
262
  ["'", '"'].each do |q|
263
263
  src = "#{q}hello\n\nworld#{q}"
264
264
  s = stmt(src)
265
- s.jump(:string_content).source.should == "hello\n\nworld"
266
- s.source.should == src
265
+ expect(s.jump(:string_content).source).to eq "hello\n\nworld"
266
+ expect(s.source).to eq src
267
267
  end
268
268
 
269
269
  src = '("this is a string")'
270
- stmt(src).jump(:string_literal).source.should == '"this is a string"'
270
+ expect(stmt(src).jump(:string_literal).source).to eq '"this is a string"'
271
271
  end
272
272
 
273
- it "should show proper source for %w() array" do
273
+ it "shows proper source for %w() array" do
274
274
  src = "%w(\na b c\n d e f\n)"
275
- stmt(src).jump(:qwords_literal).source.should == src
275
+ expect(stmt(src).jump(:qwords_literal).source).to eq src
276
276
  end
277
277
 
278
- it "should show proper source for %w{} array" do
278
+ it "shows proper source for %w{} array" do
279
279
  src = "%w{\na b c\n d e f\n}"
280
- stmt(src).jump(:array).source.should == src
280
+ expect(stmt(src).jump(:array).source).to eq src
281
281
  end
282
282
 
283
- it "should parse %w() array in constant declaration" do
283
+ it "parses %w() array in constant declaration" do
284
284
  s = stmt(<<-eof)
285
285
  class Foo
286
286
  FOO = %w( foo bar )
287
287
  end
288
288
  eof
289
- s.jump(:qwords_literal).source.should == '%w( foo bar )'
289
+ expect(s.jump(:qwords_literal).source).to eq '%w( foo bar )'
290
290
  if RUBY_VERSION >= '1.9.3' # ripper fix: array node encapsulates qwords
291
- s.jump(:array).source.should == '%w( foo bar )'
291
+ expect(s.jump(:array).source).to eq '%w( foo bar )'
292
292
  end
293
293
  end
294
294
 
295
- it "should parse %w() array source in object[] parsed context" do
295
+ it "parses %w() array source in object[] parsed context" do
296
296
  s = stmts(<<-eof)
297
297
  {}[:key]
298
298
  FOO = %w( foo bar )
299
299
  eof
300
- s[1].jump(:array).source.should == '%w( foo bar )'
300
+ expect(s[1].jump(:array).source).to eq '%w( foo bar )'
301
301
  end
302
302
 
303
- it "should parse %w() array source in object[]= parsed context" do
303
+ it "parses %w() array source in object[]= parsed context" do
304
304
  s = stmts(<<-eof)
305
305
  {}[:key] = :value
306
306
  FOO = %w( foo bar )
307
307
  eof
308
- s[1].jump(:array).source.should == '%w( foo bar )'
308
+ expect(s[1].jump(:array).source).to eq '%w( foo bar )'
309
309
  end
310
310
 
311
- it "should parse [] as array" do
311
+ it "parses [] as array" do
312
312
  s = stmt(<<-eof)
313
313
  class Foo
314
314
  FOO = ['foo', 'bar']
315
315
  end
316
316
  eof
317
- s.jump(:array).source.should == "['foo', 'bar']"
317
+ expect(s.jump(:array).source).to eq "['foo', 'bar']"
318
318
  end
319
319
 
320
- it "should show source for unary minus" do
321
- stmt("X = - 1").jump(:unary).source.should == '- 1'
320
+ it "shows source for unary minus" do
321
+ expect(stmt("X = - 1").jump(:unary).source).to eq '- 1'
322
322
  end
323
323
 
324
- it "should show source for unary exclamation" do
325
- stmt("X = !1").jump(:unary).source.should == '!1'
324
+ it "shows source for unary exclamation" do
325
+ expect(stmt("X = !1").jump(:unary).source).to eq '!1'
326
326
  end
327
327
 
328
- it "should have the correct line range for class/modules" do
328
+ it "has the correct line range for class/modules" do
329
329
  s = stmt(<<-eof)
330
330
  class Foo
331
331
  def foo; end
@@ -335,10 +335,20 @@ eof
335
335
  # Ending comment
336
336
  end
337
337
  eof
338
- s.jump(:class).line_range.should == (1..7)
338
+ expect(s.jump(:class).line_range).to eq (1..7)
339
339
  end
340
340
 
341
- it "should find lone comments" do
341
+ it "has the correct line range for blocks" do
342
+ Registry.clear
343
+ ast = YARD.parse_string(<<-eof).enumerator
344
+ module A
345
+ some_method
346
+ end
347
+ eof
348
+ expect(ast.first.block.source.strip).to eq "some_method"
349
+ end
350
+
351
+ it "finds lone comments" do
342
352
  Registry.clear
343
353
  ast = YARD.parse_string(<<-eof).enumerator
344
354
  class Foo
@@ -351,16 +361,16 @@ eof
351
361
  # end comment
352
362
  end
353
363
  eof
354
- comment = ast.first.last.first
355
- comment.type.should == :comment
356
- comment.docstring_hash_flag.should be_true
357
- comment.docstring.strip.should == "comment here"
364
+ comment = ast.first.last.jump(:comment)
365
+ expect(comment.type).to eq :comment
366
+ expect(comment.docstring_hash_flag).to be true
367
+ expect(comment.docstring.strip).to eq "comment here"
358
368
 
359
- ast.first.last.last.type.should == :comment
360
- ast.first.last.last.docstring.should == "end comment"
369
+ expect(ast.first.last.last.type).to eq :comment
370
+ expect(ast.first.last.last.docstring).to eq "end comment"
361
371
  end
362
372
 
363
- it "should not group comments if they don't begin the line" do
373
+ it "does not group comments if they don't begin the line" do
364
374
  Registry.clear
365
375
  ast = YARD.parse_string(<<-eof).enumerator
366
376
  class Foo
@@ -368,8 +378,8 @@ eof
368
378
  CONST2 = 2 # Another comment here
369
379
  end
370
380
  eof
371
- Registry.at("Foo::CONST1").docstring.should == "Comment here"
372
- Registry.at("Foo::CONST2").docstring.should == "Another comment here"
381
+ expect(Registry.at("Foo::CONST1").docstring).to eq "Comment here"
382
+ expect(Registry.at("Foo::CONST2").docstring).to eq "Another comment here"
373
383
  end
374
384
  end
375
385
  end if HAVE_RIPPER