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
@@ -6,24 +6,24 @@ include YARD::Parser::Ruby
6
6
 
7
7
  describe YARD::Parser::Ruby::AstNode do
8
8
  describe "#jump" do
9
- it "should jump to the first specific inner node if found" do
9
+ it "jumps to the first specific inner node if found" do
10
10
  ast = s(:paren, s(:paren, s(:params, s(s(:ident, "hi"), s(:ident, "bye")))))
11
- ast.jump(:params)[0][0].type.should equal(:ident)
11
+ expect(ast.jump(:params)[0][0].type).to equal(:ident)
12
12
  end
13
13
 
14
- it "should return the original ast if no inner node is found" do
14
+ it "returns the original ast if no inner node is found" do
15
15
  ast = s(:paren, s(:list, s(:list, s(s(:ident, "hi"), s(:ident, "bye")))))
16
- ast.jump(:params).object_id.should == ast.object_id
16
+ expect(ast.jump(:params).object_id).to eq ast.object_id
17
17
  end
18
18
  end
19
19
 
20
- describe '#pretty_print' do
21
- it "should show a list of nodes" do
20
+ describe "#pretty_print" do
21
+ it "shows a list of nodes" do
22
22
  obj = YARD::Parser::Ruby::RubyParser.parse("# x\nbye", "x").ast
23
23
  out = StringIO.new
24
24
  PP.pp(obj, out)
25
25
  vcall = RUBY_VERSION >= '1.9.3' ? 'vcall' : 'var_ref'
26
- out.string.should == "s(s(:#{vcall},\n" +
26
+ expect(out.string).to eq "s(s(:#{vcall},\n" +
27
27
  " s(:ident, \"bye\", line: 2..2, source: 4..6),\n" +
28
28
  " docstring: \"x\",\n" +
29
29
  " line: 2..2,\n" +
@@ -4,7 +4,7 @@ describe YARD::Parser::Ruby::Legacy::StatementList do
4
4
  def stmts(code) YARD::Parser::Ruby::Legacy::StatementList.new(code) end
5
5
  def stmt(code) stmts(code).first end
6
6
 
7
- it "should parse dangling block expressions" do
7
+ it "parses dangling block expressions" do
8
8
  s = stmt <<-eof
9
9
  if
10
10
  foo
@@ -12,9 +12,9 @@ describe YARD::Parser::Ruby::Legacy::StatementList do
12
12
  end
13
13
  eof
14
14
 
15
- s.tokens.to_s(true).should == "if\n foo\n ...\n end"
16
- s.tokens.to_s.should == "if\n foo"
17
- s.block.to_s.should == "puts 'hi'"
15
+ expect(s.tokens.to_s(true)).to eq "if\n foo\n ...\n end"
16
+ expect(s.tokens.to_s).to eq "if\n foo"
17
+ expect(s.block.to_s).to eq "puts 'hi'"
18
18
 
19
19
  s = stmt <<-eof
20
20
  if foo ||
@@ -23,152 +23,152 @@ eof
23
23
  end
24
24
  eof
25
25
 
26
- s.tokens.to_s(true).should == "if foo ||\n bar\n ...\n end"
27
- s.tokens.to_s.should == "if foo ||\n bar"
28
- s.block.to_s.should == "puts 'hi'"
26
+ expect(s.tokens.to_s(true)).to eq "if foo ||\n bar\n ...\n end"
27
+ expect(s.tokens.to_s).to eq "if foo ||\n bar"
28
+ expect(s.block.to_s).to eq "puts 'hi'"
29
29
  end
30
30
 
31
- it "should allow semicolons within parentheses" do
31
+ it "allows semicolons within parentheses" do
32
32
  s = stmt "(foo; bar)"
33
33
 
34
- s.tokens.to_s(true).should == "(foo; bar)"
35
- s.block.should be_nil
34
+ expect(s.tokens.to_s(true)).to eq "(foo; bar)"
35
+ expect(s.block).to be nil
36
36
  end
37
37
 
38
- it "should allow for non-block statements" do
38
+ it "allows for non-block statements" do
39
39
  s = stmt "hello_world(1, 2, 3)"
40
- s.tokens.to_s.should == "hello_world(1, 2, 3)"
41
- s.block.should be_nil
40
+ expect(s.tokens.to_s).to eq "hello_world(1, 2, 3)"
41
+ expect(s.block).to be nil
42
42
  end
43
43
 
44
- it "should allow block statements to be used as part of other block statements" do
44
+ it "allows block statements to be used as part of other block statements" do
45
45
  s = stmt "while (foo; bar); foo = 12; end; while"
46
46
 
47
- s.tokens.to_s(true).should == "while (foo; bar); ... end"
48
- s.tokens.to_s.should == "while (foo; bar)"
49
- s.block.to_s.should == "foo = 12"
47
+ expect(s.tokens.to_s(true)).to eq "while (foo; bar); ... end"
48
+ expect(s.tokens.to_s).to eq "while (foo; bar)"
49
+ expect(s.block.to_s).to eq "foo = 12"
50
50
  end
51
51
 
52
- it "should allow continued processing after a block" do
52
+ it "allows continued processing after a block" do
53
53
  s = stmt "if foo; end.stuff"
54
- s.tokens.to_s(true).should == "if foo; end.stuff"
55
- s.block.to_s.should == ""
54
+ expect(s.tokens.to_s(true)).to eq "if foo; end.stuff"
55
+ expect(s.block.to_s).to eq ""
56
56
 
57
57
  s = stmt "if foo; end[stuff]"
58
- s.tokens.to_s(true).should == "if foo; end[stuff]"
59
- s.block.to_s.should == ""
58
+ expect(s.tokens.to_s(true)).to eq "if foo; end[stuff]"
59
+ expect(s.block.to_s).to eq ""
60
60
 
61
61
  s = stmt "if foo; hi end.map do; 123; end"
62
- s.tokens.to_s(true).should == "if foo; ... end.map do; 123; end"
63
- s.block.to_s.should == "hi"
62
+ expect(s.tokens.to_s(true)).to eq "if foo; ... end.map do; 123; end"
63
+ expect(s.block.to_s).to eq "hi"
64
64
  end
65
65
 
66
- it "should parse default arguments" do
66
+ it "parses default arguments" do
67
67
  s = stmt "def foo(bar, baz = 1, bang = 2); bar; end"
68
- s.tokens.to_s(true).should == "def foo(bar, baz = 1, bang = 2) ... end"
69
- s.block.to_s.should == "bar"
68
+ expect(s.tokens.to_s(true)).to eq "def foo(bar, baz = 1, bang = 2) ... end"
69
+ expect(s.block.to_s).to eq "bar"
70
70
 
71
71
  s = stmt "def foo bar, baz = 1, bang = 2; bar; end"
72
- s.tokens.to_s(true).should == "def foo bar, baz = 1, bang = 2; ... end"
73
- s.block.to_s.should == "bar"
72
+ expect(s.tokens.to_s(true)).to eq "def foo bar, baz = 1, bang = 2; ... end"
73
+ expect(s.block.to_s).to eq "bar"
74
74
 
75
75
  s = stmt "def foo bar , baz = 1 , bang = 2; bar; end"
76
- s.tokens.to_s(true).should == "def foo bar , baz = 1 , bang = 2; ... end"
77
- s.block.to_s.should == "bar"
76
+ expect(s.tokens.to_s(true)).to eq "def foo bar , baz = 1 , bang = 2; ... end"
77
+ expect(s.block.to_s).to eq "bar"
78
78
  end
79
79
 
80
- it "should parse complex default arguments" do
80
+ it "parses complex default arguments" do
81
81
  s = stmt "def foo(bar, baz = File.new(1, 2), bang = 3); bar; end"
82
- s.tokens.to_s(true).should == "def foo(bar, baz = File.new(1, 2), bang = 3) ... end"
83
- s.block.to_s.should == "bar"
82
+ expect(s.tokens.to_s(true)).to eq "def foo(bar, baz = File.new(1, 2), bang = 3) ... end"
83
+ expect(s.block.to_s).to eq "bar"
84
84
 
85
85
  s = stmt "def foo bar, baz = File.new(1, 2), bang = 3; bar; end"
86
- s.tokens.to_s(true).should == "def foo bar, baz = File.new(1, 2), bang = 3; ... end"
87
- s.block.to_s.should == "bar"
86
+ expect(s.tokens.to_s(true)).to eq "def foo bar, baz = File.new(1, 2), bang = 3; ... end"
87
+ expect(s.block.to_s).to eq "bar"
88
88
 
89
89
  s = stmt "def foo bar , baz = File.new(1, 2) , bang = 3; bar; end"
90
- s.tokens.to_s(true).should == "def foo bar , baz = File.new(1, 2) , bang = 3; ... end"
91
- s.block.to_s.should == "bar"
90
+ expect(s.tokens.to_s(true)).to eq "def foo bar , baz = File.new(1, 2) , bang = 3; ... end"
91
+ expect(s.block.to_s).to eq "bar"
92
92
  end
93
93
 
94
- it "should parse blocks with do/end" do
94
+ it "parses blocks with do/end" do
95
95
  s = stmt <<-eof
96
96
  foo do
97
97
  puts 'hi'
98
98
  end
99
99
  eof
100
100
 
101
- s.tokens.to_s(true).should == "foo do\n ...\n end"
102
- s.block.to_s.should == "puts 'hi'"
101
+ expect(s.tokens.to_s(true)).to eq "foo do\n ...\n end"
102
+ expect(s.block.to_s).to eq "puts 'hi'"
103
103
  end
104
104
 
105
- it "should parse blocks with {}" do
105
+ it "parses blocks with {}" do
106
106
  s = stmt "x { y }"
107
- s.tokens.to_s(true).should == "x { ... }"
108
- s.block.to_s.should == "y"
107
+ expect(s.tokens.to_s(true)).to eq "x { ... }"
108
+ expect(s.block.to_s).to eq "y"
109
109
 
110
110
  s = stmt "x() { y }"
111
- s.tokens.to_s(true).should == "x() { ... }"
112
- s.block.to_s.should == "y"
111
+ expect(s.tokens.to_s(true)).to eq "x() { ... }"
112
+ expect(s.block.to_s).to eq "y"
113
113
  end
114
114
 
115
- it "should parse blocks with begin/end" do
115
+ it "parses blocks with begin/end" do
116
116
  s = stmt "begin xyz end"
117
- s.tokens.to_s(true).should == "begin ... end"
118
- s.block.to_s.should == "xyz"
117
+ expect(s.tokens.to_s(true)).to eq "begin ... end"
118
+ expect(s.block.to_s).to eq "xyz"
119
119
  end
120
120
 
121
- it "should parse nested blocks" do
121
+ it "parses nested blocks" do
122
122
  s = stmt "foo(:x) { baz(:y) { skippy } }"
123
123
 
124
- s.tokens.to_s(true).should == "foo(:x) { ... }"
125
- s.block.to_s.should == "baz(:y) { skippy }"
124
+ expect(s.tokens.to_s(true)).to eq "foo(:x) { ... }"
125
+ expect(s.block.to_s).to eq "baz(:y) { skippy }"
126
126
  end
127
127
 
128
- it "should not parse hashes as blocks" do
128
+ it "does not parse hashes as blocks" do
129
129
  s = stmt "x({})"
130
- s.tokens.to_s(true).should == "x({})"
131
- s.block.to_s.should == ""
130
+ expect(s.tokens.to_s(true)).to eq "x({})"
131
+ expect(s.block.to_s).to eq ""
132
132
 
133
133
  s = stmt "x = {}"
134
- s.tokens.to_s(true).should == "x = {}"
135
- s.block.to_s.should == ""
134
+ expect(s.tokens.to_s(true)).to eq "x = {}"
135
+ expect(s.block.to_s).to eq ""
136
136
 
137
137
  s = stmt "x(y, {})"
138
- s.tokens.to_s(true).should == "x(y, {})"
139
- s.block.to_s.should == ""
138
+ expect(s.tokens.to_s(true)).to eq "x(y, {})"
139
+ expect(s.block.to_s).to eq ""
140
140
  end
141
141
 
142
- it "should parse hashes in blocks with {}" do
142
+ it "parses hashes in blocks with {}" do
143
143
  s = stmt "x {x = {}}"
144
144
 
145
- s.tokens.to_s(true).should == "x {...}"
146
- s.block.to_s.should == "x = {}"
145
+ expect(s.tokens.to_s(true)).to eq "x {...}"
146
+ expect(s.block.to_s).to eq "x = {}"
147
147
  end
148
148
 
149
- it "should parse blocks with {} in hashes" do
149
+ it "parses blocks with {} in hashes" do
150
150
  s = stmt "[:foo, x {}]"
151
151
 
152
- s.tokens.to_s(true).should == "[:foo, x {}]"
153
- s.block.to_s.should == ""
152
+ expect(s.tokens.to_s(true)).to eq "[:foo, x {}]"
153
+ expect(s.block.to_s).to eq ""
154
154
  end
155
155
 
156
- it "should handle multiple methods" do
156
+ it "handles multiple methods" do
157
157
  s = stmt <<-eof
158
158
  def %; end
159
159
  def b; end
160
160
  eof
161
- s.to_s.should == "def %; end"
161
+ expect(s.to_s).to eq "def %; end"
162
162
  end
163
163
 
164
- it "should handle nested methods" do
164
+ it "handles nested methods" do
165
165
  s = stmt <<-eof
166
166
  def *(o) def +@; end
167
167
  def ~@
168
168
  end end
169
169
  eof
170
- s.tokens.to_s(true).should == "def *(o) ... end"
171
- s.block.to_s.should == "def +@; end\n def ~@\n end"
170
+ expect(s.tokens.to_s(true)).to eq "def *(o) ... end"
171
+ expect(s.block.to_s).to eq "def +@; end\n def ~@\n end"
172
172
 
173
173
  s = stmts(<<-eof)
174
174
  def /(other) 'hi' end
@@ -176,18 +176,18 @@ eof
176
176
  def dynamic; end
177
177
  end
178
178
  eof
179
- s[1].to_s.should == "def method1\n def dynamic; end\n end"
179
+ expect(s[1].to_s).to eq "def method1\n def dynamic; end\n end"
180
180
  end
181
181
 
182
- it "should get comment line numbers" do
182
+ it "gets comment line numbers" do
183
183
  s = stmt <<-eof
184
184
  # comment
185
185
  # comment
186
186
  # comment
187
187
  def method; end
188
188
  eof
189
- s.comments.should == ["comment", "comment", "comment"]
190
- s.comments_range.should == (1..3)
189
+ expect(s.comments).to eq ["comment", "comment", "comment"]
190
+ expect(s.comments_range).to eq (1..3)
191
191
 
192
192
  s = stmt <<-eof
193
193
 
@@ -195,8 +195,8 @@ eof
195
195
  # comment
196
196
  def method; end
197
197
  eof
198
- s.comments.should == ["comment", "comment"]
199
- s.comments_range.should == (2..3)
198
+ expect(s.comments).to eq ["comment", "comment"]
199
+ expect(s.comments_range).to eq (2..3)
200
200
 
201
201
  s = stmt <<-eof
202
202
  # comment
@@ -204,24 +204,24 @@ eof
204
204
 
205
205
  def method; end
206
206
  eof
207
- s.comments.should == ["comment", "comment"]
208
- s.comments_range.should == (1..2)
207
+ expect(s.comments).to eq ["comment", "comment"]
208
+ expect(s.comments_range).to eq (1..2)
209
209
 
210
210
  s = stmt <<-eof
211
211
  # comment
212
212
  def method; end
213
213
  eof
214
- s.comments.should == ["comment"]
215
- s.comments_range.should == (1..1)
214
+ expect(s.comments).to eq ["comment"]
215
+ expect(s.comments_range).to eq (1..1)
216
216
 
217
217
  s = stmt <<-eof
218
218
  def method; end # comment
219
219
  eof
220
- s.comments.should == ["comment"]
221
- s.comments_range.should == (1..1)
220
+ expect(s.comments).to eq ["comment"]
221
+ expect(s.comments_range).to eq (1..1)
222
222
  end
223
223
 
224
- it "should only look up to two lines back for comments" do
224
+ it "only looks up to two lines back for comments" do
225
225
  s = stmt <<-eof
226
226
  # comments
227
227
 
@@ -229,7 +229,7 @@ eof
229
229
 
230
230
  def method; end
231
231
  eof
232
- s.comments.should == ["comments"]
232
+ expect(s.comments).to eq ["comments"]
233
233
 
234
234
  s = stmt <<-eof
235
235
  # comments
@@ -237,7 +237,7 @@ eof
237
237
 
238
238
  def method; end
239
239
  eof
240
- s.comments.should == nil
240
+ expect(s.comments).to eq nil
241
241
 
242
242
  ss = stmts <<-eof
243
243
  # comments
@@ -248,52 +248,52 @@ eof
248
248
  # hello
249
249
  def method2; end
250
250
  eof
251
- ss[0].comments.should == nil
252
- ss[1].comments.should == ['hello']
251
+ expect(ss[0].comments).to eq nil
252
+ expect(ss[1].comments).to eq ['hello']
253
253
  end
254
254
 
255
- it "should handle CRLF (Windows) newlines" do
255
+ it "handles CRLF (Windows) newlines" do
256
256
  s = stmts("require 'foo'\r\n\r\n# Test Test\r\n# \r\n# Example:\r\n# example code\r\ndef test\r\nend\r\n")
257
- s[1].comments.should == ['Test Test', '', 'Example:', ' example code']
257
+ expect(s[1].comments).to eq ['Test Test', '', 'Example:', ' example code']
258
258
  end
259
259
 
260
- it "should handle elsif blocks" do
260
+ it "handles elsif blocks" do
261
261
  s = stmts(stmt("if 0\n foo\nelsif 2\n bar\nend\nbaz").block)
262
- s.size.should == 2
263
- s[1].tokens.to_s.should == "elsif 2"
264
- s[1].block.to_s.should == "bar"
262
+ expect(s.size).to eq 2
263
+ expect(s[1].tokens.to_s).to eq "elsif 2"
264
+ expect(s[1].block.to_s).to eq "bar"
265
265
  end
266
266
 
267
- it "should handle else blocks" do
267
+ it "handles else blocks" do
268
268
  s = stmts(stmt("if 0\n foo\nelse\n bar\nend\nbaz").block)
269
- s.size.should == 2
270
- s[1].tokens.to_s.should == "else"
271
- s[1].block.to_s.should == "bar"
269
+ expect(s.size).to eq 2
270
+ expect(s[1].tokens.to_s).to eq "else"
271
+ expect(s[1].block.to_s).to eq "bar"
272
272
  end
273
273
 
274
- it "should allow aliasing keywords" do
274
+ it "allows aliasing keywords" do
275
275
  ['do x', 'x do', 'end begin', 'begin end'].each do |a|
276
276
  s = stmt("alias #{a}\ndef foo; end")
277
- s.tokens.to_s.should == "alias #{a}"
278
- s.block.should be_nil
277
+ expect(s.tokens.to_s).to eq "alias #{a}"
278
+ expect(s.block).to be nil
279
279
  end
280
280
 
281
281
  s = stmt("alias do x if 2 ==\n 2")
282
- s.tokens.to_s.should == "alias do x if 2 ==\n 2"
282
+ expect(s.tokens.to_s).to eq "alias do x if 2 ==\n 2"
283
283
  end
284
284
 
285
- it "should not open a block on an aliased keyword block opener" do
285
+ it "does not open a block on an aliased keyword block opener" do
286
286
  s = stmts(<<-eof)
287
287
  class A; alias x do end
288
288
  class B; end
289
289
  eof
290
- s[0].block.to_s.should == 'alias x do'
291
- s.size.should > 1
290
+ expect(s[0].block.to_s).to eq 'alias x do'
291
+ expect(s.size).to be > 1
292
292
  end
293
293
 
294
- it "should convert heredoc to string" do
294
+ it "converts heredoc to string" do
295
295
  src = "<<-XML\n foo\n\nXML"
296
296
  s = stmt(src)
297
- s.source.should == '"foo\n\n"'
297
+ expect(s.source).to eq '"foo\n\n"'
298
298
  end
299
299
  end
@@ -5,45 +5,45 @@ include YARD::Parser::Ruby::Legacy::RubyToken
5
5
 
6
6
  describe YARD::Parser::Ruby::Legacy::TokenList do
7
7
  describe "#initialize / #push" do
8
- it "should accept a tokenlist (via constructor or push)" do
9
- lambda { TokenList.new(TokenList.new) }.should_not raise_error(ArgumentError)
10
- TokenList.new.push(TokenList.new("x = 2")).size.should == 6
8
+ it "accepts a tokenlist (via constructor or push)" do
9
+ expect { TokenList.new(TokenList.new) }.not_to raise_error
10
+ expect(TokenList.new.push(TokenList.new("x = 2")).size).to eq 6
11
11
  end
12
12
 
13
13
  it "accept a token (via constructor or push)" do
14
- lambda { TokenList.new(Token.new(0, 0)) }.should_not raise_error(ArgumentError)
15
- TokenList.new.push(Token.new(0, 0), Token.new(1, 1)).size.should == 2
14
+ expect { TokenList.new(Token.new(0, 0)) }.not_to raise_error
15
+ expect(TokenList.new.push(Token.new(0, 0), Token.new(1, 1)).size).to eq 2
16
16
  end
17
17
 
18
- it "should accept a string and parse it as code (via constructor or push)" do
19
- lambda { TokenList.new("x = 2") }.should_not raise_error(ArgumentError)
18
+ it "accepts a string and parse it as code (via constructor or push)" do
19
+ expect { TokenList.new("x = 2") }.not_to raise_error
20
20
  x = TokenList.new
21
21
  x.push("x", "=", "2")
22
- x.size.should == 6
23
- x.to_s.should == "x\n=\n2\n"
22
+ expect(x.size).to eq 6
23
+ expect(x.to_s).to eq "x\n=\n2\n"
24
24
  end
25
25
 
26
- it "should not accept any other input" do
27
- lambda { TokenList.new(:notcode) }.should raise_error(ArgumentError)
26
+ it "does not accept any other input" do
27
+ expect { TokenList.new(:notcode) }.to raise_error(ArgumentError)
28
28
  end
29
29
 
30
- it "should not interpolate string data" do
30
+ it "does not interpolate string data" do
31
31
  x = TokenList.new('x = "hello #{world}"')
32
- x.size.should == 6
33
- x[4].class.should == TkDSTRING
34
- x.to_s.should == 'x = "hello #{world}"' + "\n"
32
+ expect(x.size).to eq 6
33
+ expect(x[4].class).to eq TkDSTRING
34
+ expect(x.to_s).to eq 'x = "hello #{world}"' + "\n"
35
35
  end
36
36
 
37
- it 'handles label syntax' do
37
+ it "handles label syntax" do
38
38
  x = TokenList.new('a:1,b:2')
39
- x[0].class.should == TkLABEL
40
- x[0].text.should == 'a:'
41
- x[3].class.should == TkLABEL
42
- x[3].text.should == 'b:'
39
+ expect(x[0].class).to eq TkLABEL
40
+ expect(x[0].text).to eq 'a:'
41
+ expect(x[3].class).to eq TkLABEL
42
+ expect(x[3].text).to eq 'b:'
43
43
  end
44
44
  end
45
45
 
46
- describe '#to_s' do
46
+ describe "#to_s" do
47
47
  before do
48
48
  @t = TokenList.new
49
49
  @t << TkDEF.new(1, 1, "def")
@@ -62,16 +62,16 @@ describe YARD::Parser::Ruby::Legacy::TokenList do
62
62
  @t[8].set_text "end"
63
63
  end
64
64
 
65
- it "should only show the statement portion of the tokens by default" do
66
- @t.to_s.should == "def x"
65
+ it "only shows the statement portion of the tokens by default" do
66
+ expect(@t.to_s).to eq "def x"
67
67
  end
68
68
 
69
- it "should show ... for the block token if all of the tokens are shown" do
70
- @t.to_s(true).should == "def x; ... end"
69
+ it "shows ... for the block token if all of the tokens are shown" do
70
+ expect(@t.to_s(true)).to eq "def x; ... end"
71
71
  end
72
72
 
73
- it "should ignore ... if show_block = false" do
74
- @t.to_s(true, false).should == "def x; end"
73
+ it "ignores ... if show_block = false" do
74
+ expect(@t.to_s(true, false)).to eq "def x; end"
75
75
  end
76
76
  end
77
77
  end