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,37 +3,37 @@ require 'ostruct'
3
3
 
4
4
  describe YARD::Server::Commands::LibraryCommand do
5
5
  before do
6
- Templates::Engine.stub!(:render)
7
- Templates::Engine.stub!(:generate)
8
- YARD.stub!(:parse)
9
- Registry.stub!(:load)
10
- Registry.stub!(:save)
6
+ allow(Templates::Engine).to receive(:render)
7
+ allow(Templates::Engine).to receive(:generate)
8
+ allow(YARD).to receive(:parse)
9
+ allow(Registry).to receive(:load)
10
+ allow(Registry).to receive(:save)
11
11
 
12
12
  @cmd = LibraryCommand.new(:adapter => mock_adapter)
13
13
  @request = OpenStruct.new(:xhr? => false, :path => "/foo")
14
14
  @library = OpenStruct.new(:source_path => '.')
15
15
  @cmd.library = @library
16
- @cmd.stub!(:load_yardoc).and_return(nil)
16
+ allow(@cmd).to receive(:load_yardoc).and_return(nil)
17
17
  end
18
18
 
19
19
  def call
20
- lambda { @cmd.call(@request) }.should raise_error(NotImplementedError)
20
+ expect { @cmd.call(@request) }.to raise_error(NotImplementedError)
21
21
  end
22
22
 
23
23
  describe "#call" do
24
- it "should raise NotImplementedError" do
24
+ it "raises NotImplementedError" do
25
25
  call
26
26
  end
27
27
 
28
- it "should set :rdoc as the default markup in incremental mode" do
28
+ it "sets :rdoc as the default markup in incremental mode" do
29
29
  @cmd.incremental = true
30
30
  call
31
- @cmd.options[:markup].should == :rdoc
31
+ expect(@cmd.options[:markup]).to eq :rdoc
32
32
  end
33
33
 
34
- it "should set :rdoc as the default markup in regular mode" do
34
+ it "sets :rdoc as the default markup in regular mode" do
35
35
  call
36
- @cmd.options[:markup].should == :rdoc
36
+ expect(@cmd.options[:markup]).to eq :rdoc
37
37
  end
38
38
  end
39
39
  end
@@ -7,60 +7,60 @@ describe YARD::Server::Commands::StaticFileCommand do
7
7
  @cmd = StaticFileCommand.new(:adapter => adapter)
8
8
  end
9
9
 
10
- describe '#run' do
10
+ describe "#run" do
11
11
  def run(path, status = nil, body = nil)
12
12
  s, h, b = *@cmd.call(mock_request(path))
13
- body.should == b.first if body
14
- status.should == s if status
13
+ expect(body).to eq b.first if body
14
+ expect(status).to eq s if status
15
15
  [s, h, b]
16
16
  end
17
17
 
18
- it "should search through document root before static paths" do
19
- File.should_receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
18
+ it "searches through document root before static paths" do
19
+ expect(File).to receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
20
20
  StaticFileCommand::STATIC_PATHS.reverse.each do |path|
21
- File.should_receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
21
+ expect(File).to receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
22
22
  end
23
23
  run '/path/to/file.txt'
24
24
  end
25
25
 
26
- it "should return file contents if found" do
26
+ it "returns file contents if found" do
27
27
  tpl = Templates::Engine.template(:default, :fulldoc, :html)
28
- File.should_receive(:exist?).with('/c/path/to/file.txt').and_return(false)
29
- tpl.should_receive(:find_file).with('/path/to/file.txt').and_return('/path/to/foo')
30
- File.should_receive(:read).with('/path/to/foo').and_return('FOO')
28
+ expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(false)
29
+ expect(tpl).to receive(:find_file).with('/path/to/file.txt').and_return('/path/to/foo')
30
+ expect(File).to receive(:read).with('/path/to/foo').and_return('FOO')
31
31
  run('/path/to/file.txt', 200, 'FOO')
32
32
  end
33
33
 
34
- it "should allow registering of new paths and use those before other static paths" do
34
+ it "allows registering of new paths and use those before other static paths" do
35
35
  Server.register_static_path '/foo'
36
36
  path = '/foo/path/to/file.txt'
37
- File.should_receive(:exist?).with('/c/path/to/file.txt').and_return(false)
38
- File.should_receive(:exist?).with(path).and_return(true)
39
- File.should_receive(:read).with(path).and_return('FOO')
37
+ expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(false)
38
+ expect(File).to receive(:exist?).with(path).and_return(true)
39
+ expect(File).to receive(:read).with(path).and_return('FOO')
40
40
  run('/path/to/file.txt', 200, 'FOO')
41
41
  end
42
42
 
43
- it "should not use registered path before docroot" do
43
+ it "does not use registered path before docroot" do
44
44
  Server.register_static_path '/foo'
45
45
  path = '/foo/path/to/file.txt'
46
- File.should_receive(:exist?).with('/c/path/to/file.txt').and_return(true)
47
- File.should_receive(:read).with('/c/path/to/file.txt').and_return('FOO')
46
+ expect(File).to receive(:exist?).with('/c/path/to/file.txt').and_return(true)
47
+ expect(File).to receive(:read).with('/c/path/to/file.txt').and_return('FOO')
48
48
  run('/c/path/to/file.txt', 200, 'FOO')
49
49
  end
50
50
 
51
- it "should return 404 if not found" do
52
- File.should_receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
51
+ it "returns 404 if not found" do
52
+ expect(File).to receive(:exist?).with('/c/path/to/file.txt').ordered.and_return(false)
53
53
  StaticFileCommand::STATIC_PATHS.reverse.each do |path|
54
- File.should_receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
54
+ expect(File).to receive(:exist?).with(File.join(path, 'path/to/file.txt')).ordered.and_return(false)
55
55
  end
56
56
  run('/path/to/file.txt', 404)
57
57
  end
58
58
 
59
- it "should return text/html for file with no extension" do
60
- File.should_receive(:exist?).with('/c/file').and_return(true)
61
- File.should_receive(:read).with('/c/file')
59
+ it "returns text/html for file with no extension" do
60
+ expect(File).to receive(:exist?).with('/c/file').and_return(true)
61
+ expect(File).to receive(:read).with('/c/file')
62
62
  s, h, b = *run('/file')
63
- h['Content-Type'].should == 'text/html'
63
+ expect(h['Content-Type']).to eq 'text/html'
64
64
  end
65
65
 
66
66
  {
@@ -73,11 +73,11 @@ describe YARD::Server::Commands::StaticFileCommand do
73
73
  "txt" => "text/plain",
74
74
  "unknown" => "application/octet-stream"
75
75
  }.each do |ext, mime|
76
- it "should serve file.#{ext} as #{mime}" do
77
- File.should_receive(:exist?).with('/c/file.' + ext).and_return(true)
78
- File.should_receive(:read).with('/c/file.' + ext)
76
+ it "serves file.#{ext} as #{mime}" do
77
+ expect(File).to receive(:exist?).with('/c/file.' + ext).and_return(true)
78
+ expect(File).to receive(:read).with('/c/file.' + ext)
79
79
  s, h, b = *run('/file.' + ext)
80
- h['Content-Type'].should == mime
80
+ expect(h['Content-Type']).to eq mime
81
81
  end
82
82
  end
83
83
  end
@@ -31,23 +31,23 @@ describe YARD::Server::DocServerHelper do
31
31
  @helper = MockDocServerHelper.new
32
32
  end
33
33
 
34
- describe '#url_for' do
35
- it "should not link to /library/ if single_library = true" do
34
+ describe "#url_for" do
35
+ it "does not link to /library/ if single_library = true" do
36
36
  @helper.single_library = true
37
- @helper.url_for(Registry.root).should == "/PREFIX/toplevel"
37
+ expect(@helper.url_for(Registry.root)).to eq "/PREFIX/toplevel"
38
38
  end
39
39
 
40
- it "should return /PREFIX/foo/version if foo has a version" do
40
+ it "returns /PREFIX/foo/version if foo has a version" do
41
41
  @helper.library = LibraryVersion.new('foo', 'bar')
42
42
  @helper.adapter.router.request.version_supplied = true
43
- @helper.url_for(P('A')).should == '/PREFIX/foo/bar/A'
43
+ expect(@helper.url_for(P('A'))).to eq '/PREFIX/foo/bar/A'
44
44
  end
45
45
  end
46
46
 
47
- describe '#url_for_file' do
48
- it "should properly link file objects using file/ prefix" do
47
+ describe "#url_for_file" do
48
+ it "properly links file objects using file/ prefix" do
49
49
  file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
50
- @helper.url_for_file(file).should == '/PREFIX/foo/file/a/b/FooBar.md'
50
+ expect(@helper.url_for_file(file)).to eq '/PREFIX/foo/file/a/b/FooBar.md'
51
51
  end
52
52
  end
53
53
  end
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe YARD::Server::DocServerSerializer do
4
- describe '#serialized_path' do
4
+ describe "#serialized_path" do
5
5
  before do
6
6
  Registry.clear
7
7
  @serializer = Server::DocServerSerializer.new
@@ -9,45 +9,50 @@ describe YARD::Server::DocServerSerializer do
9
9
 
10
10
  after(:all) { Server::Adapter.shutdown }
11
11
 
12
- it "should return '/PREFIX/library/toplevel' for root" do
13
- @serializer.serialized_path(Registry.root).should == "toplevel"
12
+ it "returns '/PREFIX/library/toplevel' for root" do
13
+ expect(@serializer.serialized_path(Registry.root)).to eq "toplevel"
14
14
  end
15
15
 
16
- it "should return /PREFIX/library/Object for Object in a library" do
17
- @serializer.serialized_path(P('A::B::C')).should == 'A/B/C'
16
+ it "returns /PREFIX/library/Object for Object in a library" do
17
+ expect(@serializer.serialized_path(P('A::B::C'))).to eq 'A/B/C'
18
18
  end
19
19
 
20
- it "should link to instance method as Class:method" do
20
+ it "links to instance method as Class:method" do
21
21
  obj = CodeObjects::MethodObject.new(:root, :method)
22
- @serializer.serialized_path(obj).should == 'toplevel:method'
22
+ expect(@serializer.serialized_path(obj)).to eq 'toplevel:method'
23
23
  end
24
24
 
25
- it "should link to class method as Class.method" do
25
+ it "links to class method as Class.method" do
26
26
  obj = CodeObjects::MethodObject.new(:root, :method, :class)
27
- @serializer.serialized_path(obj).should == 'toplevel.method'
27
+ expect(@serializer.serialized_path(obj)).to eq 'toplevel.method'
28
28
  end
29
29
 
30
- it "should link to anchor for constant" do
30
+ it "links to anchor for constant" do
31
31
  obj = CodeObjects::ConstantObject.new(:root, :FOO)
32
- @serializer.serialized_path(obj).should == 'toplevel#FOO-constant'
32
+ expect(@serializer.serialized_path(obj)).to eq 'toplevel#FOO-constant'
33
33
  end
34
34
 
35
- it "should link to anchor for class variable" do
35
+ it "links to anchor for class variable" do
36
36
  obj = CodeObjects::ClassVariableObject.new(:root, :@@foo)
37
- @serializer.serialized_path(obj).should == 'toplevel#@@foo-classvariable'
37
+ expect(@serializer.serialized_path(obj)).to eq 'toplevel#@@foo-classvariable'
38
38
  end
39
39
 
40
- it "should link files using file/ prefix" do
40
+ it "links files using file/ prefix" do
41
41
  file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
42
- @serializer.serialized_path(file).should == 'file/FooBar'
42
+ expect(@serializer.serialized_path(file)).to eq 'file/FooBar'
43
43
  end
44
44
 
45
- it "should handle unicode data" do
45
+ it "escapes special characters" do
46
+ obj = CodeObjects::MethodObject.new(:root, :method?)
47
+ expect(@serializer.serialized_path(obj)).to eq 'toplevel:method%3F'
48
+ end
49
+
50
+ it "handles unicode data" do
46
51
  file = CodeObjects::ExtraFileObject.new("test\u0160", '')
47
52
  if file.name.encoding == Encoding.find("Windows-1252")
48
- @serializer.serialized_path(file).should == 'file/test_8A'
53
+ expect(@serializer.serialized_path(file)).to eq 'file/test_8A'
49
54
  else
50
- @serializer.serialized_path(file).should == 'file/test_C5A0'
55
+ expect(@serializer.serialized_path(file)).to eq 'file/test_C5A0'
51
56
  end
52
57
  end if defined?(::Encoding)
53
58
  end
@@ -3,18 +3,18 @@ require File.dirname(__FILE__) + "/spec_helper"
3
3
  describe "YARD::Server::RackMiddleware" do
4
4
  before do
5
5
  begin; require 'rack'; rescue LoadError; pending "rack required for these tests" end
6
- @superapp = mock(:superapp)
6
+ @superapp = double(:superapp)
7
7
  @app = YARD::Server::RackMiddleware.new(@superapp, :libraries => {'foo' => [LibraryVersion.new('foo', nil)]})
8
8
  end
9
9
 
10
10
  after(:all) { YARD::Server::Adapter.shutdown }
11
11
 
12
- it "should handle requests" do
13
- @app.call(Rack::MockRequest.env_for('/'))[0].should == 200
12
+ it "handles requests" do
13
+ expect(@app.call(Rack::MockRequest.env_for('/'))[0]).to eq 200
14
14
  end
15
15
 
16
- it "should pass up to the next middleware on 404" do
17
- @superapp.should_receive(:call).and_return([200, {}, ['OK']])
18
- @app.call(Rack::MockRequest.env_for('/INVALID')).should == [200, {}, ['OK']]
16
+ it "passes up to the next middleware on 404" do
17
+ expect(@superapp).to receive(:call).and_return([200, {}, ['OK']])
18
+ expect(@app.call(Rack::MockRequest.env_for('/INVALID'))).to eq [200, {}, ['OK']]
19
19
  end
20
20
  end
@@ -15,7 +15,7 @@ describe YARD::Server::Router do
15
15
  @request = mock_request
16
16
  end
17
17
 
18
- describe '#parse_library_from_path' do
18
+ describe "#parse_library_from_path" do
19
19
  def parse(*args)
20
20
  @request.path = '/' + args.join('/')
21
21
  @router = MyRouterSpecRouter.new(@adapter)
@@ -23,36 +23,36 @@ describe YARD::Server::Router do
23
23
  @router.parse_library_from_path(args.flatten)
24
24
  end
25
25
 
26
- it "should parse library and version name out of path" do
27
- parse('project', '1.0.0').should == [@projects[0], []]
28
- @request.version_supplied.should be_true
26
+ it "parses library and version name out of path" do
27
+ expect(parse('project', '1.0.0')).to eq [@projects[0], []]
28
+ expect(@request.version_supplied).to be true
29
29
  end
30
30
 
31
- it "should parse library and use latest version if version is not supplied" do
32
- parse('project').should == [@projects[1], []]
33
- @request.version_supplied.should be_false
31
+ it "parses library and use latest version if version is not supplied" do
32
+ expect(parse('project')).to eq [@projects[1], []]
33
+ expect(@request.version_supplied).to be false
34
34
  end
35
35
 
36
- it "should parse library and use latest version if next component is not a version" do
37
- parse('project', 'notaversion').should == [@projects[1], ['notaversion']]
38
- @request.version_supplied.should be_false
36
+ it "parses library and use latest version if next component is not a version" do
37
+ expect(parse('project', 'notaversion')).to eq [@projects[1], ['notaversion']]
38
+ expect(@request.version_supplied).to be false
39
39
  end
40
40
 
41
- it "should return nil library if no library is found" do
42
- parse('notproject').should == [nil, ['notproject']]
41
+ it "returns nil library if no library is found" do
42
+ expect(parse('notproject')).to eq [nil, ['notproject']]
43
43
  end
44
44
 
45
- it "should not parse library or version if single_library == true" do
46
- @adapter.stub!(:options).and_return(:single_library => true)
47
- parse('notproject').should == [@projects[0], ['notproject']]
45
+ it "does not parse library or version if single_library == true" do
46
+ allow(@adapter).to receive(:options).and_return(:single_library => true)
47
+ expect(parse('notproject')).to eq [@projects[0], ['notproject']]
48
48
  end
49
49
  end
50
50
 
51
- describe '#route' do
51
+ describe "#route" do
52
52
  def route_to(route, command, *args)
53
53
  req = mock_request(route)
54
54
  router = MyRouterSpecRouter.new(@adapter)
55
- command.should_receive(:new).and_return do |*args|
55
+ expect(command).to receive(:new) do |*args|
56
56
  @command = command.allocate
57
57
  @command.send(:initialize, *args)
58
58
  class << @command; def call(req); self end end
@@ -61,61 +61,61 @@ describe YARD::Server::Router do
61
61
  router.call(req)
62
62
  end
63
63
 
64
- it "should route /docs/OBJECT to object if single_library = true" do
65
- @adapter.stub!(:options).and_return(:single_library => true)
64
+ it "routes /docs/OBJECT to object if single_library = true" do
65
+ allow(@adapter).to receive(:options).and_return(:single_library => true)
66
66
  route_to('/mydocs/foo/FOO', DisplayObjectCommand)
67
67
  end
68
68
 
69
- it "should route /docs" do
69
+ it "routes /docs" do
70
70
  route_to('/mydocs/foo', LibraryIndexCommand)
71
71
  end
72
72
 
73
- it "should route /docs as index for library if single_library == true" do
74
- @adapter.stub!(:options).and_return(:single_library => true)
73
+ it "routes /docs as index for library if single_library == true" do
74
+ allow(@adapter).to receive(:options).and_return(:single_library => true)
75
75
  route_to('/mydocs/foo/', DisplayObjectCommand)
76
76
  end
77
77
 
78
- it "should route /docs/name/version" do
78
+ it "routes /docs/name/version" do
79
79
  route_to('/mydocs/foo/project/1.0.0', DisplayObjectCommand)
80
- @command.library.should == @projects[0]
80
+ expect(@command.library).to eq @projects[0]
81
81
  end
82
82
 
83
- it "should route /docs/name/ to latest version of library" do
83
+ it "routes /docs/name/ to latest version of library" do
84
84
  route_to('/mydocs/foo/project', DisplayObjectCommand)
85
- @command.library.should == @projects[1]
85
+ expect(@command.library).to eq @projects[1]
86
86
  end
87
87
 
88
- it "should route /list/name/version/class" do
88
+ it "routes /list/name/version/class" do
89
89
  route_to('/mylist/foo/project/1.0.0/class', ListCommand)
90
- @command.library.should == @projects[0]
90
+ expect(@command.library).to eq @projects[0]
91
91
  end
92
92
 
93
- it "should route /list/name/version/methods" do
93
+ it "routes /list/name/version/methods" do
94
94
  route_to('/mylist/foo/project/1.0.0/methods', ListCommand)
95
- @command.library.should == @projects[0]
95
+ expect(@command.library).to eq @projects[0]
96
96
  end
97
97
 
98
- it "should route /list/name/version/files" do
98
+ it "routes /list/name/version/files" do
99
99
  route_to('/mylist/foo/project/1.0.0/files', ListCommand)
100
- @command.library.should == @projects[0]
100
+ expect(@command.library).to eq @projects[0]
101
101
  end
102
102
 
103
- it "should route /list/name to latest version of library" do
103
+ it "routes /list/name to latest version of library" do
104
104
  route_to('/mylist/foo/project/class', ListCommand)
105
- @command.library.should == @projects[1]
105
+ expect(@command.library).to eq @projects[1]
106
106
  end
107
107
 
108
- it "should route /search/name/version" do
108
+ it "routes /search/name/version" do
109
109
  route_to('/mysearch/foo/project/1.0.0', SearchCommand)
110
- @command.library.should == @projects[0]
110
+ expect(@command.library).to eq @projects[0]
111
111
  end
112
112
 
113
- it "should route /search/name to latest version of library" do
113
+ it "routes /search/name to latest version of library" do
114
114
  route_to('/mysearch/foo/project', SearchCommand)
115
- @command.library.should == @projects[1]
115
+ expect(@command.library).to eq @projects[1]
116
116
  end
117
117
 
118
- it "should search static files for non-existent library" do
118
+ it "searches static files for non-existent library" do
119
119
  route_to('/mydocs/foo/notproject', StaticFileCommand)
120
120
  end
121
121
  end
@@ -3,37 +3,37 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe YARD::Server::StaticCaching do
4
4
  include StaticCaching
5
5
 
6
- describe '#check_static_cache' do
6
+ describe "#check_static_cache" do
7
7
  def adapter; @adapter ||= mock_adapter end
8
8
  def request; @request ||= OpenStruct.new end
9
9
 
10
- it "should return nil if document root is not set" do
10
+ it "returns nil if document root is not set" do
11
11
  adapter.document_root = nil
12
- check_static_cache.should be_nil
12
+ expect(check_static_cache).to be nil
13
13
  end
14
14
 
15
- it "should read a file from document root if path matches file on system" do
15
+ it "reads a file from document root if path matches file on system" do
16
16
  request.path = '/hello/world.html'
17
- File.should_receive(:file?).with('/public/hello/world.html').and_return(true)
18
- File.should_receive(:open).with('/public/hello/world.html', anything).and_return('body')
17
+ expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true)
18
+ expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body')
19
19
  s, h, b = *check_static_cache
20
- s.should == 200
21
- b.should == ["body"]
20
+ expect(s).to eq 200
21
+ expect(b).to eq ["body"]
22
22
  end
23
23
 
24
- it "should read a file if path matches file on system + .html" do
24
+ it "reads a file if path matches file on system + .html" do
25
25
  request.path = '/hello/world'
26
- File.should_receive(:file?).with('/public/hello/world.html').and_return(true)
27
- File.should_receive(:open).with('/public/hello/world.html', anything).and_return('body')
26
+ expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true)
27
+ expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body')
28
28
  s, h, b = *check_static_cache
29
- s.should == 200
30
- b.should == ["body"]
29
+ expect(s).to eq 200
30
+ expect(b).to eq ["body"]
31
31
  end
32
32
 
33
- it "should return nil if no matching file is found" do
33
+ it "returns nil if no matching file is found" do
34
34
  request.path = '/hello/foo'
35
- File.should_receive(:file?).with('/public/hello/foo.html').and_return(false)
36
- check_static_cache.should == nil
35
+ expect(File).to receive(:file?).with('/public/hello/foo.html').and_return(false)
36
+ expect(check_static_cache).to eq nil
37
37
  end
38
38
  end
39
39
  end