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,16 +3,15 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
3
3
  describe YARD::Parser, "tag handling" do
4
4
  before { parse_file :tag_handler_001, __FILE__ }
5
5
 
6
- it "should know the list of all available tags" do
7
- P("Foo#foo").tags.should include(P("Foo#foo").tag(:api))
6
+ it "knows the list of all available tags" do
7
+ expect(P("Foo#foo").tags).to include(P("Foo#foo").tag(:api))
8
8
  end
9
9
 
10
- it "should know the text of tags on a method" do
11
- P("Foo#foo").tag(:api).text.should == "public"
10
+ it "knows the text of tags on a method" do
11
+ expect(P("Foo#foo").tag(:api).text).to eq "public"
12
12
  end
13
13
 
14
- it "should return true when asked whether a tag exists" do
15
- P("Foo#foo").has_tag?(:api).should == true
14
+ it "returns true when asked whether a tag exists" do
15
+ expect(P("Foo#foo").has_tag?(:api)).to be true
16
16
  end
17
-
18
17
  end
@@ -7,12 +7,12 @@ describe YARD::Rake::YardocTask do
7
7
  @yardoc.use_document_file = false
8
8
  @yardoc.use_yardopts_file = false
9
9
  @yardoc.generate = false
10
- Templates::Engine.stub!(:render)
11
- Templates::Engine.stub!(:generate)
12
- YARD.stub!(:parse)
13
- Registry.stub!(:load)
14
- Registry.stub!(:save)
15
- YARD::CLI::Yardoc.stub!(:new).and_return(@yardoc)
10
+ allow(Templates::Engine).to receive(:render)
11
+ allow(Templates::Engine).to receive(:generate)
12
+ allow(YARD).to receive(:parse)
13
+ allow(Registry).to receive(:load)
14
+ allow(Registry).to receive(:save)
15
+ allow(YARD::CLI::Yardoc).to receive(:new).and_return(@yardoc)
16
16
  ::Rake.application.clear
17
17
  end
18
18
 
@@ -20,103 +20,93 @@ describe YARD::Rake::YardocTask do
20
20
  ::Rake.application.tasks[0].invoke
21
21
  end
22
22
 
23
- describe '#initialize' do
24
- it "should allow separate rake task name to be set" do
23
+ describe "#initialize" do
24
+ it "allows separate rake task name to be set" do
25
25
  YARD::Rake::YardocTask.new(:notyardoc)
26
- ::Rake.application.tasks[0].name.should == "notyardoc"
26
+ expect(::Rake.application.tasks[0].name).to eq "notyardoc"
27
27
  end
28
28
  end
29
29
 
30
- describe '#files' do
31
- it "should allow files to be set" do
30
+ describe "#files" do
31
+ it "allows files to be set" do
32
32
  YARD::Rake::YardocTask.new do |t|
33
33
  t.files = ['a', 'b', 'c']
34
34
  end
35
35
  run
36
- @yardoc.files.should == %w(a b c)
36
+ expect(@yardoc.files).to eq %w(a b c)
37
37
  end
38
38
  end
39
39
 
40
- describe '#options' do
41
- it "should allow extra options to be set" do
40
+ describe "#options" do
41
+ it "allows extra options to be set" do
42
42
  YARD::Rake::YardocTask.new do |t|
43
43
  t.options = ['--private', '--protected']
44
44
  end
45
45
  run
46
- @yardoc.visibilities.should == [:public, :private, :protected]
46
+ expect(@yardoc.visibilities).to eq [:public, :private, :protected]
47
47
  end
48
48
 
49
- it "should allow --api and --no-api" do
49
+ it "allows --api and --no-api" do
50
50
  YARD::Rake::YardocTask.new do |t|
51
51
  t.options = %w(--api public --no-api)
52
52
  end
53
53
  run
54
- @yardoc.options.verifier.expressions.
55
- should include('["public"].include?(@api.text) || !@api')
54
+ expect(@yardoc.options.verifier.expressions).to include('["public"].include?(@api.text) || !@api')
56
55
  end
57
56
  end
58
57
 
59
- describe '#stats_options' do
58
+ describe "#stats_options" do
60
59
  before do
61
60
  @yard_stats = Object.new
62
- @yard_stats.stub!(:run)
63
- YARD::CLI::Stats.stub!(:new).and_return(@yard_stats)
61
+ allow(@yard_stats).to receive(:run)
62
+ allow(YARD::CLI::Stats).to receive(:new).and_return(@yard_stats)
64
63
  end
65
64
 
66
- it "should not invoke stats" do
67
- @yard_stats.should_not_receive(:run)
68
- @yardoc.statistics = true
69
- YARD::Rake::YardocTask.new do |t|
70
- end
71
- run
72
- @yardoc.statistics.should == true
73
- end
74
-
75
- it "should invoke stats" do
76
- @yard_stats.should_receive(:run).with('--list-undoc', '--use-cache')
65
+ it "invokes stats" do
66
+ expect(@yard_stats).to receive(:run).with('--list-undoc', '--use-cache')
77
67
  @yardoc.statistics = true
78
68
  YARD::Rake::YardocTask.new do |t|
79
69
  t.stats_options = %w(--list-undoc)
80
70
  end
81
71
  run
82
- @yardoc.statistics.should == false
72
+ expect(@yardoc.statistics).to be false
83
73
  end
84
74
  end
85
75
 
86
- describe '#before' do
87
- it "should allow before callback" do
76
+ describe "#before" do
77
+ it "allows before callback" do
88
78
  proc = lambda { }
89
- proc.should_receive(:call)
90
- @yardoc.should_receive(:run)
79
+ expect(proc).to receive(:call)
80
+ expect(@yardoc).to receive(:run)
91
81
  YARD::Rake::YardocTask.new {|t| t.before = proc }
92
82
  run
93
83
  end
94
84
  end
95
85
 
96
- describe '#after' do
97
- it "should allow after callback" do
86
+ describe "#after" do
87
+ it "allows after callback" do
98
88
  proc = lambda { }
99
- proc.should_receive(:call)
100
- @yardoc.should_receive(:run)
89
+ expect(proc).to receive(:call)
90
+ expect(@yardoc).to receive(:run)
101
91
  YARD::Rake::YardocTask.new {|t| t.after = proc }
102
92
  run
103
93
  end
104
94
  end
105
95
 
106
- describe '#verifier' do
107
- it "should allow a verifier proc to be set" do
96
+ describe "#verifier" do
97
+ it "allows a verifier proc to be set" do
108
98
  verifier = Verifier.new
109
- @yardoc.should_receive(:run) do
110
- @yardoc.options[:verifier].should == verifier
99
+ expect(@yardoc).to receive(:run) do
100
+ expect(@yardoc.options[:verifier]).to eq verifier
111
101
  end
112
102
  YARD::Rake::YardocTask.new {|t| t.verifier = verifier }
113
103
  run
114
104
  end
115
105
 
116
- it "should override --query options" do
106
+ it "overrides --query options" do
117
107
  verifier = Verifier.new
118
- @yardoc.should_receive(:run) do
119
- @yardoc.options[:verifier].should == verifier
108
+ expect(@yardoc).to receive(:run) do
109
+ expect(@yardoc.options[:verifier]).to eq verifier
120
110
  end
121
111
  YARD::Rake::YardocTask.new do |t|
122
112
  t.options += ['--query', '@return']
@@ -6,312 +6,312 @@ require "thread"
6
6
  describe YARD::Registry do
7
7
  before { Registry.clear }
8
8
 
9
- describe '.yardoc_file_for_gem' do
9
+ describe ".yardoc_file_for_gem" do
10
10
  before do
11
- @gem = mock('gem')
12
- @gem.stub!(:name).and_return('foo')
13
- @gem.stub!(:full_name).and_return('foo-1.0')
14
- @gem.stub!(:full_gem_path).and_return('/path/to/foo')
11
+ @gem = double('gem')
12
+ allow(@gem).to receive(:name).and_return('foo')
13
+ allow(@gem).to receive(:full_name).and_return('foo-1.0')
14
+ allow(@gem).to receive(:full_gem_path).and_return('/path/to/foo')
15
15
  end
16
16
 
17
- it "should return nil if gem isn't found" do
18
- Gem.source_index.should_receive(:find_name).with('foo', '>= 0').and_return([])
19
- Registry.yardoc_file_for_gem('foo').should == nil
17
+ it "returns nil if gem isn't found" do
18
+ expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([])
19
+ expect(Registry.yardoc_file_for_gem('foo')).to eq nil
20
20
  end
21
21
 
22
- it "should allow version to be specified" do
23
- Gem.source_index.should_receive(:find_name).with('foo', '= 2').and_return([])
24
- Registry.yardoc_file_for_gem('foo', '= 2').should == nil
22
+ it "allows version to be specified" do
23
+ expect(Gem.source_index).to receive(:find_name).with('foo', '= 2').and_return([])
24
+ expect(Registry.yardoc_file_for_gem('foo', '= 2')).to eq nil
25
25
  end
26
26
 
27
- it "should return existing .yardoc path for gem when for_writing=false" do
28
- File.should_receive(:exist?).and_return(false)
29
- File.should_receive(:exist?).with('/path/to/foo/.yardoc').and_return(true)
30
- Gem.source_index.should_receive(:find_name).with('foo', '>= 0').and_return([@gem])
31
- Registry.yardoc_file_for_gem('foo').should == '/path/to/foo/.yardoc'
27
+ it "returns existing .yardoc path for gem when for_writing=false" do
28
+ expect(File).to receive(:exist?).and_return(false)
29
+ expect(File).to receive(:exist?).with('/path/to/foo/.yardoc').and_return(true)
30
+ expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
31
+ expect(Registry.yardoc_file_for_gem('foo')).to eq '/path/to/foo/.yardoc'
32
32
  end
33
33
 
34
- it "should return nil if no .yardoc path exists in gem when for_writing=false" do
35
- File.should_receive(:exist?).and_return(false)
36
- File.should_receive(:exist?).with('/path/to/foo/.yardoc').and_return(false)
37
- Gem.source_index.should_receive(:find_name).with('foo', '>= 0').and_return([@gem])
38
- Registry.yardoc_file_for_gem('foo').should == nil
34
+ it "returns nil if no .yardoc path exists in gem when for_writing=false" do
35
+ expect(File).to receive(:exist?).and_return(false)
36
+ expect(File).to receive(:exist?).with('/path/to/foo/.yardoc').and_return(false)
37
+ expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
38
+ expect(Registry.yardoc_file_for_gem('foo')).to eq nil
39
39
  end
40
40
 
41
- it "should search local gem path first if for_writing=false" do
42
- File.should_receive(:exist?).and_return(true)
43
- Gem.source_index.should_receive(:find_name).with('foo', '>= 0').and_return([@gem])
44
- Registry.yardoc_file_for_gem('foo').should =~ %r{/.yard/gem_index/foo-1.0.yardoc$}
41
+ it "searches local gem path first if for_writing=false" do
42
+ expect(File).to receive(:exist?).and_return(true)
43
+ expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
44
+ expect(Registry.yardoc_file_for_gem('foo')).to match %r{/.yard/gem_index/foo-1.0.yardoc$}
45
45
  end
46
46
 
47
- it "should return global .yardoc path for gem if for_writing=true and dir is writable" do
48
- File.should_receive(:writable?).with(@gem.full_gem_path).and_return(true)
49
- Gem.source_index.should_receive(:find_name).with('foo', '>= 0').and_return([@gem])
50
- Registry.yardoc_file_for_gem('foo', '>= 0', true).should == '/path/to/foo/.yardoc'
47
+ it "returns global .yardoc path for gem if for_writing=true and dir is writable" do
48
+ expect(File).to receive(:writable?).with(@gem.full_gem_path).and_return(true)
49
+ expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
50
+ expect(Registry.yardoc_file_for_gem('foo', '>= 0', true)).to eq '/path/to/foo/.yardoc'
51
51
  end
52
52
 
53
- it "should return local .yardoc path for gem if for_writing=true and dir is not writable" do
54
- File.should_receive(:writable?).with(@gem.full_gem_path).and_return(false)
55
- Gem.source_index.should_receive(:find_name).with('foo', '>= 0').and_return([@gem])
56
- Registry.yardoc_file_for_gem('foo', '>= 0', true).should =~ %r{/.yard/gem_index/foo-1.0.yardoc$}
53
+ it "returns local .yardoc path for gem if for_writing=true and dir is not writable" do
54
+ expect(File).to receive(:writable?).with(@gem.full_gem_path).and_return(false)
55
+ expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
56
+ expect(Registry.yardoc_file_for_gem('foo', '>= 0', true)).to match %r{/.yard/gem_index/foo-1.0.yardoc$}
57
57
  end
58
58
 
59
- it "should return gem path if gem starts with yard-doc- and for_writing=false" do
60
- @gem.stub!(:name).and_return('yard-doc-core')
61
- @gem.stub!(:full_name).and_return('yard-doc-core-1.0')
62
- @gem.stub!(:full_gem_path).and_return('/path/to/yard-doc-core')
63
- Gem.source_index.should_receive(:find_name).with('yard-doc-core', '>= 0').and_return([@gem])
64
- File.should_receive(:exist?).with('/path/to/yard-doc-core/.yardoc').and_return(true)
65
- Registry.yardoc_file_for_gem('yard-doc-core').should == '/path/to/yard-doc-core/.yardoc'
59
+ it "returns gem path if gem starts with yard-doc- and for_writing=false" do
60
+ allow(@gem).to receive(:name).and_return('yard-doc-core')
61
+ allow(@gem).to receive(:full_name).and_return('yard-doc-core-1.0')
62
+ allow(@gem).to receive(:full_gem_path).and_return('/path/to/yard-doc-core')
63
+ expect(Gem.source_index).to receive(:find_name).with('yard-doc-core', '>= 0').and_return([@gem])
64
+ expect(File).to receive(:exist?).with('/path/to/yard-doc-core/.yardoc').and_return(true)
65
+ expect(Registry.yardoc_file_for_gem('yard-doc-core')).to eq '/path/to/yard-doc-core/.yardoc'
66
66
  end
67
67
 
68
- it "should return nil if gem starts with yard-doc- and for_writing=true" do
69
- @gem.stub!(:name).and_return('yard-doc-core')
70
- @gem.stub!(:full_name).and_return('yard-doc-core-1.0')
71
- @gem.stub!(:full_gem_path).and_return('/path/to/yard-doc-core')
72
- Gem.source_index.should_receive(:find_name).with('yard-doc-core', '>= 0').and_return([@gem])
73
- File.should_receive(:exist?).with('/path/to/yard-doc-core/.yardoc').and_return(true)
74
- Registry.yardoc_file_for_gem('yard-doc-core', '>= 0', true).should == nil
68
+ it "returns nil if gem starts with yard-doc- and for_writing=true" do
69
+ allow(@gem).to receive(:name).and_return('yard-doc-core')
70
+ allow(@gem).to receive(:full_name).and_return('yard-doc-core-1.0')
71
+ allow(@gem).to receive(:full_gem_path).and_return('/path/to/yard-doc-core')
72
+ expect(Gem.source_index).to receive(:find_name).with('yard-doc-core', '>= 0').and_return([@gem])
73
+ expect(File).to receive(:exist?).with('/path/to/yard-doc-core/.yardoc').and_return(true)
74
+ expect(Registry.yardoc_file_for_gem('yard-doc-core', '>= 0', true)).to eq nil
75
75
  end
76
76
  end
77
77
 
78
- describe '.root' do
79
- it "should have an empty path for root" do
80
- Registry.root.path.should == ""
78
+ describe ".root" do
79
+ it "has an empty path for root" do
80
+ expect(Registry.root.path).to eq ""
81
81
  end
82
82
  end
83
83
 
84
- describe '.locale' do
85
- it "should load locale object" do
84
+ describe ".locale" do
85
+ it "loads locale object" do
86
86
  fr_locale = I18n::Locale.new("fr")
87
87
  store = Registry.send(:thread_local_store)
88
- store.should_receive(:locale).with("fr").and_return(fr_locale)
89
- Registry.locale("fr").should == fr_locale
88
+ expect(store).to receive(:locale).with("fr").and_return(fr_locale)
89
+ expect(Registry.locale("fr")).to eq fr_locale
90
90
  end
91
91
  end
92
92
 
93
- describe '.resolve' do
94
- it "should resolve any existing namespace" do
93
+ describe ".resolve" do
94
+ it "resolves any existing namespace" do
95
95
  o1 = ModuleObject.new(:root, :A)
96
96
  o2 = ModuleObject.new(o1, :B)
97
97
  o3 = ModuleObject.new(o2, :C)
98
- Registry.resolve(o1, "B::C").should == o3
98
+ expect(Registry.resolve(o1, "B::C")).to eq o3
99
99
  Registry.resolve(:root, "A::B::C")
100
100
  end
101
101
 
102
- it "should resolve an object in the root namespace when prefixed with ::" do
102
+ it "resolves an object in the root namespace when prefixed with ::" do
103
103
  o1 = ModuleObject.new(:root, :A)
104
104
  o2 = ModuleObject.new(o1, :B)
105
105
  o3 = ModuleObject.new(o2, :C)
106
- Registry.resolve(o3, "::A").should == o1
106
+ expect(Registry.resolve(o3, "::A")).to eq o1
107
107
 
108
- Registry.resolve(o3, "::String", false, true).should == P(:String)
108
+ expect(Registry.resolve(o3, "::String", false, true)).to eq P(:String)
109
109
  end
110
110
 
111
- it "should resolve instance methods with # prefix" do
111
+ it "resolves instance methods with # prefix" do
112
112
  o1 = ModuleObject.new(:root, :A)
113
113
  o2 = ModuleObject.new(o1, :B)
114
114
  o3 = ModuleObject.new(o2, :C)
115
115
  o4 = MethodObject.new(o3, :methname)
116
- Registry.resolve(o1, "B::C#methname").should == o4
117
- Registry.resolve(o2, "C#methname").should == o4
118
- Registry.resolve(o3, "#methname").should == o4
116
+ expect(Registry.resolve(o1, "B::C#methname")).to eq o4
117
+ expect(Registry.resolve(o2, "C#methname")).to eq o4
118
+ expect(Registry.resolve(o3, "#methname")).to eq o4
119
119
  end
120
120
 
121
- it "should resolve instance methods in the root without # prefix" do
121
+ it "resolves instance methods in the root without # prefix" do
122
122
  o = MethodObject.new(:root, :methname)
123
- Registry.resolve(:root, 'methname').should == o
123
+ expect(Registry.resolve(:root, 'methname')).to eq o
124
124
  end
125
125
 
126
- it "should resolve superclass methods when inheritance = true" do
126
+ it "resolves superclass methods when inheritance = true" do
127
127
  superyard = ClassObject.new(:root, :SuperYard)
128
128
  yard = ClassObject.new(:root, :YARD)
129
129
  yard.superclass = superyard
130
130
  imeth = MethodObject.new(superyard, :hello)
131
131
  cmeth = MethodObject.new(superyard, :class_hello, :class)
132
132
 
133
- Registry.resolve(yard, "#hello", false).should be_nil
134
- Registry.resolve(yard, "#hello", true).should == imeth
135
- Registry.resolve(yard, "class_hello", false).should be_nil
136
- Registry.resolve(yard, "class_hello", true).should == cmeth
133
+ expect(Registry.resolve(yard, "#hello", false)).to be nil
134
+ expect(Registry.resolve(yard, "#hello", true)).to eq imeth
135
+ expect(Registry.resolve(yard, "class_hello", false)).to be nil
136
+ expect(Registry.resolve(yard, "class_hello", true)).to eq cmeth
137
137
  end
138
138
 
139
- it "should resolve mixin methods when inheritance = true" do
139
+ it "resolves mixin methods when inheritance = true" do
140
140
  yard = ClassObject.new(:root, :YARD)
141
141
  mixin = ModuleObject.new(:root, :Mixin)
142
142
  yard.mixins(:instance) << mixin
143
143
  imeth = MethodObject.new(mixin, :hello)
144
144
  cmeth = MethodObject.new(mixin, :class_hello, :class)
145
145
 
146
- Registry.resolve(yard, "#hello", false).should be_nil
147
- Registry.resolve(yard, "#hello", true).should == imeth
148
- Registry.resolve(yard, "class_hello", false).should be_nil
149
- Registry.resolve(yard, "class_hello", true).should == cmeth
146
+ expect(Registry.resolve(yard, "#hello", false)).to be nil
147
+ expect(Registry.resolve(yard, "#hello", true)).to eq imeth
148
+ expect(Registry.resolve(yard, "class_hello", false)).to be nil
149
+ expect(Registry.resolve(yard, "class_hello", true)).to eq cmeth
150
150
  end
151
151
 
152
- it "should resolve methods in Object when inheritance = true" do
152
+ it "resolves methods in Object when inheritance = true" do
153
153
  YARD.parse_string <<-eof
154
154
  class Object; def foo; end end
155
155
  class A; end
156
156
  class MyObject < A; end
157
157
  eof
158
158
 
159
- Registry.resolve(P('MyObject'), '#foo', true).should == P('Object#foo')
159
+ expect(Registry.resolve(P('MyObject'), '#foo', true)).to eq P('Object#foo')
160
160
  end
161
161
 
162
- it "should resolve methods in BasicObject when inheritance = true" do
162
+ it "resolves methods in BasicObject when inheritance = true" do
163
163
  YARD.parse_string <<-eof
164
164
  class BasicObject; def foo; end end
165
165
  class A; end
166
166
  class MyObject < A; end
167
167
  eof
168
168
 
169
- Registry.resolve(P('MyObject'), '#foo', true).should == P('BasicObject#foo')
169
+ expect(Registry.resolve(P('MyObject'), '#foo', true)).to eq P('BasicObject#foo')
170
170
  end
171
171
 
172
- it "should not resolve methods in Object if inheriting BasicObject when inheritance = true" do
172
+ it "does not resolve methods in Object if inheriting BasicObject when inheritance = true" do
173
173
  YARD.parse_string <<-eof
174
174
  class Object; def foo; end end
175
175
  class MyObject < BasicObject; end
176
176
  eof
177
177
 
178
- Registry.resolve(P('MyObject'), '#foo', true).should be_nil
178
+ expect(Registry.resolve(P('MyObject'), '#foo', true)).to be nil
179
179
  end
180
180
 
181
- it "should allow type=:typename to ensure resolved object is of a certain type" do
181
+ it "allows type=:typename to ensure resolved object is of a certain type" do
182
182
  YARD.parse_string "class Foo; end"
183
- Registry.resolve(Registry.root, 'Foo').should == Registry.at('Foo')
184
- Registry.resolve(Registry.root, 'Foo', false, false, :method).should be_nil
183
+ expect(Registry.resolve(Registry.root, 'Foo')).to eq Registry.at('Foo')
184
+ expect(Registry.resolve(Registry.root, 'Foo', false, false, :method)).to be nil
185
185
  end
186
186
 
187
- it "should allow keep trying to find obj where type equals object type" do
187
+ it "allows keep trying to find obj where type equals object type" do
188
188
  YARD.parse_string <<-eof
189
189
  module Foo
190
190
  class Bar; end
191
191
  def self.Bar; end
192
192
  end
193
193
  eof
194
- Registry.resolve(P('Foo'), 'Bar').should == Registry.at('Foo::Bar')
195
- Registry.resolve(P('Foo'), 'Bar', false, false, :method).should ==
196
- Registry.at('Foo.Bar')
194
+ expect(Registry.resolve(P('Foo'), 'Bar')).to eq Registry.at('Foo::Bar')
195
+ expect(Registry.resolve(P('Foo'), 'Bar', false, false, :method)).to eq(
196
+ Registry.at('Foo.Bar'))
197
197
  end
198
198
 
199
- it "should return proxy fallback with given type if supplied" do
199
+ it "returns proxy fallback with given type if supplied" do
200
200
  YARD.parse_string "module Foo; end"
201
201
  proxy = Registry.resolve(P('Foo'), 'Bar', false, true, :method)
202
- proxy.type.should == :method
202
+ expect(proxy.type).to eq :method
203
203
  proxy = Registry.resolve(P('Qux'), 'Bar', false, true, :method)
204
- proxy.type.should == :method
204
+ expect(proxy.type).to eq :method
205
205
  end
206
206
 
207
- it "should only check 'Path' in lookup on root namespace" do
208
- Registry.should_receive(:at).once.with('Test').and_return(true)
207
+ it "only checks 'Path' in lookup on root namespace" do
208
+ expect(Registry).to receive(:at).once.with('Test').and_return(true)
209
209
  Registry.resolve(Registry.root, "Test")
210
210
  end
211
211
 
212
- it "should not perform lookup by joining namespace and name without separator" do
212
+ it "does not perform lookup by joining namespace and name without separator" do
213
213
  yard = ClassObject.new(:root, :YARD)
214
- Registry.should_not_receive(:at).with('YARDB')
214
+ expect(Registry).not_to receive(:at).with('YARDB')
215
215
  Registry.resolve(yard, 'B')
216
216
  end
217
217
  end
218
218
 
219
- describe '.all' do
220
- it "should return objects of types specified by arguments" do
219
+ describe ".all" do
220
+ it "returns objects of types specified by arguments" do
221
221
  ModuleObject.new(:root, :A)
222
222
  o1 = ClassObject.new(:root, :B)
223
223
  o2 = MethodObject.new(:root, :testing)
224
224
  r = Registry.all(:method, :class)
225
- r.should include(o1, o2)
225
+ expect(r).to include(o1, o2)
226
226
  end
227
227
 
228
- it "should return code objects" do
228
+ it "returns code objects" do
229
229
  o1 = ModuleObject.new(:root, :A)
230
230
  o2 = ClassObject.new(:root, :B)
231
231
  MethodObject.new(:root, :testing)
232
232
  r = Registry.all.select {|t| NamespaceObject === t }
233
- r.should include(o1, o2)
233
+ expect(r).to include(o1, o2)
234
234
  end
235
235
 
236
- it "should allow .all to omit list" do
236
+ it "allows .all to omit list" do
237
237
  o1 = ModuleObject.new(:root, :A)
238
238
  o2 = ClassObject.new(:root, :B)
239
239
  r = Registry.all
240
- r.should include(o1, o2)
240
+ expect(r).to include(o1, o2)
241
241
  end
242
242
  end
243
243
 
244
- describe '.paths' do
245
- it "should return all object paths" do
244
+ describe ".paths" do
245
+ it "returns all object paths" do
246
246
  o1 = ModuleObject.new(:root, :A)
247
247
  o2 = ClassObject.new(:root, :B)
248
- Registry.paths.should include('A', 'B')
248
+ expect(Registry.paths).to include('A', 'B')
249
249
  end
250
250
  end
251
251
 
252
- describe '.load_yardoc' do
253
- it "should delegate load to RegistryStore" do
252
+ describe ".load_yardoc" do
253
+ it "delegates load to RegistryStore" do
254
254
  store = RegistryStore.new
255
- store.should_receive(:load).with('foo')
256
- RegistryStore.should_receive(:new).and_return(store)
255
+ expect(store).to receive(:load).with('foo')
256
+ expect(RegistryStore).to receive(:new).and_return(store)
257
257
  Registry.yardoc_file = 'foo'
258
258
  Registry.load_yardoc
259
259
  end
260
260
 
261
- it "should return itself" do
262
- Registry.load_yardoc.should == Registry
261
+ it "returns itself" do
262
+ expect(Registry.load_yardoc).to eq Registry
263
263
  end
264
264
 
265
- it "should maintain hash key equality on loaded objects" do
265
+ it "maintains hash key equality on loaded objects" do
266
266
  Registry.clear
267
267
  Registry.load!(File.dirname(__FILE__) + '/serializers/data/serialized_yardoc')
268
268
  baz = Registry.at('Foo#baz')
269
- Registry.at('Foo').aliases.keys.should include(baz)
270
- Registry.at('Foo').aliases.has_key?(baz).should == true
269
+ expect(Registry.at('Foo').aliases.keys).to include(baz)
270
+ expect(Registry.at('Foo').aliases.has_key?(baz)).to be true
271
271
  end
272
272
  end
273
273
 
274
274
  ['load', 'load_all', 'load!'].each do |meth|
275
275
  describe('.' + meth) do
276
- it "should return itself" do
277
- Registry.send(meth).should == Registry
276
+ it "returns itself" do
277
+ expect(Registry.send(meth)).to eq Registry
278
278
  end
279
279
  end
280
280
  end
281
281
 
282
- describe '.each' do
282
+ describe ".each" do
283
283
  before do
284
284
  YARD.parse_string "def a; end; def b; end; def c; end"
285
285
  end
286
286
 
287
287
  after { Registry.clear }
288
288
 
289
- it "should iterate over .all" do
289
+ it "iterates over .all" do
290
290
  items = []
291
291
  Registry.each {|x| items << x.path }
292
- items.sort.should == ['#a', '#b', '#c']
292
+ expect(items.sort).to eq ['#a', '#b', '#c']
293
293
  end
294
294
 
295
- it "should include Enumerable and allow for find, select" do
296
- Registry.find {|x| x.path == "#a" }.should be_a(CodeObjects::MethodObject)
295
+ it "includes Enumerable and allow for find, select" do
296
+ expect(Registry.find {|x| x.path == "#a" }).to be_a(CodeObjects::MethodObject)
297
297
  end
298
298
  end
299
299
 
300
- describe '.instance' do
301
- it "should return itself" do
302
- Registry.instance.should == Registry
300
+ describe ".instance" do
301
+ it "returns itself" do
302
+ expect(Registry.instance).to eq Registry
303
303
  end
304
304
  end
305
305
 
306
- describe '.single_object_db' do
307
- it "should default to nil" do
308
- Registry.single_object_db.should == nil
309
- Thread.new { Registry.single_object_db.should == nil }.join
306
+ describe ".single_object_db" do
307
+ it "defaults to nil" do
308
+ expect(Registry.single_object_db).to eq nil
309
+ Thread.new { expect(Registry.single_object_db).to eq nil }.join
310
310
  end
311
311
  end
312
312
 
313
- describe 'Thread local' do
314
- it "should maintain two Registries in separate threads" do
313
+ describe "Thread local" do
314
+ it "maintains two Registries in separate threads" do
315
315
  barrier = 0
316
316
  mutex = Mutex.new
317
317
  threads = []
@@ -322,7 +322,7 @@ describe YARD::Registry do
322
322
  while barrier < 2 do
323
323
  s = "barrier < 2, spinning"
324
324
  end
325
- Registry.at('Foo').docstring.should == "docstring 1"
325
+ expect(Registry.at('Foo').docstring).to eq "docstring 1"
326
326
  end
327
327
  threads << Thread.new do
328
328
  Registry.clear
@@ -331,29 +331,29 @@ describe YARD::Registry do
331
331
  while barrier < 2 do
332
332
  s = "barrier < 2, spinning"
333
333
  end
334
- Registry.at('Foo').docstring.should == "docstring 2"
334
+ expect(Registry.at('Foo').docstring).to eq "docstring 2"
335
335
  end
336
336
  threads.each {|t| t.join }
337
337
  end
338
338
 
339
- it "should allow setting of yardoc_file in separate threads" do
339
+ it "allows setting of yardoc_file in separate threads" do
340
340
  barrier = 0
341
341
  mutex = Mutex.new
342
342
  threads = []
343
343
  threads << Thread.new do
344
- Registry.yardoc_file.should == '.yardoc'
344
+ expect(Registry.yardoc_file).to eq '.yardoc'
345
345
  Registry.yardoc_file = 'foo'
346
346
  mutex.synchronize { barrier += 1 }
347
347
  while barrier == 1 do
348
348
  s = "barrier = 1, spinning"
349
349
  end
350
- Registry.yardoc_file.should == 'foo'
350
+ expect(Registry.yardoc_file).to eq 'foo'
351
351
  end
352
352
  threads << Thread.new do
353
353
  while barrier == 0 do
354
354
  s = "barrier = 0, spinning"
355
355
  end
356
- Registry.yardoc_file.should == '.yardoc'
356
+ expect(Registry.yardoc_file).to eq '.yardoc'
357
357
  mutex.synchronize { barrier += 1 }
358
358
  Registry.yardoc_file = 'foo2'
359
359
  end
@@ -361,28 +361,28 @@ describe YARD::Registry do
361
361
  Registry.yardoc_file = Registry::DEFAULT_YARDOC_FILE
362
362
  end
363
363
 
364
- it "should automatically clear in new threads" do
365
- Thread.new { Registry.all.should be_empty }.join
364
+ it "automatically clears in new threads" do
365
+ Thread.new { expect(Registry.all).to be_empty }.join
366
366
  end
367
367
 
368
- it "should allow setting of po_dir in separate threads" do
368
+ it "allows setting of po_dir in separate threads" do
369
369
  barrier = 0
370
370
  mutex = Mutex.new
371
371
  threads = []
372
372
  threads << Thread.new do
373
- Registry.po_dir.should == 'po'
373
+ expect(Registry.po_dir).to eq 'po'
374
374
  Registry.po_dir = 'locale'
375
375
  mutex.synchronize { barrier += 1 }
376
376
  while barrier == 1 do
377
377
  s = "barrier = 1, spinning"
378
378
  end
379
- Registry.po_dir.should == 'locale'
379
+ expect(Registry.po_dir).to eq 'locale'
380
380
  end
381
381
  threads << Thread.new do
382
382
  while barrier == 0 do
383
383
  s = "barrier = 0, spinning"
384
384
  end
385
- Registry.po_dir.should == 'po'
385
+ expect(Registry.po_dir).to eq 'po'
386
386
  mutex.synchronize { barrier += 1 }
387
387
  Registry.po_dir = '.'
388
388
  end