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
@@ -7,105 +7,105 @@ describe YARD::RegistryStore do
7
7
  @serializer = Serializers::YardocSerializer.new('foo')
8
8
  @foo = CodeObjects::MethodObject.new(nil, :foo)
9
9
  @bar = CodeObjects::ClassObject.new(nil, :Bar)
10
- Serializers::YardocSerializer.stub!(:new).and_return(@serializer)
10
+ allow(Serializers::YardocSerializer).to receive(:new).and_return(@serializer)
11
11
  end
12
12
 
13
- describe '#load' do
14
- it "should load root.dat as full object list if it is a Hash" do
15
- File.should_receive(:directory?).with('foo').and_return(true)
16
- File.should_receive(:file?).with('foo/checksums').and_return(false)
17
- File.should_receive(:file?).with('foo/proxy_types').and_return(false)
18
- File.should_receive(:file?).with('foo/object_types').and_return(false)
19
- @serializer.should_receive(:deserialize).with('root').and_return({:root => @foo, :A => @bar})
20
- @store.load('foo').should == true
21
- @store.root.should == @foo
22
- @store.get('A').should == @bar
13
+ describe "#load" do
14
+ it "loads root.dat as full object list if it is a Hash" do
15
+ expect(File).to receive(:directory?).with('foo').and_return(true)
16
+ expect(File).to receive(:file?).with('foo/checksums').and_return(false)
17
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
18
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
19
+ expect(@serializer).to receive(:deserialize).with('root').and_return({:root => @foo, :A => @bar})
20
+ expect(@store.load('foo')).to be true
21
+ expect(@store.root).to eq @foo
22
+ expect(@store.get('A')).to eq @bar
23
23
  end
24
24
 
25
- it "should load old yardoc format if .yardoc is a file" do
26
- File.should_receive(:directory?).with('foo').and_return(false)
27
- File.should_receive(:file?).with('foo').and_return(true)
28
- File.should_receive(:read_binary).with('foo').and_return('FOO')
29
- Marshal.should_receive(:load).with('FOO')
25
+ it "loads old yardoc format if .yardoc is a file" do
26
+ expect(File).to receive(:directory?).with('foo').and_return(false)
27
+ expect(File).to receive(:file?).with('foo').and_return(true)
28
+ expect(File).to receive(:read_binary).with('foo').and_return('FOO')
29
+ expect(Marshal).to receive(:load).with('FOO')
30
30
 
31
31
  @store.load('foo')
32
32
  end
33
33
 
34
- it "should load new yardoc format if .yardoc is a directory" do
35
- File.should_receive(:directory?).with('foo').and_return(true)
36
- File.should_receive(:file?).with('foo/checksums').and_return(false)
37
- File.should_receive(:file?).with('foo/proxy_types').and_return(false)
38
- File.should_receive(:file?).with('foo/object_types').and_return(false)
39
- File.should_receive(:file?).with('foo/objects/root.dat').and_return(false)
34
+ it "loads new yardoc format if .yardoc is a directory" do
35
+ expect(File).to receive(:directory?).with('foo').and_return(true)
36
+ expect(File).to receive(:file?).with('foo/checksums').and_return(false)
37
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
38
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
39
+ expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
40
40
 
41
- @store.load('foo').should == true
41
+ expect(@store.load('foo')).to be true
42
42
  end
43
43
 
44
- it "should return true if .yardoc is loaded (file)" do
45
- File.should_receive(:directory?).with('myyardoc').and_return(false)
46
- File.should_receive(:file?).with('myyardoc').and_return(true)
47
- File.should_receive(:read_binary).with('myyardoc').and_return(Marshal.dump(''))
48
- @store.load('myyardoc').should == true
44
+ it "returns true if .yardoc is loaded (file)" do
45
+ expect(File).to receive(:directory?).with('myyardoc').and_return(false)
46
+ expect(File).to receive(:file?).with('myyardoc').and_return(true)
47
+ expect(File).to receive(:read_binary).with('myyardoc').and_return(Marshal.dump(''))
48
+ expect(@store.load('myyardoc')).to be true
49
49
  end
50
50
 
51
- it "should return true if .yardoc is loaded (directory)" do
52
- File.should_receive(:directory?).with('foo').and_return(true)
53
- File.should_receive(:file?).with('foo/checksums').and_return(false)
54
- File.should_receive(:file?).with('foo/proxy_types').and_return(false)
55
- File.should_receive(:file?).with('foo/object_types').and_return(false)
56
- File.should_receive(:file?).with('foo/objects/root.dat').and_return(false)
57
- @store.load('foo').should == true
51
+ it "returns true if .yardoc is loaded (directory)" do
52
+ expect(File).to receive(:directory?).with('foo').and_return(true)
53
+ expect(File).to receive(:file?).with('foo/checksums').and_return(false)
54
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
55
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
56
+ expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
57
+ expect(@store.load('foo')).to be true
58
58
  end
59
59
 
60
- it "should return false if .yardoc does not exist" do
61
- @store.load('NONEXIST').should == false
60
+ it "returns false if .yardoc does not exist" do
61
+ expect(@store.load('NONEXIST')).to be false
62
62
  end
63
63
 
64
- it "should return false if there is no file to load" do
65
- @store.load(nil).should == false
64
+ it "returns false if there is no file to load" do
65
+ expect(@store.load(nil)).to be false
66
66
  end
67
67
 
68
- it "should load checksums if they exist" do
69
- File.should_receive(:directory?).with('foo').and_return(true)
70
- File.should_receive(:file?).with('foo/checksums').and_return(true)
71
- File.should_receive(:file?).with('foo/proxy_types').and_return(false)
72
- File.should_receive(:file?).with('foo/objects/root.dat').and_return(false)
73
- File.should_receive(:file?).with('foo/object_types').and_return(false)
74
- File.should_receive(:readlines).with('foo/checksums').and_return([
68
+ it "loads checksums if they exist" do
69
+ expect(File).to receive(:directory?).with('foo').and_return(true)
70
+ expect(File).to receive(:file?).with('foo/checksums').and_return(true)
71
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
72
+ expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
73
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
74
+ expect(File).to receive(:readlines).with('foo/checksums').and_return([
75
75
  'file1 CHECKSUM1', ' file2 CHECKSUM2 '
76
76
  ])
77
- @store.load('foo').should == true
78
- @store.checksums.should == {'file1' => 'CHECKSUM1', 'file2' => 'CHECKSUM2'}
79
- end
80
-
81
- it "should load proxy_types if they exist" do
82
- File.should_receive(:directory?).with('foo').and_return(true)
83
- File.should_receive(:file?).with('foo/checksums').and_return(false)
84
- File.should_receive(:file?).with('foo/proxy_types').and_return(true)
85
- File.should_receive(:file?).with('foo/object_types').and_return(false)
86
- File.should_receive(:file?).with('foo/objects/root.dat').and_return(false)
87
- File.should_receive(:read_binary).with('foo/proxy_types').and_return(Marshal.dump({'a' => 'b'}))
88
- @store.load('foo').should == true
89
- @store.proxy_types.should == {'a' => 'b'}
90
- end
91
-
92
- it "should load root object if it exists" do
93
- File.should_receive(:directory?).with('foo').and_return(true)
94
- File.should_receive(:file?).with('foo/checksums').and_return(false)
95
- File.should_receive(:file?).with('foo/proxy_types').and_return(false)
96
- File.should_receive(:file?).with('foo/object_types').and_return(false)
97
- File.should_receive(:file?).with('foo/objects/root.dat').and_return(true)
98
- File.should_receive(:read_binary).with('foo/objects/root.dat').and_return(Marshal.dump(@foo))
99
- @store.load('foo').should == true
100
- @store.root.should == @foo
77
+ expect(@store.load('foo')).to be true
78
+ expect(@store.checksums).to eq({'file1' => 'CHECKSUM1', 'file2' => 'CHECKSUM2'})
79
+ end
80
+
81
+ it "loads proxy_types if they exist" do
82
+ expect(File).to receive(:directory?).with('foo').and_return(true)
83
+ expect(File).to receive(:file?).with('foo/checksums').and_return(false)
84
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(true)
85
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
86
+ expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
87
+ expect(File).to receive(:read_binary).with('foo/proxy_types').and_return(Marshal.dump({'a' => 'b'}))
88
+ expect(@store.load('foo')).to be true
89
+ expect(@store.proxy_types).to eq({'a' => 'b'})
90
+ end
91
+
92
+ it "loads root object if it exists" do
93
+ expect(File).to receive(:directory?).with('foo').and_return(true)
94
+ expect(File).to receive(:file?).with('foo/checksums').and_return(false)
95
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
96
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
97
+ expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(true)
98
+ expect(File).to receive(:read_binary).with('foo/objects/root.dat').and_return(Marshal.dump(@foo))
99
+ expect(@store.load('foo')).to be true
100
+ expect(@store.root).to eq @foo
101
101
  end
102
102
  end
103
103
 
104
- describe '#save' do
104
+ describe "#save" do
105
105
  before do
106
- @store.stub!(:write_proxy_types)
107
- @store.stub!(:write_checksums)
108
- @store.stub!(:destroy)
106
+ allow(@store).to receive(:write_proxy_types)
107
+ allow(@store).to receive(:write_checksums)
108
+ allow(@store).to receive(:destroy)
109
109
  end
110
110
 
111
111
  after do
@@ -113,7 +113,7 @@ describe YARD::RegistryStore do
113
113
  end
114
114
 
115
115
  def saves_to_singledb
116
- @serializer.should_receive(:serialize).once.with(instance_of(Hash))
116
+ expect(@serializer).to receive(:serialize).once.with(instance_of(Hash))
117
117
  @store.save(true, 'foo')
118
118
  end
119
119
 
@@ -123,24 +123,24 @@ describe YARD::RegistryStore do
123
123
 
124
124
  def saves_to_multidb
125
125
  times = @store.keys.size
126
- @serializer.should_receive(:serialize).exactly(times).times
126
+ expect(@serializer).to receive(:serialize).exactly(times).times
127
127
  @store.save(true, 'foo')
128
128
  @last = times
129
129
  end
130
130
 
131
- it "should save as single object db if single_object_db is nil and there are less than 3000 objects" do
131
+ it "saves as single object db if single_object_db is nil and there are less than 3000 objects" do
132
132
  Registry.single_object_db = nil
133
133
  add_items(100)
134
134
  saves_to_singledb
135
135
  end
136
136
 
137
- it "should save as single object db if single_object_db is nil and there are more than 3000 objects" do
137
+ it "saves as single object db if single_object_db is nil and there are more than 3000 objects" do
138
138
  Registry.single_object_db = nil
139
139
  add_items(5000)
140
140
  saves_to_singledb
141
141
  end
142
142
 
143
- it "should save as single object db if single_object_db is true (and any amount of objects)" do
143
+ it "saves as single object db if single_object_db is true (and any amount of objects)" do
144
144
  Registry.single_object_db = true
145
145
  add_items(100)
146
146
  saves_to_singledb
@@ -148,7 +148,7 @@ describe YARD::RegistryStore do
148
148
  saves_to_singledb
149
149
  end
150
150
 
151
- it "should never save as single object db if single_object_db is false" do
151
+ it "never saves as single object db if single_object_db is false" do
152
152
  Registry.single_object_db = false
153
153
  add_items(100)
154
154
  saves_to_multidb
@@ -157,159 +157,159 @@ describe YARD::RegistryStore do
157
157
  end
158
158
  end
159
159
 
160
- describe '#put' do
161
- it "should assign values" do
160
+ describe "#put" do
161
+ it "assigns values" do
162
162
  @store.put(:YARD, @foo)
163
- @store.get(:YARD).should == @foo
163
+ expect(@store.get(:YARD)).to eq @foo
164
164
  end
165
165
 
166
- it "should treat '' as root" do
166
+ it "treats '' as root" do
167
167
  @store.put('', @foo)
168
- @store.get(:root).should == @foo
168
+ expect(@store.get(:root)).to eq @foo
169
169
  end
170
170
  end
171
171
 
172
- describe '#get' do
173
- it "should hit cache if object exists" do
172
+ describe "#get" do
173
+ it "hits cache if object exists" do
174
174
  @store.put(:YARD, @foo)
175
- @store.get(:YARD).should == @foo
175
+ expect(@store.get(:YARD)).to eq @foo
176
176
  end
177
177
 
178
- it "should hit backstore on cache miss and cache is not fully loaded" do
179
- serializer = mock(:serializer)
180
- serializer.should_receive(:deserialize).once.with(:YARD).and_return(@foo)
178
+ it "hits backstore on cache miss and cache is not fully loaded" do
179
+ serializer = double(:serializer)
180
+ expect(serializer).to receive(:deserialize).once.with(:YARD).and_return(@foo)
181
181
  @store.load('foo')
182
182
  @store.instance_variable_set("@loaded_objects", 0)
183
183
  @store.instance_variable_set("@available_objects", 100)
184
184
  @store.instance_variable_set("@serializer", serializer)
185
- @store.get(:YARD).should == @foo
186
- @store.get(:YARD).should == @foo
187
- @store.instance_variable_get("@loaded_objects").should == 1
185
+ expect(@store.get(:YARD)).to eq @foo
186
+ expect(@store.get(:YARD)).to eq @foo
187
+ expect(@store.instance_variable_get("@loaded_objects")).to eq 1
188
188
  end
189
189
  end
190
190
 
191
191
  [:keys, :values].each do |item|
192
192
  describe "##{item}" do
193
- it "should load entire database if reload=true" do
194
- File.should_receive(:directory?).with('foo').and_return(true)
193
+ it "loads entire database if reload=true" do
194
+ expect(File).to receive(:directory?).with('foo').and_return(true)
195
195
  @store.load('foo')
196
- @store.should_receive(:load_all)
196
+ expect(@store).to receive(:load_all)
197
197
  @store.send(item, true)
198
198
  end
199
199
 
200
- it "should not load entire database if reload=false" do
201
- File.should_receive(:directory?).with('foo').and_return(true)
200
+ it "does not load entire database if reload=false" do
201
+ expect(File).to receive(:directory?).with('foo').and_return(true)
202
202
  @store.load('foo')
203
- @store.should_not_receive(:load_all)
203
+ expect(@store).not_to receive(:load_all)
204
204
  @store.send(item, false)
205
205
  end
206
206
  end
207
207
  end
208
208
 
209
- describe '#paths_for_type' do
209
+ describe "#paths_for_type" do
210
210
  after { Registry.clear }
211
211
 
212
- it "should set all object types if not set by object_types" do
213
- File.should_receive(:directory?).with('foo').and_return(true)
214
- File.should_receive(:file?).with('foo/checksums').and_return(false)
215
- File.should_receive(:file?).with('foo/proxy_types').and_return(false)
216
- File.should_receive(:file?).with('foo/object_types').and_return(false)
217
- @serializer.should_receive(:deserialize).with('root').and_return({:'A#foo' => @foo, :A => @bar})
212
+ it "sets all object types if not set by object_types" do
213
+ expect(File).to receive(:directory?).with('foo').and_return(true)
214
+ expect(File).to receive(:file?).with('foo/checksums').and_return(false)
215
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
216
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
217
+ expect(@serializer).to receive(:deserialize).with('root').and_return({:'A#foo' => @foo, :A => @bar})
218
218
  @store.load('foo')
219
- @store.paths_for_type(:method).should == ['#foo']
220
- @store.paths_for_type(:class).should == ['Bar']
219
+ expect(@store.paths_for_type(:method)).to eq ['#foo']
220
+ expect(@store.paths_for_type(:class)).to eq ['Bar']
221
221
  end
222
222
 
223
- it "should keep track of types when assigning values" do
223
+ it "keeps track of types when assigning values" do
224
224
  @store.put(:abc, @foo)
225
- @store.paths_for_type(@foo.type).should == ['abc']
225
+ expect(@store.paths_for_type(@foo.type)).to eq ['abc']
226
226
  end
227
227
 
228
- it "should reassign path if type changes" do
228
+ it "reassigns path if type changes" do
229
229
  foo = CodeObjects::ClassObject.new(:root, :Foo)
230
230
  @store.put('Foo', foo)
231
- @store.get('Foo').type.should == :class
232
- @store.paths_for_type(:class).should == ["Foo"]
231
+ expect(@store.get('Foo').type).to eq :class
232
+ expect(@store.paths_for_type(:class)).to eq ["Foo"]
233
233
  foo = CodeObjects::ModuleObject.new(:root, :Foo)
234
234
  @store.put('Foo', foo)
235
- @store.get('Foo').type.should == :module
236
- @store.paths_for_type(:class).should == []
237
- @store.paths_for_type(:module).should == ["Foo"]
235
+ expect(@store.get('Foo').type).to eq :module
236
+ expect(@store.paths_for_type(:class)).to eq []
237
+ expect(@store.paths_for_type(:module)).to eq ["Foo"]
238
238
  end
239
239
  end
240
240
 
241
- describe '#values_for_type' do
242
- it "should return all objects with type" do
241
+ describe "#values_for_type" do
242
+ it "returns all objects with type" do
243
243
  @store.put(:abc, @foo)
244
- @store.values_for_type(@foo.type).should == [@foo]
244
+ expect(@store.values_for_type(@foo.type)).to eq [@foo]
245
245
  end
246
246
  end
247
247
 
248
- describe '#load_all' do
249
- it "should load the entire database" do
250
- foomock = mock(:Foo)
251
- barmock = mock(:Bar)
252
- foomock.stub!(:type).and_return(:class)
253
- barmock.stub!(:type).and_return(:class)
254
- foomock.should_receive(:path).and_return('Foo')
255
- barmock.should_receive(:path).and_return('Bar')
256
- File.should_receive(:directory?).with('foo').and_return(true)
257
- File.should_receive(:file?).with('foo/proxy_types').and_return(false)
258
- File.should_receive(:file?).with('foo/object_types').and_return(false)
259
- File.should_receive(:file?).with('foo/checksums').and_return(false)
260
- File.should_receive(:file?).with('foo/objects/root.dat').and_return(false)
261
- @store.should_receive(:all_disk_objects).at_least(1).times.and_return(['foo/objects/foo', 'foo/objects/bar'])
248
+ describe "#load_all" do
249
+ it "loads the entire database" do
250
+ foomock = double(:Foo)
251
+ barmock = double(:Bar)
252
+ allow(foomock).to receive(:type).and_return(:class)
253
+ allow(barmock).to receive(:type).and_return(:class)
254
+ expect(foomock).to receive(:path).and_return('Foo')
255
+ expect(barmock).to receive(:path).and_return('Bar')
256
+ expect(File).to receive(:directory?).with('foo').and_return(true)
257
+ expect(File).to receive(:file?).with('foo/proxy_types').and_return(false)
258
+ expect(File).to receive(:file?).with('foo/object_types').and_return(false)
259
+ expect(File).to receive(:file?).with('foo/checksums').and_return(false)
260
+ expect(File).to receive(:file?).with('foo/objects/root.dat').and_return(false)
261
+ expect(@store).to receive(:all_disk_objects).at_least(1).times.and_return(['foo/objects/foo', 'foo/objects/bar'])
262
262
  @store.load('foo')
263
263
  serializer = @store.instance_variable_get("@serializer")
264
- serializer.should_receive(:deserialize).with('foo/objects/foo', true).and_return(foomock)
265
- serializer.should_receive(:deserialize).with('foo/objects/bar', true).and_return(barmock)
264
+ expect(serializer).to receive(:deserialize).with('foo/objects/foo', true).and_return(foomock)
265
+ expect(serializer).to receive(:deserialize).with('foo/objects/bar', true).and_return(barmock)
266
266
  @store.send(:load_all)
267
- @store.instance_variable_get("@available_objects").should == 2
268
- @store.instance_variable_get("@loaded_objects").should == 2
269
- @store[:Foo].should == foomock
270
- @store[:Bar].should == barmock
267
+ expect(@store.instance_variable_get("@available_objects")).to eq 2
268
+ expect(@store.instance_variable_get("@loaded_objects")).to eq 2
269
+ expect(@store[:Foo]).to eq foomock
270
+ expect(@store[:Bar]).to eq barmock
271
271
  end
272
272
  end
273
273
 
274
- describe '#destroy' do
275
- it "should destroy file ending in .yardoc when force=false" do
276
- File.should_receive(:file?).with('foo.yardoc').and_return(true)
277
- File.should_receive(:unlink).with('foo.yardoc')
274
+ describe "#destroy" do
275
+ it "destroys file ending in .yardoc when force=false" do
276
+ expect(File).to receive(:file?).with('foo.yardoc').and_return(true)
277
+ expect(File).to receive(:unlink).with('foo.yardoc')
278
278
  @store.instance_variable_set("@file", 'foo.yardoc')
279
- @store.destroy.should == true
279
+ expect(@store.destroy).to be true
280
280
  end
281
281
 
282
- it "should destroy dir ending in .yardoc when force=false" do
283
- File.should_receive(:directory?).with('foo.yardoc').and_return(true)
284
- FileUtils.should_receive(:rm_rf).with('foo.yardoc')
282
+ it "destroys dir ending in .yardoc when force=false" do
283
+ expect(File).to receive(:directory?).with('foo.yardoc').and_return(true)
284
+ expect(FileUtils).to receive(:rm_rf).with('foo.yardoc')
285
285
  @store.instance_variable_set("@file", 'foo.yardoc')
286
- @store.destroy.should == true
286
+ expect(@store.destroy).to be true
287
287
  end
288
288
 
289
- it "should not destroy file/dir not ending in .yardoc when force=false" do
290
- File.should_not_receive(:file?).with('foo')
291
- File.should_not_receive(:directory?).with('foo')
292
- File.should_not_receive(:unlink).with('foo')
293
- FileUtils.should_not_receive(:rm_rf).with('foo')
289
+ it "does not destroy file/dir not ending in .yardoc when force=false" do
290
+ expect(File).not_to receive(:file?).with('foo')
291
+ expect(File).not_to receive(:directory?).with('foo')
292
+ expect(File).not_to receive(:unlink).with('foo')
293
+ expect(FileUtils).not_to receive(:rm_rf).with('foo')
294
294
  @store.instance_variable_set("@file", 'foo')
295
- @store.destroy.should == false
295
+ expect(@store.destroy).to be false
296
296
  end
297
297
 
298
- it "should destroy any file/dir when force=true" do
299
- File.should_receive(:file?).with('foo').and_return(true)
300
- File.should_receive(:unlink).with('foo')
298
+ it "destroys any file/dir when force=true" do
299
+ expect(File).to receive(:file?).with('foo').and_return(true)
300
+ expect(File).to receive(:unlink).with('foo')
301
301
  @store.instance_variable_set("@file", 'foo')
302
- @store.destroy(true).should == true
302
+ expect(@store.destroy(true)).to be true
303
303
  end
304
304
  end
305
305
 
306
- describe '#locale' do
307
- it "should load ./po/LOCALE_NAME.po" do
306
+ describe "#locale" do
307
+ it "loads ./po/LOCALE_NAME.po" do
308
308
  fr_locale = I18n::Locale.new("fr")
309
- I18n::Locale.should_receive(:new).with("fr").and_return(fr_locale)
310
- Registry.should_receive(:po_dir).and_return("po")
311
- fr_locale.should_receive(:load).with("po")
312
- @store.locale("fr").should == fr_locale
309
+ expect(I18n::Locale).to receive(:new).with("fr").and_return(fr_locale)
310
+ expect(Registry).to receive(:po_dir).and_return("po")
311
+ expect(fr_locale).to receive(:load).with("po")
312
+ expect(@store.locale("fr")).to eq fr_locale
313
313
  end
314
314
  end
315
315
  end