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
@@ -5,104 +5,104 @@ require 'fileutils'
5
5
  describe Gem::DocManager do
6
6
  before do
7
7
  # Ensure filesystem integrity
8
- FileUtils.stub(:mkdir_p)
9
- FileUtils.stub(:rm_rf)
10
- Dir.stub(:chdir)
8
+ allow(FileUtils).to receive(:mkdir_p)
9
+ allow(FileUtils).to receive(:rm_rf)
10
+ allow(Dir).to receive(:chdir)
11
11
 
12
- YARD::CLI::Yardoc.stub(:run)
12
+ allow(YARD::CLI::Yardoc).to receive(:run)
13
13
 
14
14
  @spec_file = File.join(YARD::ROOT, '..', 'yard.gemspec')
15
15
  @spec = Gem::SourceIndex.load_specification(@spec_file)
16
16
  @spec.has_yardoc = false # no yardoc docs for now
17
17
  @yardopts = File.join(@spec.full_gem_path, '.yardopts')
18
18
  @doc = Gem::DocManager.new(@spec)
19
- @doc.stub(:install_ri_yard_orig)
20
- @doc.stub(:install_rdoc_yard_orig)
19
+ allow(@doc).to receive(:install_ri_yard_orig)
20
+ allow(@doc).to receive(:install_rdoc_yard_orig)
21
21
  end
22
22
 
23
- def runs; YARD::CLI::Yardoc.should_receive(:run) end
23
+ def runs; expect(YARD::CLI::Yardoc).to receive(:run) end
24
24
 
25
- describe '.load_yardoc' do
26
- it "should properly load YARD" do
27
- Gem::DocManager.should_receive(:require) do |path|
28
- File.expand_path(path).should == YARD::ROOT + '/yard'
25
+ describe ".load_yardoc" do
26
+ it "properly loads YARD" do
27
+ expect(Gem::DocManager).to receive(:require) do |path|
28
+ expect(File.expand_path(path)).to eq YARD::ROOT + '/yard'
29
29
  end
30
30
  Gem::DocManager.load_yardoc
31
31
  end
32
32
  end
33
33
 
34
- describe '#install_ri_yard' do
34
+ describe "#install_ri_yard" do
35
35
  def install
36
36
  msg = "Building YARD (yri) index for #{@spec.full_name}..."
37
- @doc.should_receive(:say).with(msg)
37
+ expect(@doc).to receive(:say).with(msg)
38
38
  @doc.install_ri_yard
39
39
  end
40
40
 
41
- it "should pass --quiet to all documentation" do
41
+ it "passes --quiet to all documentation" do
42
42
  runs.with('-c', '-n', '--quiet', 'lib')
43
43
  install
44
44
  end
45
45
 
46
- it "should pass extra_rdoc_files to documentation" do
46
+ it "passes extra_rdoc_files to documentation" do
47
47
  @spec.extra_rdoc_files = %w(README LICENSE)
48
48
  runs.with('-c', '-n', '--quiet', 'lib', '-', 'README', 'LICENSE')
49
49
  install
50
50
  end
51
51
 
52
- it "should add --backtrace if Gem.configuration.backtrace" do
52
+ it "adds --backtrace if Gem.configuration.backtrace" do
53
53
  Gem.configuration.backtrace = true
54
54
  runs.with('-c', '-n', '--quiet', '--backtrace', 'lib')
55
55
  install
56
56
  Gem.configuration.backtrace = false
57
57
  end
58
58
 
59
- it "should add require_paths if there is no .yardopts" do
60
- File.should_receive(:file?).with(@yardopts).and_return(true)
59
+ it "adds require_paths if there is no .yardopts" do
60
+ expect(File).to receive(:file?).with(@yardopts).and_return(true)
61
61
  runs.with('-c', '-n', '--quiet')
62
62
  install
63
63
  end
64
64
 
65
- it "should add extra_rdoc_files if there is no .yardopts" do
65
+ it "adds extra_rdoc_files if there is no .yardopts" do
66
66
  @spec.extra_rdoc_files = %w(README LICENSE)
67
- File.should_receive(:file?).with(@yardopts).and_return(true)
67
+ expect(File).to receive(:file?).with(@yardopts).and_return(true)
68
68
  runs.with('-c', '-n', '--quiet')
69
69
  install
70
70
  end
71
71
 
72
- it "should switch to directory before running command" do
72
+ it "switches to directory before running command" do
73
73
  old = Dir.pwd
74
- Dir.should_receive(:chdir).with(@spec.full_gem_path)
75
- Dir.should_receive(:chdir).with(old)
74
+ expect(Dir).to receive(:chdir).with(@spec.full_gem_path)
75
+ expect(Dir).to receive(:chdir).with(old)
76
76
  install
77
77
  end
78
78
 
79
- it "should ensure that directory is switched back at end of command in failure" do
79
+ it "ensures that directory is switched back at end of command in failure" do
80
80
  old = Dir.pwd
81
- Dir.should_receive(:chdir).with(@spec.full_gem_path)
82
- Dir.should_receive(:chdir).with(old)
83
- @doc.ui.errs.should_receive(:puts).with(/ERROR:\s*While generating documentation/)
84
- @doc.ui.errs.should_receive(:puts).with(/MESSAGE:\s*foo/)
85
- @doc.ui.errs.should_receive(:puts).with(/YARDOC args:\s*-c -n --quiet lib/)
86
- @doc.ui.errs.should_receive(:puts).with("(continuing with the rest of the installation)")
87
- YARD::CLI::Yardoc.should_receive(:run).and_raise(RuntimeError.new("foo"))
81
+ expect(Dir).to receive(:chdir).with(@spec.full_gem_path)
82
+ expect(Dir).to receive(:chdir).with(old)
83
+ expect(@doc.ui.errs).to receive(:puts).with(/ERROR:\s*While generating documentation/)
84
+ expect(@doc.ui.errs).to receive(:puts).with(/MESSAGE:\s*foo/)
85
+ expect(@doc.ui.errs).to receive(:puts).with(/YARDOC args:\s*-c -n --quiet lib/)
86
+ expect(@doc.ui.errs).to receive(:puts).with("(continuing with the rest of the installation)")
87
+ expect(YARD::CLI::Yardoc).to receive(:run).and_raise(RuntimeError.new("foo"))
88
88
  install
89
89
  end
90
90
 
91
- it "should handle permission errors" do
92
- YARD::CLI::Yardoc.should_receive(:run).and_raise(Errno::EACCES.new("- dir"))
93
- lambda { install }.should raise_error(Gem::FilePermissionError)
91
+ it "handles permission errors" do
92
+ expect(YARD::CLI::Yardoc).to receive(:run).and_raise(Errno::EACCES.new("- dir"))
93
+ expect { install }.to raise_error(Gem::FilePermissionError)
94
94
  end
95
95
  end
96
96
 
97
- describe '#install_rdoc_yard' do
97
+ describe "#install_rdoc_yard" do
98
98
  def install
99
99
  msg = "Installing YARD documentation for #{@spec.full_name}..."
100
- @doc.should_receive(:say).with(msg)
100
+ expect(@doc).to receive(:say).with(msg)
101
101
  @doc.install_rdoc_yard
102
102
  end
103
103
 
104
- it "should add -o outdir when generating docs" do
105
- File.should_receive(:file?).with(@yardopts).and_return(true)
104
+ it "adds -o outdir when generating docs" do
105
+ expect(File).to receive(:file?).with(@yardopts).and_return(true)
106
106
  @spec.has_yardoc = true
107
107
  doc_dir = File.join(@doc.instance_variable_get("@doc_dir"), 'rdoc')
108
108
  runs.with('-o', doc_dir, '--quiet')
@@ -4,47 +4,46 @@ require 'stringio'
4
4
 
5
5
  describe YARD::Serializers::FileSystemSerializer do
6
6
  before do
7
- FileUtils.stub!(:mkdir_p)
8
- File.stub!(:open)
7
+ allow(FileUtils).to receive(:mkdir_p)
8
+ allow(File).to receive(:open)
9
9
  end
10
10
 
11
- describe '#basepath' do
12
- it "should default the base path to the 'doc/'" do
11
+ describe "#basepath" do
12
+ it "defaults the base path to the 'doc/'" do
13
13
  obj = Serializers::FileSystemSerializer.new
14
- obj.basepath.should == 'doc'
14
+ expect(obj.basepath).to eq 'doc'
15
15
  end
16
16
  end
17
17
 
18
- describe '#extension' do
19
- it "should default the file extension to .html" do
18
+ describe "#extension" do
19
+ it "defaults the file extension to .html" do
20
20
  obj = Serializers::FileSystemSerializer.new
21
- obj.extension.should == "html"
21
+ expect(obj.extension).to eq "html"
22
22
  end
23
23
  end
24
24
 
25
- describe '#serialized_path' do
26
- it "should allow no extension to be used" do
25
+ describe "#serialized_path" do
26
+ it "allows no extension to be used" do
27
27
  obj = Serializers::FileSystemSerializer.new :extension => nil
28
28
  yard = CodeObjects::ClassObject.new(nil, :FooBar)
29
- obj.serialized_path(yard).should == 'FooBar'
29
+ expect(obj.serialized_path(yard)).to eq 'FooBar'
30
30
  end
31
31
 
32
- it "should serialize to top-level-namespace for root" do
32
+ it "serializes to top-level-namespace for root" do
33
33
  obj = Serializers::FileSystemSerializer.new :extension => nil
34
- obj.serialized_path(Registry.root).should == "top-level-namespace"
34
+ expect(obj.serialized_path(Registry.root)).to eq "top-level-namespace"
35
35
  end
36
36
 
37
- it "should return serialized_path for a String" do
37
+ it "returns serialized_path for a String" do
38
38
  s = Serializers::FileSystemSerializer.new(:basepath => 'foo', :extension => 'txt')
39
- s.serialized_path('test.txt').should == 'test.txt'
39
+ expect(s.serialized_path('test.txt')).to eq 'test.txt'
40
40
  end
41
41
 
42
- it "should remove special chars from path" do
42
+ it "removes special chars from path" do
43
43
  m = CodeObjects::MethodObject.new(nil, 'a')
44
44
  s = Serializers::FileSystemSerializer.new
45
45
 
46
- { :/ => '_2F_i.html',
47
- :gsub! => 'gsub_21_i.html',
46
+ { :gsub! => 'gsub_21_i.html',
48
47
  :ask? => 'ask_3F_i.html',
49
48
  :=== => '_3D_3D_3D_i.html',
50
49
  :+ => '_2B_i.html',
@@ -59,25 +58,25 @@ describe YARD::Serializers::FileSystemSerializer do
59
58
  :/ => '_2F_i.html',
60
59
  :=~ => '_3D_7E_i.html'
61
60
  }.each do |meth, value|
62
- m.stub!(:name).and_return(meth)
63
- s.serialized_path(m).should == value
61
+ allow(m).to receive(:name).and_return(meth)
62
+ expect(s.serialized_path(m)).to eq value
64
63
  end
65
64
  end
66
65
 
67
- it "should handle ExtraFileObject's" do
66
+ it "handles ExtraFileObject's" do
68
67
  s = Serializers::FileSystemSerializer.new
69
68
  e = CodeObjects::ExtraFileObject.new('filename.txt', '')
70
- s.serialized_path(e).should == 'file.filename.html'
69
+ expect(s.serialized_path(e)).to eq 'file.filename.html'
71
70
  end
72
71
 
73
- it "should differentiate instance and class methods from serialized path" do
72
+ it "differentiates instance and class methods from serialized path" do
74
73
  s = Serializers::FileSystemSerializer.new
75
74
  m1 = CodeObjects::MethodObject.new(nil, 'meth')
76
75
  m2 = CodeObjects::MethodObject.new(nil, 'meth', :class)
77
- s.serialized_path(m1).should_not == s.serialized_path(m2)
76
+ expect(s.serialized_path(m1)).not_to eq s.serialized_path(m2)
78
77
  end
79
78
 
80
- it "should serialize path from overload tag" do
79
+ it "serializes path from overload tag" do
81
80
  YARD.parse_string <<-'eof'
82
81
  class Foo
83
82
  # @overload bar
@@ -87,12 +86,33 @@ describe YARD::Serializers::FileSystemSerializer do
87
86
 
88
87
  serializer = Serializers::FileSystemSerializer.new
89
88
  object = Registry.at('Foo#bar').tag(:overload)
90
- serializer.serialized_path(object).should == "Foo/bar_i.html"
89
+ expect(serializer.serialized_path(object)).to eq "Foo/bar_i.html"
90
+ end
91
+
92
+ it "maps matching case sensitive object names to different files on disk" do
93
+ Registry.clear
94
+ o1 = CodeObjects::ClassObject.new(:root, "AB")
95
+ o2 = CodeObjects::ClassObject.new(:root, "Ab")
96
+ s = Serializers::FileSystemSerializer.new
97
+ expect([["AB_.html", "Ab.html"], ["AB.html", "Ab_.html"]]).to include(
98
+ [s.serialized_path(o1), s.serialized_path(o2)])
99
+ end
100
+
101
+ it "handles case sensitivity of nested paths for objects with matching names" do
102
+ Registry.clear
103
+ YARD.parse_string <<-eof
104
+ class Abc; class D; end end
105
+ class ABC; class D; end end
106
+ eof
107
+
108
+ s = Serializers::FileSystemSerializer.new
109
+ expect(s.serialized_path(Registry.at('ABC::D'))).to eq "ABC/D.html"
110
+ expect(s.serialized_path(Registry.at('Abc::D'))).to eq "Abc/D.html"
91
111
  end
92
112
  end
93
113
 
94
- describe '#serialize' do
95
- it "should serialize to the correct path" do
114
+ describe "#serialize" do
115
+ it "serializes to the correct path" do
96
116
  yard = CodeObjects::ClassObject.new(nil, :FooBar)
97
117
  meth = CodeObjects::MethodObject.new(yard, :baz, :class)
98
118
  meth2 = CodeObjects::MethodObject.new(yard, :baz)
@@ -101,24 +121,24 @@ describe YARD::Serializers::FileSystemSerializer do
101
121
  'foo/FooBar/baz_i.txt' => meth2,
102
122
  'foo/FooBar.txt' => yard }.each do |path, obj|
103
123
  io = StringIO.new
104
- File.should_receive(:open).with(path, 'wb').and_yield(io)
105
- io.should_receive(:write).with("data")
124
+ expect(File).to receive(:open).with(path, 'wb').and_yield(io)
125
+ expect(io).to receive(:write).with("data")
106
126
 
107
127
  s = Serializers::FileSystemSerializer.new(:basepath => 'foo', :extension => 'txt')
108
128
  s.serialize(obj, "data")
109
129
  end
110
130
  end
111
131
 
112
- it "should guarantee the directory exists" do
132
+ it "guarantees the directory exists" do
113
133
  o1 = CodeObjects::ClassObject.new(nil, :Really)
114
134
  o2 = CodeObjects::ClassObject.new(o1, :Long)
115
135
  o3 = CodeObjects::ClassObject.new(o2, :PathName)
116
136
  obj = CodeObjects::MethodObject.new(o3, :foo)
117
137
 
118
- FileUtils.should_receive(:mkdir_p).once.with('doc/Really/Long/PathName')
138
+ expect(FileUtils).to receive(:mkdir_p).once.with('doc/Really/Long/PathName')
119
139
 
120
140
  s = Serializers::FileSystemSerializer.new
121
141
  s.serialize(obj, "data")
122
142
  end
123
143
  end
124
- end
144
+ end
@@ -16,30 +16,30 @@ describe YARD::Serializers::YardocSerializer do
16
16
  @bar = CodeObjects::MethodObject.new(@foo, :bar)
17
17
  end
18
18
 
19
- describe '#dump' do
20
- it "should maintain object equality when loading a dumped object" do
19
+ describe "#dump" do
20
+ it "maintains object equality when loading a dumped object" do
21
21
  newfoo = @serializer.internal_dump(@foo)
22
- newfoo.should equal(@foo)
23
- newfoo.should == @foo
24
- @foo.should equal(newfoo)
25
- @foo.should == newfoo
26
- newfoo.hash.should == @foo.hash
22
+ expect(newfoo).to equal(@foo)
23
+ expect(newfoo).to eq @foo
24
+ expect(@foo).to equal(newfoo)
25
+ expect(@foo).to eq newfoo
26
+ expect(newfoo.hash).to eq @foo.hash
27
27
  end
28
28
 
29
- it "should maintain hash key equality when loading a dumped object" do
29
+ it "maintains hash key equality when loading a dumped object" do
30
30
  newfoo = @serializer.internal_dump(@foo)
31
- {@foo => 1}.should have_key(newfoo)
32
- {newfoo => 1}.should have_key(@foo)
31
+ expect({@foo => 1}).to have_key(newfoo)
32
+ expect({newfoo => 1}).to have_key(@foo)
33
33
  end
34
34
  end
35
35
 
36
- describe '#serialize' do
37
- it "should accept a hash of codeobjects (and write to root)" do
36
+ describe "#serialize" do
37
+ it "accepts a hash of codeobjects (and write to root)" do
38
38
  data = {:root => Registry.root}
39
39
  marshaldata = Marshal.dump(data)
40
- filemock = mock(:file)
41
- filemock.should_receive(:write).with(marshaldata)
42
- File.should_receive(:open!).with('.yardoc/objects/root.dat', 'wb').and_yield(filemock)
40
+ filemock = double(:file)
41
+ expect(filemock).to receive(:write).with(marshaldata)
42
+ expect(File).to receive(:open!).with('.yardoc/objects/root.dat', 'wb').and_yield(filemock)
43
43
  @serializer.serialize(data)
44
44
  end
45
45
  end
@@ -3,36 +3,36 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe YARD::Server::Adapter do
4
4
  after(:all) { Server::Adapter.shutdown }
5
5
 
6
- describe '#add_library' do
7
- it "should add a library" do
6
+ describe "#add_library" do
7
+ it "adds a library" do
8
8
  lib = LibraryVersion.new('yard')
9
9
  a = Adapter.new({})
10
- a.libraries.should be_empty
10
+ expect(a.libraries).to be_empty
11
11
  a.add_library(lib)
12
- a.libraries['yard'].should == [lib]
12
+ expect(a.libraries['yard']).to eq [lib]
13
13
  end
14
14
  end
15
15
 
16
- describe '#start' do
17
- it "should not implement #start" do
18
- lambda { Adapter.new({}).start }.should raise_error(NotImplementedError)
16
+ describe "#start" do
17
+ it "does not implement #start" do
18
+ expect { Adapter.new({}).start }.to raise_error(NotImplementedError)
19
19
  end
20
20
  end
21
21
 
22
- describe '.setup' do
23
- it 'should add template paths and helpers' do
22
+ describe ".setup" do
23
+ it "adds template paths and helpers" do
24
24
  Adapter.setup
25
- Templates::Template.extra_includes.should include(DocServerHelper)
26
- Templates::Engine.template_paths.should include(YARD::ROOT + '/yard/server/templates')
25
+ expect(Templates::Template.extra_includes).to include(DocServerHelper)
26
+ expect(Templates::Engine.template_paths).to include(YARD::ROOT + '/yard/server/templates')
27
27
  end
28
28
  end
29
29
 
30
- describe '.shutdown' do
31
- it 'should cleanup template paths and helpers' do
30
+ describe ".shutdown" do
31
+ it "cleans up template paths and helpers" do
32
32
  Adapter.setup
33
33
  Adapter.shutdown
34
- Templates::Template.extra_includes.should_not include(DocServerHelper)
35
- Templates::Engine.template_paths.should_not include(YARD::ROOT + '/yard/server/templates')
34
+ expect(Templates::Template.extra_includes).not_to include(DocServerHelper)
35
+ expect(Templates::Engine.template_paths).not_to include(YARD::ROOT + '/yard/server/templates')
36
36
  end
37
37
  end
38
38
  end
@@ -9,79 +9,79 @@ class MyCacheCommand < Base
9
9
  end
10
10
 
11
11
  describe YARD::Server::Commands::Base do
12
- describe '#cache' do
12
+ describe "#cache" do
13
13
  before do
14
14
  @command = MyCacheCommand.new(:adapter => mock_adapter, :caching => true)
15
15
  @command.request = OpenStruct.new
16
16
  end
17
17
 
18
- it "should not cache if caching == false" do
19
- File.should_not_receive(:open)
18
+ it "does not cache if caching == false" do
19
+ expect(File).not_to receive(:open)
20
20
  @command.caching = false
21
21
  @command.run
22
22
  end
23
23
 
24
- it "should require document root to cache" do
25
- File.should_not_receive(:open)
24
+ it "requires document root to cache" do
25
+ expect(File).not_to receive(:open)
26
26
  @command.adapter.document_root = nil
27
27
  @command.run
28
28
  end
29
29
 
30
- it "should cache to path/to/file.html and create directories" do
31
- FileUtils.should_receive(:mkdir_p).with('/public/path/to')
32
- File.should_receive(:open).with('/public/path/to/file.html', anything)
30
+ it "caches to path/to/file.html and create directories" do
31
+ expect(FileUtils).to receive(:mkdir_p).with('/public/path/to')
32
+ expect(File).to receive(:open).with('/public/path/to/file.html', anything)
33
33
  @command.request.path = '/path/to/file.html'
34
34
  @command.run
35
35
  end
36
36
  end
37
37
 
38
- describe '#redirect' do
39
- it "should return a valid redirection" do
38
+ describe "#redirect" do
39
+ it "returns a valid redirection" do
40
40
  cmd = MyProcCommand.new { redirect '/foo' }
41
- cmd.call(mock_request('/foo')).should ==
42
- [302, {"Content-Type" => "text/html", "Location" => "/foo"}, [""]]
41
+ expect(cmd.call(mock_request('/foo'))).to eq(
42
+ [302, {"Content-Type" => "text/html", "Location" => "/foo"}, [""]])
43
43
  end
44
44
  end
45
45
 
46
- describe '#call' do
47
- it "should handle a NotFoundError and use message as body" do
46
+ describe "#call" do
47
+ it "handles a NotFoundError and use message as body" do
48
48
  cmd = MyProcCommand.new { raise NotFoundError, "hello world" }
49
49
  s, h, b = *cmd.call(mock_request('/foo'))
50
- s.should == 404
51
- b.should == ["hello world"]
50
+ expect(s).to eq 404
51
+ expect(b).to eq ["hello world"]
52
52
  end
53
53
 
54
- it "should not use message as body if not provided in NotFoundError" do
54
+ it "does not use message as body if not provided in NotFoundError" do
55
55
  cmd = MyProcCommand.new { raise NotFoundError }
56
56
  s, h, b = *cmd.call(mock_request('/foo'))
57
- s.should == 404
58
- b.should == ["Not found: /foo"]
57
+ expect(s).to eq 404
58
+ expect(b).to eq ["Not found: /foo"]
59
59
  end
60
60
 
61
- it "should handle 404 status code from #run" do
61
+ it "handles 404 status code from #run" do
62
62
  cmd = MyProcCommand.new { self.status = 404 }
63
63
  s, h, b = *cmd.call(mock_request('/foo'))
64
- s.should == 404
65
- b.should == ["Not found: /foo"]
64
+ expect(s).to eq 404
65
+ expect(b).to eq ["Not found: /foo"]
66
66
  end
67
67
 
68
- it "should not override body if status is 404 and body is defined" do
68
+ it "does not override body if status is 404 and body is defined" do
69
69
  cmd = MyProcCommand.new { self.body = "foo"; self.status = 404 }
70
70
  s, h, b = *cmd.call(mock_request('/bar'))
71
- s.should == 404
72
- b.should == ['foo']
71
+ expect(s).to eq 404
72
+ expect(b).to eq ['foo']
73
73
  end
74
74
 
75
- it "should handle body as Array" do
75
+ it "handles body as Array" do
76
76
  cmd = MyProcCommand.new { self.body = ['a', 'b', 'c'] }
77
77
  s, h, b = *cmd.call(mock_request('/foo'))
78
- b.should == %w(a b c)
78
+ expect(b).to eq %w(a b c)
79
79
  end
80
80
 
81
- it "should allow headers to be defined" do
81
+ it "allows headers to be defined" do
82
82
  cmd = MyProcCommand.new { self.headers['Foo'] = 'BAR' }
83
83
  s, h, b = *cmd.call(mock_request('/foo'))
84
- h['Foo'].should == 'BAR'
84
+ expect(h['Foo']).to eq 'BAR'
85
85
  end
86
86
  end
87
87
  end