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,32 +3,32 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ModuleHandler" do
4
4
  before(:all) { parse_file :module_handler_001, __FILE__ }
5
5
 
6
- it "should parse a module block" do
7
- Registry.at(:ModName).should_not == nil
8
- Registry.at("ModName::OtherModName").should_not == nil
6
+ it "parses a module block" do
7
+ expect(Registry.at(:ModName)).not_to eq nil
8
+ expect(Registry.at("ModName::OtherModName")).not_to eq nil
9
9
  end
10
10
 
11
- it "should attach docstring" do
12
- Registry.at("ModName::OtherModName").docstring.should == "Docstring"
11
+ it "attaches docstring" do
12
+ expect(Registry.at("ModName::OtherModName").docstring).to eq "Docstring"
13
13
  end
14
14
 
15
- it "should handle any formatting" do
16
- Registry.at(:StressTest).should_not == nil
15
+ it "handles any formatting" do
16
+ expect(Registry.at(:StressTest)).not_to eq nil
17
17
  end
18
18
 
19
- it "should handle complex module names" do
20
- Registry.at("A::B").should_not == nil
19
+ it "handles complex module names" do
20
+ expect(Registry.at("A::B")).not_to eq nil
21
21
  end
22
22
 
23
- it "should handle modules in the form ::ModName" do
24
- Registry.at("Kernel").should_not be_nil
23
+ it "handles modules in the form ::ModName" do
24
+ expect(Registry.at("Kernel")).not_to be nil
25
25
  end
26
26
 
27
- it "should list mixins in proper order" do
28
- Registry.at('D').mixins.should == [P(:C), P(:B), P(:A)]
27
+ it "lists mixins in proper order" do
28
+ expect(Registry.at('D').mixins).to eq [P(:C), P(:B), P(:A)]
29
29
  end
30
30
 
31
- it "should create proper module when constant is in namespace" do
32
- Registry.at('Q::FOO::A').should_not be_nil
31
+ it "creates proper module when constant is in namespace" do
32
+ expect(Registry.at('Q::FOO::A')).not_to be nil
33
33
  end
34
34
  end
@@ -1,54 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
+ require File.dirname(__FILE__) + '/class_method_handler_shared_examples'
2
3
 
3
4
  describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PrivateClassMethodHandler" do
4
- before(:all) { parse_file :private_class_method_handler_001, __FILE__ }
5
+ before { Registry.clear }
5
6
 
6
- it "should handle private_class_method statement" do
7
- Registry.at('A.c').visibility.should eq :private
8
- Registry.at('A.d').visibility.should eq :private
9
- Registry.at('A.e').visibility.should eq :private
10
- end
7
+ let(:visibility) { :private }
11
8
 
12
- it "should fail if parameter is not String or Symbol" do
13
- undoc_error 'class Foo; X = 1; private_class_method X.new("hi"); end'
14
- undoc_error 'class Foo; X = 1; private_class_method 123; end'
15
- end unless LEGACY_PARSER
16
-
17
- # Issue #760
18
- # https://github.com/lsegal/yard/issues/760
19
- it "should handle singleton classes" do
20
- # Note: It's important to def a method within the singleton class or
21
- # the bug may not trigger.
22
- code = 'class SingletonClass; private_class_method :new; def self.foo; "foo"end; end'
23
- StubbedSourceParser.parse_string(code) # Should be successful.
24
- end unless LEGACY_PARSER
25
-
26
-
27
- describe "should handle reopened class" do
28
-
29
- # Modified #parse_file from '/spec/spec_helper.rb' because the second example
30
- # file was overwriting the data from the first example when trying to reopen
31
- # the class.
32
- def parse_files(files, thisfile = __FILE__, log_level = log.level, ext = '.rb.txt')
33
- Registry.clear
34
- paths = files.map { |file| File.join(File.dirname(thisfile), 'examples', file.to_s + ext) }
35
- YARD::Parser::SourceParser.parse(paths, [], log_level)
36
- end
37
-
38
- before {
39
- parse_files [
40
- :private_class_method_handler_002,
41
- :private_class_method_handler_003
42
- ], __FILE__
43
- }
44
-
45
- specify do
46
- Registry.at('SingletonClass.foo').visibility.should eq :public
47
- Registry.at('SingletonClass.bar').visibility.should eq :private
48
- Registry.at('SingletonClass.baz').visibility.should eq :private
49
- Registry.at('SingletonClass.bat').visibility.should eq :public
50
- end
51
-
52
- end unless LEGACY_PARSER # reopened class
53
-
9
+ include_examples "class method visibility decorator"
54
10
  end
@@ -3,22 +3,22 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PrivateConstantHandler" do
4
4
  before(:all) { parse_file :private_constant_handler_001, __FILE__ }
5
5
 
6
- it "should handle private_constant statement" do
7
- Registry.at('A::Foo').visibility.should == :private
8
- Registry.at('A::B').visibility.should == :private
9
- Registry.at('A::C').visibility.should == :private
6
+ it "handles private_constant statement" do
7
+ expect(Registry.at('A::Foo').visibility).to eq :private
8
+ expect(Registry.at('A::B').visibility).to eq :private
9
+ expect(Registry.at('A::C').visibility).to eq :private
10
10
  end
11
11
 
12
- it "should make all other constants public" do
13
- Registry.at('A::D').visibility.should == :public
12
+ it "makes all other constants public" do
13
+ expect(Registry.at('A::D').visibility).to eq :public
14
14
  end
15
15
 
16
- it "should fail if parameter is not String, Symbol or Constant" do
16
+ it "fails if parameter is not String, Symbol or Constant" do
17
17
  undoc_error 'class Foo; private_constant x; end'
18
18
  undoc_error 'class Foo; X = 1; private_constant X.new("hi"); end'
19
19
  end unless LEGACY_PARSER
20
20
 
21
- it "should fail if constant can't be recognized" do
21
+ it "fails if constant can't be recognized" do
22
22
  undoc_error 'class Foo2; private_constant :X end'
23
23
  end
24
24
  end
@@ -5,30 +5,30 @@ describe YARD::Handlers::Processor do
5
5
  @proc = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby))
6
6
  end
7
7
 
8
- it "should start with public visibility" do
9
- @proc.visibility.should == :public
8
+ it "starts with public visibility" do
9
+ expect(@proc.visibility).to eq :public
10
10
  end
11
11
 
12
- it "should start in instance scope" do
13
- @proc.scope.should == :instance
12
+ it "starts in instance scope" do
13
+ expect(@proc.scope).to eq :instance
14
14
  end
15
15
 
16
- it "should start in root namespace" do
17
- @proc.namespace.should == Registry.root
16
+ it "starts in root namespace" do
17
+ expect(@proc.namespace).to eq Registry.root
18
18
  end
19
19
 
20
- it "should have a globals structure" do
21
- @proc.globals.should be_a(OpenStruct)
20
+ it "has a globals structure" do
21
+ expect(@proc.globals).to be_a(OpenStruct)
22
22
  end
23
23
 
24
- it 'should ignore HandlerAborted exceptions (but print debug info)' do
24
+ it "ignores HandlerAborted exceptions (but print debug info)" do
25
25
  class AbortHandlerProcessor < YARD::Handlers::Ruby::Base
26
26
  process { abort! }
27
27
  end
28
28
  stmt = OpenStruct.new(:line => 1, :show => 'SOURCE')
29
- @proc.stub!(:find_handlers).and_return([AbortHandlerProcessor])
30
- log.should_receive(:debug).with(/AbortHandlerProcessor cancelled from/)
31
- log.should_receive(:debug).with("\tin file '(stdin)':1:\n\nSOURCE\n")
29
+ allow(@proc).to receive(:find_handlers).and_return([AbortHandlerProcessor])
30
+ expect(log).to receive(:debug).with(/AbortHandlerProcessor cancelled from/)
31
+ expect(log).to receive(:debug).with("\tin file '(stdin)':1:\n\nSOURCE\n")
32
32
  @proc.process([stmt])
33
33
  end
34
34
  end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ require File.dirname(__FILE__) + '/class_method_handler_shared_examples'
3
+
4
+ describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PublicClassMethodHandler" do
5
+ before { Registry.clear }
6
+
7
+ let(:visibility) { :public }
8
+
9
+ include_examples "class method visibility decorator"
10
+ end
@@ -4,7 +4,7 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
4
4
  include YARD::Parser::Ruby; YARD::Parser::Ruby::AstNode
5
5
 
6
6
  before do
7
- Handlers::Ruby::Base.stub!(:inherited)
7
+ allow(Handlers::Ruby::Base).to receive(:inherited)
8
8
  @processor = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby))
9
9
  end
10
10
 
@@ -13,67 +13,67 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
13
13
  end
14
14
 
15
15
  def valid(handler, stmt)
16
- @processor.find_handlers(stmt).should include(handler)
16
+ expect(@processor.find_handlers(stmt)).to include(handler)
17
17
  end
18
18
 
19
19
  def invalid(handler, stmt)
20
- @processor.find_handlers(stmt).should_not include(handler)
20
+ expect(@processor.find_handlers(stmt)).not_to include(handler)
21
21
  end
22
22
 
23
- it "should only handle Handlers inherited from Ruby::Base class" do
23
+ it "only handles Handlers inherited from Ruby::Base class" do
24
24
  class IgnoredHandler < Handlers::Base
25
25
  handles :list
26
26
  end
27
27
  class NotIgnoredHandler < Handlers::Ruby::Base
28
28
  handles :list
29
29
  end
30
- Handlers::Base.stub!(:subclasses).and_return [IgnoredHandler, NotIgnoredHandler]
31
- @processor.find_handlers(s()).should == [NotIgnoredHandler]
30
+ allow(Handlers::Base).to receive(:subclasses).and_return [IgnoredHandler, NotIgnoredHandler]
31
+ expect(@processor.find_handlers(s())).to eq [NotIgnoredHandler]
32
32
  end
33
33
 
34
- it "should handle string input (matches AstNode#source)" do
34
+ it "handles string input (matches AstNode#source)" do
35
35
  class StringHandler < Handlers::Ruby::Base
36
36
  handles "x"
37
37
  end
38
- Handlers::Base.stub!(:subclasses).and_return [StringHandler]
38
+ allow(Handlers::Base).to receive(:subclasses).and_return [StringHandler]
39
39
  ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
40
40
  valid StringHandler, ast[0][0][0]
41
41
  invalid StringHandler, ast[0][1]
42
42
  end
43
43
 
44
- it "should handle symbol input (matches AstNode#type)" do
44
+ it "handles symbol input (matches AstNode#type)" do
45
45
  class SymbolHandler < Handlers::Ruby::Base
46
46
  handles :myNodeType
47
47
  end
48
- Handlers::Base.stub!(:subclasses).and_return [SymbolHandler]
48
+ allow(Handlers::Base).to receive(:subclasses).and_return [SymbolHandler]
49
49
  valid SymbolHandler, s(:myNodeType, s(1, 2, 3))
50
50
  invalid SymbolHandler, s(:NOTmyNodeType, s(1, 2, 3))
51
51
  end
52
52
 
53
- it "should handle regex input (matches AstNode#source)" do
53
+ it "handles regex input (matches AstNode#source)" do
54
54
  class RegexHandler < Handlers::Ruby::Base
55
55
  handles %r{^if x ==}
56
56
  end
57
- Handlers::Base.stub!(:subclasses).and_return [RegexHandler]
57
+ allow(Handlers::Base).to receive(:subclasses).and_return [RegexHandler]
58
58
  ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
59
59
  valid RegexHandler, ast
60
60
  invalid RegexHandler, ast[0][1]
61
61
  end
62
62
 
63
- it "should handle AstNode input (matches AST literally)" do
63
+ it "handles AstNode input (matches AST literally)" do
64
64
  class ASTHandler < Handlers::Ruby::Base
65
65
  handles s(:vcall, s(:ident, "hello_world"))
66
66
  end
67
- Handlers::Base.stub!(:subclasses).and_return [ASTHandler]
67
+ allow(Handlers::Base).to receive(:subclasses).and_return [ASTHandler]
68
68
  valid ASTHandler, s(:vcall, s(:ident, "hello_world"))
69
69
  invalid ASTHandler, s(:vcall, s(:ident, "NOTHELLOWORLD"))
70
70
  end
71
71
 
72
- it "should handle #method_call(:methname) on a valid AST" do
72
+ it "handles #method_call(:methname) on a valid AST" do
73
73
  class MethCallHandler < Handlers::Ruby::Base
74
74
  handles method_call(:meth)
75
75
  end
76
- Handlers::Base.stub!(:subclasses).and_return [MethCallHandler]
76
+ allow(Handlers::Base).to receive(:subclasses).and_return [MethCallHandler]
77
77
  ast = Parser::Ruby::RubyParser.parse(<<-"eof").ast
78
78
  meth # 0
79
79
  meth() # 1
@@ -4,8 +4,10 @@ include Parser::Ruby::Legacy
4
4
 
5
5
  describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do
6
6
  before do
7
- Handlers::Ruby::Legacy::Base.stub!(:inherited)
8
- Handlers::Ruby::Legacy::MixinHandler.stub!(:inherited) # fixes a Ruby1.9 issue
7
+ allow(Handlers::Ruby::Legacy::Base).to receive(:inherited)
8
+ if RUBY_VERSION > '1.8.7'
9
+ allow(Handlers::Ruby::Legacy::MixinHandler).to receive(:inherited) # fixes a Ruby1.9 issue
10
+ end
9
11
  @processor = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby18))
10
12
  end
11
13
 
@@ -17,45 +19,45 @@ describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do
17
19
  Statement.new(TokenList.new(string))
18
20
  end
19
21
 
20
- it "should only handle Handlers inherited from Ruby::Legacy::Base class" do
22
+ it "only handles Handlers inherited from Ruby::Legacy::Base class" do
21
23
  class IgnoredHandler < Handlers::Base
22
24
  handles "hello"
23
25
  end
24
26
  class NotIgnoredHandlerLegacy < Handlers::Ruby::Legacy::Base
25
27
  handles "hello"
26
28
  end
27
- Handlers::Base.stub!(:subclasses).and_return [IgnoredHandler, NotIgnoredHandlerLegacy]
28
- @processor.find_handlers(stmt("hello world")).should == [NotIgnoredHandlerLegacy]
29
+ allow(Handlers::Base).to receive(:subclasses).and_return [IgnoredHandler, NotIgnoredHandlerLegacy]
30
+ expect(@processor.find_handlers(stmt("hello world"))).to eq [NotIgnoredHandlerLegacy]
29
31
  end
30
32
 
31
- it "should handle a string input" do
33
+ it "handles a string input" do
32
34
  class TestStringHandler < Handlers::Ruby::Legacy::Base
33
35
  handles "hello"
34
36
  end
35
37
 
36
- TestStringHandler.handles?(stmt("hello world")).should be_true
37
- TestStringHandler.handles?(stmt("nothello world")).should be_false
38
+ expect(TestStringHandler.handles?(stmt("hello world"))).to be true
39
+ expect(TestStringHandler.handles?(stmt("nothello world"))).to be false
38
40
  end
39
41
 
40
- it "should handle regex input" do
42
+ it "handles regex input" do
41
43
  class TestRegexHandler < Handlers::Ruby::Legacy::Base
42
44
  handles /^nothello$/
43
45
  end
44
46
 
45
- TestRegexHandler.handles?(stmt("nothello")).should be_true
46
- TestRegexHandler.handles?(stmt("not hello hello")).should be_false
47
+ expect(TestRegexHandler.handles?(stmt("nothello"))).to be true
48
+ expect(TestRegexHandler.handles?(stmt("not hello hello"))).to be false
47
49
  end
48
50
 
49
- it "should handle token input" do
51
+ it "handles token input" do
50
52
  class TestTokenHandler < Handlers::Ruby::Legacy::Base
51
53
  handles TkMODULE
52
54
  end
53
55
 
54
- TestTokenHandler.handles?(stmt("module")).should be_true
55
- TestTokenHandler.handles?(stmt("if")).should be_false
56
+ expect(TestTokenHandler.handles?(stmt("module"))).to be true
57
+ expect(TestTokenHandler.handles?(stmt("if"))).to be false
56
58
  end
57
59
 
58
- it "should parse a do/end or { } block with #parse_block" do
60
+ it "parses a do/end or { } block with #parse_block" do
59
61
  class MyBlockHandler < Handlers::Ruby::Legacy::Base
60
62
  handles /\AmyMethod\b/
61
63
  def process
@@ -70,13 +72,13 @@ describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do
70
72
  def process; @@reached = true end
71
73
  end
72
74
 
73
- Handlers::Base.stub!(:subclasses).and_return [MyBlockHandler, MyBlockInnerHandler]
75
+ allow(Handlers::Base).to receive(:subclasses).and_return [MyBlockHandler, MyBlockInnerHandler]
74
76
  Parser::SourceParser.parser_type = :ruby18
75
77
  Parser::SourceParser.parse_string "myMethod do inner end"
76
- MyBlockInnerHandler.should be_reached
78
+ expect(MyBlockInnerHandler).to be_reached
77
79
  MyBlockInnerHandler.reset
78
80
  Parser::SourceParser.parse_string "myMethod { inner }"
79
- MyBlockInnerHandler.should be_reached
81
+ expect(MyBlockInnerHandler).to be_reached
80
82
  Parser::SourceParser.parser_type = :ruby
81
83
  end
82
84
  end
@@ -4,7 +4,7 @@ require 'stringio'
4
4
  include Handlers
5
5
 
6
6
  def undoc_error(code)
7
- lambda { StubbedSourceParser.parse_string(code) }.should raise_error(Parser::UndocumentableError)
7
+ expect { StubbedSourceParser.parse_string(code) }.to raise_error(Parser::UndocumentableError)
8
8
  end
9
9
 
10
10
  def with_parser(parser_type, &block)
@@ -3,37 +3,41 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHandler" do
4
4
  before(:all) { parse_file :visibility_handler_001, __FILE__ }
5
5
 
6
- it "should be able to set visibility to public" do
7
- Registry.at("Testing#pub").visibility.should == :public
8
- Registry.at("Testing#pub2").visibility.should == :public
6
+ it "is able to set visibility to public" do
7
+ expect(Registry.at("Testing#pub").visibility).to eq :public
8
+ expect(Registry.at("Testing#pub2").visibility).to eq :public
9
9
  end
10
10
 
11
- it "should be able to set visibility to private" do
12
- Registry.at("Testing#priv").visibility.should == :private
11
+ it "is able to set visibility to private" do
12
+ expect(Registry.at("Testing#priv").visibility).to eq :private
13
13
  end
14
14
 
15
- it "should be able to set visibility to protected" do
16
- Registry.at("Testing#prot").visibility.should == :protected
15
+ it "is able to set visibility to protected" do
16
+ expect(Registry.at("Testing#prot").visibility).to eq :protected
17
17
  end
18
18
 
19
- it "should support parameters and only set visibility on those methods" do
20
- Registry['Testing#notpriv'].visibility.should == :protected
21
- Registry['Testing#notpriv2'].visibility.should == :protected
22
- Registry['Testing#notpriv?'].visibility.should == :protected
19
+ it "supports parameters and only set visibility on those methods" do
20
+ expect(Registry.at('Testing#notpriv').visibility).to eq :protected
21
+ expect(Registry.at('Testing#notpriv2').visibility).to eq :protected
22
+ expect(Registry.at('Testing#notpriv?').visibility).to eq :protected
23
23
  end
24
24
 
25
- it "should only accept strings and symbols" do
26
- Registry.at('Testing#name').should be_nil
27
- Registry.at('Testing#argument').should be_nil
28
- Registry.at('Testing#method_call').should be_nil
25
+ it "only accepts strings and symbols" do
26
+ expect(Registry.at('Testing#name')).to be nil
27
+ expect(Registry.at('Testing#argument')).to be nil
28
+ expect(Registry.at('Testing#method_call')).to be nil
29
29
  end
30
30
 
31
- it "should handle constants passed in as symbols" do
32
- Registry.at('Testing#Foo').visibility.should == :private
31
+ it "handles constants passed in as symbols" do
32
+ expect(Registry.at('Testing#Foo').visibility).to eq :private
33
33
  end
34
34
 
35
- it 'should not register classes with visibility' do
36
- Registry.at('Testing::Bar').visibility.should == :public
37
- Registry.at('Testing::Baz').visibility.should == :public
35
+ it "does not register classes with visibility" do
36
+ expect(Registry.at('Testing::Bar').visibility).to eq :public
37
+ expect(Registry.at('Testing::Baz').visibility).to eq :public
38
38
  end
39
- end
39
+
40
+ it "can decorate a method definition" do
41
+ expect(Registry.at('Testing#decpriv').visibility).to eq :private
42
+ end unless LEGACY_PARSER
43
+ end
@@ -3,49 +3,49 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}YieldHandler" do
4
4
  before(:all) { parse_file :yield_handler_001, __FILE__ }
5
5
 
6
- it "should only parse yield blocks in methods" do
7
- P(:Testing).tag(:yield).should be_nil
8
- P(:Testing).tag(:yieldparam).should be_nil
6
+ it "only parses yield blocks in methods" do
7
+ expect(P(:Testing).tag(:yield)).to be nil
8
+ expect(P(:Testing).tag(:yieldparam)).to be nil
9
9
  end
10
10
 
11
- it "should handle an empty yield statement" do
12
- P('Testing#mymethod').tag(:yield).should be_nil
13
- P('Testing#mymethod').tag(:yieldparam).should be_nil
11
+ it "handles an empty yield statement" do
12
+ expect(P('Testing#mymethod').tag(:yield)).to be nil
13
+ expect(P('Testing#mymethod').tag(:yieldparam)).to be nil
14
14
  end
15
15
 
16
- it "should not document a yield statement in a method with either @yield or @yieldparam" do
17
- P('Testing#mymethod2').tag(:yield).types.should == ['a', 'b']
18
- P('Testing#mymethod2').tag(:yield).text.should == "Blah"
19
- P('Testing#mymethod2').tags(:yieldparam).size.should == 2
16
+ it "does not document a yield statement in a method with either @yield or @yieldparam" do
17
+ expect(P('Testing#mymethod2').tag(:yield).types).to eq ['a', 'b']
18
+ expect(P('Testing#mymethod2').tag(:yield).text).to eq "Blah"
19
+ expect(P('Testing#mymethod2').tags(:yieldparam).size).to eq 2
20
20
 
21
- P('Testing#mymethod3').tag(:yield).types.should == ['a', 'b']
22
- P('Testing#mymethod3').tags(:yieldparam).size.should == 0
21
+ expect(P('Testing#mymethod3').tag(:yield).types).to eq ['a', 'b']
22
+ expect(P('Testing#mymethod3').tags(:yieldparam).size).to eq 0
23
23
 
24
- P('Testing#mymethod4').tag(:yieldparam).name.should == '_self'
25
- P('Testing#mymethod4').tag(:yieldparam).text.should == 'BLAH'
24
+ expect(P('Testing#mymethod4').tag(:yieldparam).name).to eq '_self'
25
+ expect(P('Testing#mymethod4').tag(:yieldparam).text).to eq 'BLAH'
26
26
  end
27
27
 
28
- it "should handle any arbitrary yield statement" do
29
- P('Testing#mymethod5').tag(:yield).types.should == [':a', 'b', '_self', 'File.read(\'file\', \'w\')', 'CONSTANT']
28
+ it "handles any arbitrary yield statement" do
29
+ expect(P('Testing#mymethod5').tag(:yield).types).to eq [':a', 'b', '_self', 'File.read(\'file\', \'w\')', 'CONSTANT']
30
30
  end
31
31
 
32
- it "should handle parentheses" do
33
- P('Testing#mymethod6').tag(:yield).types.should == ['b', 'a']
32
+ it "handles parentheses" do
33
+ expect(P('Testing#mymethod6').tag(:yield).types).to eq ['b', 'a']
34
34
  end
35
35
 
36
- it "should only document the first yield statement in a method (limitation of yield handler)" do
37
- P('Testing#mymethod7').tag(:yield).types.should == ['a']
36
+ it "only documents the first yield statement in a method (limitation of yield handler)" do
37
+ expect(P('Testing#mymethod7').tag(:yield).types).to eq ['a']
38
38
  end
39
39
 
40
- it "should handle `self` keyword and list object type as yieldparam for _self" do
41
- P('Testing#mymethod8').tag(:yield).types.should == ['_self']
42
- P('Testing#mymethod8').tag(:yieldparam).types.should == ['Testing']
43
- P('Testing#mymethod8').tag(:yieldparam).text.should == "the object that the method was called on"
40
+ it "handles `self` keyword and list object type as yieldparam for _self" do
41
+ expect(P('Testing#mymethod8').tag(:yield).types).to eq ['_self']
42
+ expect(P('Testing#mymethod8').tag(:yieldparam).types).to eq ['Testing']
43
+ expect(P('Testing#mymethod8').tag(:yieldparam).text).to eq "the object that the method was called on"
44
44
  end
45
45
 
46
- it "should handle `super` keyword and document it under _super" do
47
- P('Testing#mymethod9').tag(:yield).types.should == ['_super']
48
- P('Testing#mymethod9').tag(:yieldparam).types.should be_nil
49
- P('Testing#mymethod9').tag(:yieldparam).text.should == "the result of the method from the superclass"
46
+ it "handles `super` keyword and document it under _super" do
47
+ expect(P('Testing#mymethod9').tag(:yield).types).to eq ['_super']
48
+ expect(P('Testing#mymethod9').tag(:yieldparam).types).to be nil
49
+ expect(P('Testing#mymethod9').tag(:yieldparam).text).to eq "the result of the method from the superclass"
50
50
  end
51
51
  end