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
@@ -9,89 +9,89 @@ end
9
9
  describe YARD::CLI::YRI do
10
10
  before do
11
11
  @yri = TestYRI.new
12
- Registry.stub!(:load)
12
+ allow(Registry).to receive(:load)
13
13
  end
14
14
 
15
- describe '#find_object' do
16
- it "should use cache if available" do
17
- @yri.stub!(:cache_object)
18
- File.should_receive(:exist?).with('.yardoc').and_return(false)
19
- File.should_receive(:exist?).with('bar.yardoc').and_return(true)
20
- Registry.should_receive(:load).with('bar.yardoc')
21
- Registry.should_receive(:at).ordered.with('Foo').and_return(nil)
22
- Registry.should_receive(:at).ordered.with('Foo').and_return('OBJ')
15
+ describe "#find_object" do
16
+ it "uses cache if available" do
17
+ allow(@yri).to receive(:cache_object)
18
+ expect(File).to receive(:exist?).with('.yardoc').and_return(false)
19
+ expect(File).to receive(:exist?).with('bar.yardoc').and_return(true)
20
+ expect(Registry).to receive(:load).with('bar.yardoc')
21
+ expect(Registry).to receive(:at).ordered.with('Foo').and_return(nil)
22
+ expect(Registry).to receive(:at).ordered.with('Foo').and_return('OBJ')
23
23
  @yri.instance_variable_set("@cache", {'Foo' => 'bar.yardoc'})
24
- @yri.find_object('Foo').should == 'OBJ'
24
+ expect(@yri.find_object('Foo')).to eq 'OBJ'
25
25
  end
26
26
 
27
- it "should never use cache ahead of current directory's .yardoc" do
28
- @yri.stub!(:cache_object)
29
- File.should_receive(:exist?).with('.yardoc').and_return(true)
30
- Registry.should_receive(:load).with('.yardoc')
31
- Registry.should_receive(:at).ordered.with('Foo').and_return(nil)
32
- Registry.should_receive(:at).ordered.with('Foo').and_return('OBJ')
27
+ it "never uses cache ahead of current directory's .yardoc" do
28
+ allow(@yri).to receive(:cache_object)
29
+ expect(File).to receive(:exist?).with('.yardoc').and_return(true)
30
+ expect(Registry).to receive(:load).with('.yardoc')
31
+ expect(Registry).to receive(:at).ordered.with('Foo').and_return(nil)
32
+ expect(Registry).to receive(:at).ordered.with('Foo').and_return('OBJ')
33
33
  @yri.instance_variable_set("@cache", {'Foo' => 'bar.yardoc'})
34
- @yri.find_object('Foo').should == 'OBJ'
35
- @yri.instance_variable_get("@search_paths")[0].should == '.yardoc'
34
+ expect(@yri.find_object('Foo')).to eq 'OBJ'
35
+ expect(@yri.instance_variable_get("@search_paths")[0]).to eq '.yardoc'
36
36
  end
37
37
  end
38
38
 
39
- describe '#cache_object' do
40
- it "should skip caching for Registry.yardoc_file" do
41
- File.should_not_receive(:open).with(CLI::YRI::CACHE_FILE, 'w')
39
+ describe "#cache_object" do
40
+ it "skips caching for Registry.yardoc_file" do
41
+ expect(File).not_to receive(:open).with(CLI::YRI::CACHE_FILE, 'w')
42
42
  @yri.cache_object('Foo', Registry.yardoc_file)
43
43
  end
44
44
  end
45
45
 
46
- describe '#initialize' do
47
- it "should load search paths" do
46
+ describe "#initialize" do
47
+ it "loads search paths" do
48
48
  path = %r{/\.yard/yri_search_paths$}
49
- File.should_receive(:file?).with(%r{/\.yard/yri_cache$}).and_return(false)
50
- File.should_receive(:file?).with(path).and_return(true)
51
- File.should_receive(:readlines).with(path).and_return(%w(line1 line2))
49
+ expect(File).to receive(:file?).with(%r{/\.yard/yri_cache$}).and_return(false)
50
+ expect(File).to receive(:file?).with(path).and_return(true)
51
+ expect(File).to receive(:readlines).with(path).and_return(%w(line1 line2))
52
52
  @yri = YARD::CLI::YRI.new
53
53
  spaths = @yri.instance_variable_get("@search_paths")
54
- spaths.should include('line1')
55
- spaths.should include('line2')
54
+ expect(spaths).to include('line1')
55
+ expect(spaths).to include('line2')
56
56
  end
57
57
 
58
- it "should use DEFAULT_SEARCH_PATHS prior to other paths" do
58
+ it "uses DEFAULT_SEARCH_PATHS prior to other paths" do
59
59
  YARD::CLI::YRI::DEFAULT_SEARCH_PATHS.push('foo', 'bar')
60
60
  path = %r{/\.yard/yri_search_paths$}
61
- File.should_receive(:file?).with(%r{/\.yard/yri_cache$}).and_return(false)
62
- File.should_receive(:file?).with(path).and_return(true)
63
- File.should_receive(:readlines).with(path).and_return(%w(line1 line2))
61
+ expect(File).to receive(:file?).with(%r{/\.yard/yri_cache$}).and_return(false)
62
+ expect(File).to receive(:file?).with(path).and_return(true)
63
+ expect(File).to receive(:readlines).with(path).and_return(%w(line1 line2))
64
64
  @yri = YARD::CLI::YRI.new
65
65
  spaths = @yri.instance_variable_get("@search_paths")
66
- spaths[0,4].should == %w(foo bar line1 line2)
66
+ expect(spaths[0,4]).to eq %w(foo bar line1 line2)
67
67
  YARD::CLI::YRI::DEFAULT_SEARCH_PATHS.replace([])
68
68
  end
69
69
  end
70
70
 
71
- describe '#run' do
72
- it "should search for objects and print their documentation" do
71
+ describe "#run" do
72
+ it "searches for objects and print their documentation" do
73
73
  obj = YARD::CodeObjects::ClassObject.new(:root, 'Foo')
74
- @yri.should_receive(:print_object).with(obj)
74
+ expect(@yri).to receive(:print_object).with(obj)
75
75
  @yri.run('Foo')
76
76
  Registry.clear
77
77
  end
78
78
 
79
- it "should print usage if no object is provided" do
80
- @yri.should_receive(:print_usage)
81
- @yri.should_receive(:exit).with(1)
79
+ it "prints usage if no object is provided" do
80
+ expect(@yri).to receive(:print_usage)
81
+ expect(@yri).to receive(:exit).with(1)
82
82
  @yri.run('')
83
83
  end
84
84
 
85
- it "should print no documentation exists for object if object is not found" do
86
- STDERR.should_receive(:puts).with("No documentation for `Foo'")
87
- @yri.should_receive(:exit).with(1)
85
+ it "prints 'no documentation exists for object' if object is not found" do
86
+ expect(STDERR).to receive(:puts).with("No documentation for `Foo'")
87
+ expect(@yri).to receive(:exit).with(1)
88
88
  @yri.run('Foo')
89
89
  end
90
90
 
91
- it "should ensure output is serialized" do
91
+ it "ensures output is serialized" do
92
92
  obj = YARD::CodeObjects::ClassObject.new(:root, 'Foo')
93
- class << @yri
94
- def test_stub; @serializer.should_receive(:serialize).once end
93
+ allow(@yri).to receive(:test_stub) do
94
+ expect(@yri.instance_variable_get(:@serializer)).to receive(:serialize).once
95
95
  end
96
96
  @yri.run('Foo')
97
97
  end
@@ -3,47 +3,46 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe YARD::CodeObjects::Base do
4
4
  before { Registry.clear }
5
5
 
6
- # Fix this
7
- # it "should not allow empty object name" do
8
- # lambda { Base.new(:root, '') }.should raise_error(ArgumentError)
9
- # end
6
+ it "does not allow empty object name" do
7
+ expect { Base.new(:root, '') }.to raise_error(ArgumentError)
8
+ end
10
9
 
11
- it "should return a unique instance of any registered object" do
10
+ it "returns a unique instance of any registered object" do
12
11
  obj = ClassObject.new(:root, :Me)
13
12
  obj2 = ClassObject.new(:root, :Me)
14
- obj.object_id.should == obj2.object_id
13
+ expect(obj.object_id).to eq obj2.object_id
15
14
 
16
15
  obj3 = ModuleObject.new(obj, :Too)
17
16
  obj4 = CodeObjects::Base.new(obj3, :Hello)
18
17
  obj4.parent = obj
19
18
 
20
19
  obj5 = CodeObjects::Base.new(obj3, :hello)
21
- obj4.object_id.should_not == obj5.object_id
20
+ expect(obj4.object_id).not_to eq obj5.object_id
22
21
  end
23
22
 
24
- it "should create a new object if cached object is not of the same class" do
25
- ConstantObject.new(:root, "MYMODULE").should be_instance_of(ConstantObject)
26
- ModuleObject.new(:root, "MYMODULE").should be_instance_of(ModuleObject)
27
- ClassObject.new(:root, "MYMODULE").should be_instance_of(ClassObject)
28
- YARD::Registry.at("MYMODULE").should be_instance_of(ClassObject)
23
+ it "creates a new object if cached object is not of the same class" do
24
+ expect(ConstantObject.new(:root, "MYMODULE")).to be_instance_of(ConstantObject)
25
+ expect(ModuleObject.new(:root, "MYMODULE")).to be_instance_of(ModuleObject)
26
+ expect(ClassObject.new(:root, "MYMODULE")).to be_instance_of(ClassObject)
27
+ expect(YARD::Registry.at("MYMODULE")).to be_instance_of(ClassObject)
29
28
  end
30
29
 
31
- it "should simplify complex namespace paths" do
30
+ it "simplifies complex namespace paths" do
32
31
  obj = ClassObject.new(:root, "A::B::C::D")
33
- obj.name.should == :D
34
- obj.path.should == "A::B::C::D"
35
- obj.namespace.should == P("A::B::C")
32
+ expect(obj.name).to eq :D
33
+ expect(obj.path).to eq "A::B::C::D"
34
+ expect(obj.namespace).to eq P("A::B::C")
36
35
  end
37
36
 
38
37
  # @bug gh-552
39
- it "should simplify complex namespace paths when path starts with ::" do
38
+ it "simplifies complex namespace paths when path starts with ::" do
40
39
  obj = ClassObject.new(:root, "::A::B::C::D")
41
- obj.name.should == :D
42
- obj.path.should == "A::B::C::D"
43
- obj.namespace.should == P("A::B::C")
40
+ expect(obj.name).to eq :D
41
+ expect(obj.path).to eq "A::B::C::D"
42
+ expect(obj.namespace).to eq P("A::B::C")
44
43
  end
45
44
 
46
- it "should recall the block if #new is called on an existing object" do
45
+ it "calls the block again if #new is called on an existing object" do
47
46
  o1 = ClassObject.new(:root, :Me) do |o|
48
47
  o.docstring = "DOCSTRING"
49
48
  end
@@ -52,74 +51,76 @@ describe YARD::CodeObjects::Base do
52
51
  o.docstring = "NOT_DOCSTRING"
53
52
  end
54
53
 
55
- o1.object_id.should == o2.object_id
56
- o1.docstring.should == "NOT_DOCSTRING"
57
- o2.docstring.should == "NOT_DOCSTRING"
54
+ expect(o1.object_id).to eq o2.object_id
55
+ expect(o1.docstring).to eq "NOT_DOCSTRING"
56
+ expect(o2.docstring).to eq "NOT_DOCSTRING"
58
57
  end
59
58
 
60
- it "should allow complex name and convert that to namespace" do
59
+ it "allows complex name and converts it to namespace" do
61
60
  obj = CodeObjects::Base.new(nil, "A::B")
62
- obj.namespace.path.should == "A"
63
- obj.name.should == :B
61
+ expect(obj.namespace.path).to eq "A"
62
+ expect(obj.name).to eq :B
64
63
  end
65
64
 
66
- it "should allow namespace to be nil and not register in the Registry" do
65
+ it "allows namespace to be nil and not register in the Registry" do
67
66
  obj = CodeObjects::Base.new(nil, :Me)
68
- obj.namespace.should == nil
69
- Registry.at(:Me).should == nil
67
+ expect(obj.namespace).to eq nil
68
+ expect(Registry.at(:Me)).to eq nil
70
69
  end
71
70
 
72
- it "should allow namespace to be a NamespaceObject" do
71
+ it "allows namespace to be a NamespaceObject" do
73
72
  ns = ModuleObject.new(:root, :Name)
74
73
  obj = CodeObjects::Base.new(ns, :Me)
75
- obj.namespace.should == ns
74
+ expect(obj.namespace).to eq ns
76
75
  end
77
76
 
78
- it "should allow :root to be the shorthand namespace of `Registry.root`" do
77
+ it "allows :root to be the shorthand namespace of `Registry.root`" do
79
78
  obj = CodeObjects::Base.new(:root, :Me)
80
- obj.namespace.should == Registry.root
79
+ expect(obj.namespace).to eq Registry.root
81
80
  end
82
81
 
83
- it "should not allow any other types as namespace" do
84
- lambda { CodeObjects::Base.new("ROOT!", :Me) }.should raise_error(ArgumentError)
82
+ it "does not allow any other types as namespace" do
83
+ expect { CodeObjects::Base.new("ROOT!", :Me) }.to raise_error(ArgumentError)
85
84
  end
86
85
 
87
- it "should register itself in the registry if namespace is supplied" do
86
+ it "registers itself in the registry if namespace is supplied" do
88
87
  obj = ModuleObject.new(:root, :Me)
89
- Registry.at(:Me).should == obj
88
+ expect(Registry.at(:Me)).to eq obj
90
89
 
91
90
  obj2 = ModuleObject.new(obj, :Too)
92
- Registry.at(:"Me::Too").should == obj2
91
+ expect(Registry.at(:"Me::Too")).to eq obj2
93
92
  end
94
93
 
95
- it "should set any attribute using #[]=" do
96
- obj = ModuleObject.new(:root, :YARD)
97
- obj[:some_attr] = "hello"
98
- obj[:some_attr].should == "hello"
99
- end
94
+ describe "#[]=" do
95
+ it "sets any attribute" do
96
+ obj = ModuleObject.new(:root, :YARD)
97
+ obj[:some_attr] = "hello"
98
+ expect(obj[:some_attr]).to eq "hello"
99
+ end
100
100
 
101
- it "#[]= should use the accessor method if available" do
102
- obj = CodeObjects::Base.new(:root, :YARD)
103
- obj[:source] = "hello"
104
- obj.source.should == "hello"
105
- obj.source = "unhello"
106
- obj[:source].should == "unhello"
101
+ it "uses the accessor method if available" do
102
+ obj = CodeObjects::Base.new(:root, :YARD)
103
+ obj[:source] = "hello"
104
+ expect(obj.source).to eq "hello"
105
+ obj.source = "unhello"
106
+ expect(obj[:source]).to eq "unhello"
107
+ end
107
108
  end
108
109
 
109
- it "should set attributes via attr= through method_missing" do
110
+ it "sets attributes via attr= through method_missing" do
110
111
  obj = CodeObjects::Base.new(:root, :YARD)
111
112
  obj.something = 2
112
- obj.something.should == 2
113
- obj[:something].should == 2
113
+ expect(obj.something).to eq 2
114
+ expect(obj[:something]).to eq 2
114
115
  end
115
116
 
116
- it "should exist in the parent's #children after creation" do
117
+ it "exists in the parent's #children after creation" do
117
118
  obj = ModuleObject.new(:root, :YARD)
118
119
  obj2 = MethodObject.new(obj, :testing)
119
- obj.children.should include(obj2)
120
+ expect(obj.children).to include(obj2)
120
121
  end
121
122
 
122
- it "should properly re-indent source starting from 0 indentation" do
123
+ it "properly re-indents source starting from 0 indentation" do
123
124
  obj = CodeObjects::Base.new(nil, :test)
124
125
  obj.source = <<-eof
125
126
  def mymethod
@@ -131,7 +132,7 @@ describe YARD::CodeObjects::Base do
131
132
  end
132
133
  end
133
134
  eof
134
- obj.source.should == "def mymethod\n if x == 2 &&\n 5 == 5\n 3\n else\n 1\n end\nend"
135
+ expect(obj.source).to eq "def mymethod\n if x == 2 &&\n 5 == 5\n 3\n else\n 1\n end\nend"
135
136
 
136
137
  Registry.clear
137
138
  Parser::SourceParser.parse_string <<-eof
@@ -139,7 +140,7 @@ describe YARD::CodeObjects::Base do
139
140
  super(key)
140
141
  end
141
142
  eof
142
- Registry.at('#key?').source.should == "def key?(key)\n super(key)\nend"
143
+ expect(Registry.at('#key?').source).to eq "def key?(key)\n super(key)\nend"
143
144
 
144
145
  Registry.clear
145
146
  Parser::SourceParser.parse_string <<-eof
@@ -151,10 +152,10 @@ describe YARD::CodeObjects::Base do
151
152
  end
152
153
  end
153
154
  eof
154
- Registry.at('#key?').source.should == "def key?(key)\n if x == 2\n puts key\n else\n exit\n end\nend"
155
+ expect(Registry.at('#key?').source).to eq "def key?(key)\n if x == 2\n puts key\n else\n exit\n end\nend"
155
156
  end
156
157
 
157
- it "should not add newlines to source when parsing sub blocks" do
158
+ it "does not add newlines to source when parsing sub blocks" do
158
159
  Parser::SourceParser.parse_string <<-eof
159
160
  module XYZ
160
161
  module ZYX
@@ -166,47 +167,47 @@ describe YARD::CodeObjects::Base do
166
167
  end
167
168
  end
168
169
  eof
169
- Registry.at('XYZ::ZYX::ABC#msg').source.should == "def msg\n hello_world\nend"
170
+ expect(Registry.at('XYZ::ZYX::ABC#msg').source).to eq "def msg\n hello_world\nend"
170
171
  end
171
172
 
172
- it "should handle source for 'def x; end'" do
173
+ it "handles source for 'def x; end'" do
173
174
  Registry.clear
174
175
  Parser::SourceParser.parse_string "def x; 2 end"
175
- Registry.at('#x').source.should == "def x; 2 end"
176
+ expect(Registry.at('#x').source).to eq "def x; 2 end"
176
177
  end
177
178
 
178
- it "should set file and line information" do
179
+ it "sets file and line information" do
179
180
  Parser::SourceParser.parse_string <<-eof
180
181
  class X; end
181
182
  eof
182
- Registry.at(:X).file.should == '(stdin)'
183
- Registry.at(:X).line.should == 1
183
+ expect(Registry.at(:X).file).to eq '(stdin)'
184
+ expect(Registry.at(:X).line).to eq 1
184
185
  end
185
186
 
186
- it "should maintain all file associations when objects are defined multiple times in one file" do
187
+ it "maintains all file associations when objects are defined multiple times in one file" do
187
188
  Parser::SourceParser.parse_string <<-eof
188
189
  class X; end
189
190
  class X; end
190
191
  class X; end
191
192
  eof
192
193
 
193
- Registry.at(:X).file.should == '(stdin)'
194
- Registry.at(:X).line.should == 1
195
- Registry.at(:X).files.should == [['(stdin)', 1], ['(stdin)', 2], ['(stdin)', 3]]
194
+ expect(Registry.at(:X).file).to eq '(stdin)'
195
+ expect(Registry.at(:X).line).to eq 1
196
+ expect(Registry.at(:X).files).to eq [['(stdin)', 1], ['(stdin)', 2], ['(stdin)', 3]]
196
197
  end
197
198
 
198
- it "should maintain all file associations when objects are defined multiple times in multiple files" do
199
+ it "maintains all file associations when objects are defined multiple times in multiple files" do
199
200
  3.times do |i|
200
- File.stub!(:read_binary).and_return("class X; end")
201
+ allow(File).to receive(:read_binary).and_return("class X; end")
201
202
  Parser::SourceParser.new.parse("file#{i+1}.rb")
202
203
  end
203
204
 
204
- Registry.at(:X).file.should == 'file1.rb'
205
- Registry.at(:X).line.should == 1
206
- Registry.at(:X).files.should == [['file1.rb', 1], ['file2.rb', 1], ['file3.rb', 1]]
205
+ expect(Registry.at(:X).file).to eq 'file1.rb'
206
+ expect(Registry.at(:X).line).to eq 1
207
+ expect(Registry.at(:X).files).to eq [['file1.rb', 1], ['file2.rb', 1], ['file3.rb', 1]]
207
208
  end
208
209
 
209
- it "should prioritize the definition with a docstring when returning #file" do
210
+ it "prioritizes the definition with a docstring when returning #file" do
210
211
  Parser::SourceParser.parse_string <<-eof
211
212
  class X; end
212
213
  class X; end
@@ -214,172 +215,172 @@ describe YARD::CodeObjects::Base do
214
215
  class X; end
215
216
  eof
216
217
 
217
- Registry.at(:X).file.should == '(stdin)'
218
- Registry.at(:X).line.should == 4
219
- Registry.at(:X).files.should == [['(stdin)', 4], ['(stdin)', 1], ['(stdin)', 2]]
218
+ expect(Registry.at(:X).file).to eq '(stdin)'
219
+ expect(Registry.at(:X).line).to eq 4
220
+ expect(Registry.at(:X).files).to eq [['(stdin)', 4], ['(stdin)', 1], ['(stdin)', 2]]
220
221
  end
221
222
 
222
- describe '#format' do
223
- it "should send to Templates.render" do
223
+ describe "#format" do
224
+ it "sends object to Templates.render" do
224
225
  object = MethodObject.new(:root, :method)
225
- Templates::Engine.should_receive(:render).with(:x => 1, :object => object)
226
+ expect(Templates::Engine).to receive(:render).with(:x => 1, :object => object)
226
227
  object.format :x => 1
227
228
  end
228
229
  end
229
230
 
230
- describe '#source_type' do
231
- it "should default source_type to :ruby" do
231
+ describe "#source_type" do
232
+ it "defaults to :ruby" do
232
233
  object = MethodObject.new(:root, :method)
233
- object.source_type.should == :ruby
234
+ expect(object.source_type).to eq :ruby
234
235
  end
235
236
  end
236
237
 
237
- describe '#relative_path' do
238
- it "should accept a string" do
238
+ describe "#relative_path" do
239
+ it "accepts a string" do
239
240
  YARD.parse_string "module A; class B; end; class C; end; end"
240
- Registry.at('A::B').relative_path(Registry.at('A::C')).should ==
241
- Registry.at('A::B').relative_path('A::C')
241
+ expect(Registry.at('A::B').relative_path(Registry.at('A::C'))).to eq(
242
+ Registry.at('A::B').relative_path('A::C'))
242
243
  end
243
244
 
244
- it "should return full class name when objects share a common class prefix" do
245
+ it "returns full class name when objects share a common class prefix" do
245
246
  YARD.parse_string "module User; end; module UserManager; end"
246
- Registry.at('User').relative_path('UserManager').should == 'UserManager'
247
- Registry.at('User').relative_path(Registry.at('UserManager')).should == 'UserManager'
247
+ expect(Registry.at('User').relative_path('UserManager')).to eq 'UserManager'
248
+ expect(Registry.at('User').relative_path(Registry.at('UserManager'))).to eq 'UserManager'
248
249
  end
249
250
 
250
- it "should return the relative path when they share a common namespace" do
251
+ it "returns the relative path when they share a common namespace" do
251
252
  YARD.parse_string "module A; class B; end; class C; end; end"
252
- Registry.at('A::B').relative_path(Registry.at('A::C')).should == 'C'
253
+ expect(Registry.at('A::B').relative_path(Registry.at('A::C'))).to eq 'C'
253
254
  YARD.parse_string "module Foo; module A; end; module B; def foo; end end end"
254
- Registry.at('Foo::A').relative_path(Registry.at('Foo::B#foo')).should == 'B#foo'
255
+ expect(Registry.at('Foo::A').relative_path(Registry.at('Foo::B#foo'))).to eq 'B#foo'
255
256
  end
256
257
 
257
- it "should return the full path if they don't have a common namespace" do
258
+ it "returns the full path if they don't have a common namespace" do
258
259
  YARD.parse_string "module A; class B; end; end; module D; class C; end; end"
259
- Registry.at('A::B').relative_path('D::C').should == 'D::C'
260
+ expect(Registry.at('A::B').relative_path('D::C')).to eq 'D::C'
260
261
  YARD.parse_string 'module C::B::C; module Apple; end; module Ant; end end'
261
- Registry.at('C::B::C::Apple').relative_path('C::B::C::Ant').should == 'Ant'
262
+ expect(Registry.at('C::B::C::Apple').relative_path('C::B::C::Ant')).to eq 'Ant'
262
263
  YARD.parse_string 'module OMG::ABC; end; class Object; end'
263
- Registry.at('OMG::ABC').relative_path('Object').should == "Object"
264
+ expect(Registry.at('OMG::ABC').relative_path('Object')).to eq "Object"
264
265
  YARD.parse_string("class YARD::Config; MYCONST = 1; end")
265
- Registry.at('YARD::Config').relative_path('YARD::Config::MYCONST').should == "MYCONST"
266
+ expect(Registry.at('YARD::Config').relative_path('YARD::Config::MYCONST')).to eq "MYCONST"
266
267
  end
267
268
 
268
- it "should return a relative path for class methods" do
269
+ it "returns a relative path for class methods" do
269
270
  YARD.parse_string "module A; def self.b; end; def self.c; end; end"
270
- Registry.at('A.b').relative_path('A.c').should == 'c'
271
- Registry.at('A').relative_path('A.c').should == 'c'
271
+ expect(Registry.at('A.b').relative_path('A.c')).to eq 'c'
272
+ expect(Registry.at('A').relative_path('A.c')).to eq 'c'
272
273
  end
273
274
 
274
- it "should return a relative path for instance methods" do
275
+ it "returns a relative path for instance methods" do
275
276
  YARD.parse_string "module A; def b; end; def c; end; end"
276
- Registry.at('A#b').relative_path('A#c').should == '#c'
277
- Registry.at('A').relative_path('A#c').should == '#c'
277
+ expect(Registry.at('A#b').relative_path('A#c')).to eq '#c'
278
+ expect(Registry.at('A').relative_path('A#c')).to eq '#c'
278
279
  end
279
280
 
280
- it "should return full path if relative path is to parent namespace" do
281
+ it "returns full path if relative path is to parent namespace" do
281
282
  YARD.parse_string "module A; module B; end end"
282
- Registry.at('A::B').relative_path('A').should == 'A'
283
+ expect(Registry.at('A::B').relative_path('A')).to eq 'A'
283
284
  end
284
285
 
285
- it "should only return name for relative path to self" do
286
+ it "only returns name for relative path to self" do
286
287
  YARD.parse_string("class A::B::C; def foo; end end")
287
- Registry.at('A::B::C').relative_path('A::B::C').should == 'C'
288
- Registry.at('A::B::C#foo').relative_path('A::B::C#foo').should == '#foo'
288
+ expect(Registry.at('A::B::C').relative_path('A::B::C')).to eq 'C'
289
+ expect(Registry.at('A::B::C#foo').relative_path('A::B::C#foo')).to eq '#foo'
289
290
  end
290
291
  end
291
292
 
292
- describe '#docstring=' do
293
- it "should convert string into Docstring when #docstring= is set" do
293
+ describe "#docstring=" do
294
+ it "converts string into Docstring when #docstring= is set" do
294
295
  o = ClassObject.new(:root, :Me)
295
296
  o.docstring = "DOCSTRING"
296
- o.docstring.should be_instance_of(Docstring)
297
+ expect(o.docstring).to be_instance_of(Docstring)
297
298
  end
298
299
 
299
- it "should set docstring to docstring of other object if docstring is '(see Path)'" do
300
+ it "sets docstring to docstring of other object if docstring is '(see Path)'" do
300
301
  ClassObject.new(:root, :AnotherObject) {|x| x.docstring = "FOO" }
301
302
  o = ClassObject.new(:root, :Me)
302
303
  o.docstring = '(see AnotherObject)'
303
- o.docstring.should == "FOO"
304
+ expect(o.docstring).to eq "FOO"
304
305
  end
305
306
 
306
- it "should not copy docstring mid-docstring" do
307
+ it "does not copy docstring mid-docstring" do
307
308
  doc = "Hello.\n(see file.rb)\nmore documentation"
308
309
  o = ClassObject.new(:root, :Me)
309
310
  o.docstring = doc
310
- o.docstring.should == doc
311
+ expect(o.docstring).to eq doc
311
312
  end
312
313
 
313
- it "should allow extra docstring after (see Path)" do
314
+ it "allows extra docstring after (see Path)" do
314
315
  ClassObject.new(:root, :AnotherObject) {|x| x.docstring = "FOO" }
315
316
  o = ClassObject.new(:root, :Me)
316
317
  o.docstring = Docstring.new("(see AnotherObject)\n\nEXTRA\n@api private", o)
317
- o.docstring.should == "FOO\n\nEXTRA"
318
- o.docstring.should have_tag(:api)
318
+ expect(o.docstring).to eq "FOO\n\nEXTRA"
319
+ expect(o.docstring).to have_tag(:api)
319
320
  end
320
321
  end
321
322
 
322
- describe '#docstring' do
323
- it "should return empty string if docstring was '(see Path)' and Path is not resolved" do
323
+ describe "#docstring" do
324
+ it "returns an empty string if docstring was '(see Path)' and Path is not resolved" do
324
325
  o = ClassObject.new(:root, :Me)
325
326
  o.docstring = '(see AnotherObject)'
326
- o.docstring.should == ""
327
+ expect(o.docstring).to eq ""
327
328
  end
328
329
 
329
- it "should return docstring when object is resolved" do
330
+ it "returns docstring when object is resolved" do
330
331
  o = ClassObject.new(:root, :Me)
331
332
  o.docstring = '(see AnotherObject)'
332
- o.docstring.should == ""
333
+ expect(o.docstring).to eq ""
333
334
  ClassObject.new(:root, :AnotherObject) {|x| x.docstring = "FOO" }
334
- o.docstring.should == "FOO"
335
+ expect(o.docstring).to eq "FOO"
335
336
  end
336
337
 
337
- describe 'localization' do
338
- it "should return localized docstring" do
338
+ describe "localization" do
339
+ it "returns localized docstring" do
339
340
  fr_locale = YARD::I18n::Locale.new('fr')
340
- fr_locale.stub!(:translate).with('Hello').and_return('Bonjour')
341
+ allow(fr_locale).to receive(:translate).with('Hello').and_return('Bonjour')
341
342
 
342
343
  o = ClassObject.new(:root, :Me)
343
344
  o.docstring = 'Hello'
344
- o.docstring.should == 'Hello'
345
+ expect(o.docstring).to eq 'Hello'
345
346
 
346
- Registry.stub!(:locale).with('fr').and_return(fr_locale)
347
- o.docstring('fr').should == "Bonjour"
347
+ allow(Registry).to receive(:locale).with('fr').and_return(fr_locale)
348
+ expect(o.docstring('fr')).to eq "Bonjour"
348
349
  end
349
350
 
350
- it "should return updated localized docstring" do
351
+ it "returns updated localized docstring" do
351
352
  fr_locale = YARD::I18n::Locale.new('fr')
352
- Registry.stub!(:locale).with('fr').and_return(fr_locale)
353
+ allow(Registry).to receive(:locale).with('fr').and_return(fr_locale)
353
354
 
354
355
  o = ClassObject.new(:root, :Me)
355
356
  o.docstring = 'Hello'
356
- o.docstring.should == 'Hello'
357
+ expect(o.docstring).to eq 'Hello'
357
358
 
358
- fr_locale.stub!(:translate).with('Hello').and_return('Bonjour')
359
- o.docstring('fr').should == "Bonjour"
359
+ allow(fr_locale).to receive(:translate).with('Hello').and_return('Bonjour')
360
+ expect(o.docstring('fr')).to eq "Bonjour"
360
361
 
361
362
  o.docstring = 'World'
362
- fr_locale.stub!(:translate).with('World').and_return('Monde')
363
- o.docstring('fr').should == "Monde"
364
- o.docstring.should == 'World'
363
+ allow(fr_locale).to receive(:translate).with('World').and_return('Monde')
364
+ expect(o.docstring('fr')).to eq "Monde"
365
+ expect(o.docstring).to eq 'World'
365
366
  end
366
367
  end
367
368
  end
368
369
 
369
- describe '#add_file' do
370
- it "should only add a file/line combination once" do
370
+ describe "#add_file" do
371
+ it "only adds a file/line combination once" do
371
372
  o = ClassObject.new(:root, :Me)
372
373
  o.add_file('filename', 12)
373
- o.files.should == [['filename', 12]]
374
+ expect(o.files).to eq [['filename', 12]]
374
375
  o.add_file('filename', 12)
375
- o.files.should == [['filename', 12]]
376
+ expect(o.files).to eq [['filename', 12]]
376
377
  o.add_file('filename', 40) # different line
377
- o.files.should == [['filename', 12], ['filename', 40]]
378
+ expect(o.files).to eq [['filename', 12], ['filename', 40]]
378
379
  end
379
380
  end
380
381
 
381
- describe '#copy_to' do
382
- it "should copy all data to new object" do
382
+ describe "#copy_to" do
383
+ it "copies all data to new object" do
383
384
  YARD.parse_string <<-eof
384
385
  private
385
386
  # A docstring
@@ -390,27 +391,27 @@ describe YARD::CodeObjects::Base do
390
391
  eof
391
392
  foo_c = MethodObject.new(:root, :foo, :class)
392
393
  Registry.at('#foo').copy_to(foo_c)
393
- foo_c.scope.should == :class
394
- foo_c.visibility.should == :private
395
- foo_c.type.should == :method
396
- foo_c.class.should == MethodObject
397
- foo_c.path.should == '::foo'
398
- foo_c.docstring.should == "A docstring"
399
- foo_c.tag(:return).types.should == ['String']
400
- foo_c.file.should == '(stdin)'
401
- foo_c.line.should == 4
402
- foo_c.source.should =~ /source_code_here/
403
- foo_c.signature.should == 'def foo(a, b, c)'
404
- foo_c.parameters.should == [['a', nil], ['b', nil], ['c', nil]]
394
+ expect(foo_c.scope).to eq :class
395
+ expect(foo_c.visibility).to eq :private
396
+ expect(foo_c.type).to eq :method
397
+ expect(foo_c.class).to eq MethodObject
398
+ expect(foo_c.path).to eq '::foo'
399
+ expect(foo_c.docstring).to eq "A docstring"
400
+ expect(foo_c.tag(:return).types).to eq ['String']
401
+ expect(foo_c.file).to eq '(stdin)'
402
+ expect(foo_c.line).to eq 4
403
+ expect(foo_c.source).to match /source_code_here/
404
+ expect(foo_c.signature).to eq 'def foo(a, b, c)'
405
+ expect(foo_c.parameters).to eq [['a', nil], ['b', nil], ['c', nil]]
405
406
  end
406
407
 
407
- it "should return copied object" do
408
+ it "returns the copied object" do
408
409
  YARD.parse_string 'def foo; end'
409
410
  foo_c = MethodObject.new(:root, :foo, :class)
410
- Registry.at('#foo').copy_to(foo_c).should == foo_c
411
+ expect(Registry.at('#foo').copy_to(foo_c)).to eq foo_c
411
412
  end
412
413
 
413
- it "should copy docstring and rewrite tags for new object" do
414
+ it "copies docstring and rewrite tags to new object" do
414
415
  YARD.parse_string <<-eof
415
416
  # @return [String] a tag
416
417
  def foo; end
@@ -418,20 +419,20 @@ describe YARD::CodeObjects::Base do
418
419
  foo_c = MethodObject.new(:root, :foo, :class)
419
420
  foo_i = Registry.at('#foo')
420
421
  foo_i.copy_to(foo_c)
421
- foo_i.tags.should_not == foo_c.tags
422
- foo_c.tags.first.object.should == foo_c
422
+ expect(foo_i.tags).not_to eq foo_c.tags
423
+ expect(foo_c.tags.first.object).to eq foo_c
423
424
  end
424
425
 
425
- it "should only copy #copyable_attributes" do
426
+ it "only copies #copyable_attributes" do
426
427
  foo = MethodObject.new(:root, :foo)
427
- foo.should_receive(:copyable_attributes).and_return %w(a b c)
428
- foo.should_receive(:instance_variable_get).with('@a').and_return(1)
429
- foo.should_receive(:instance_variable_get).with('@b').and_return(2)
430
- foo.should_receive(:instance_variable_get).with('@c').and_return(3)
428
+ expect(foo).to receive(:copyable_attributes).and_return %w(a b c)
429
+ expect(foo).to receive(:instance_variable_get).with('@a').and_return(1)
430
+ expect(foo).to receive(:instance_variable_get).with('@b').and_return(2)
431
+ expect(foo).to receive(:instance_variable_get).with('@c').and_return(3)
431
432
  bar = MethodObject.new(:root, :bar)
432
- bar.should_receive(:instance_variable_set).with('@a', 1)
433
- bar.should_receive(:instance_variable_set).with('@b', 2)
434
- bar.should_receive(:instance_variable_set).with('@c', 3)
433
+ expect(bar).to receive(:instance_variable_set).with('@a', 1)
434
+ expect(bar).to receive(:instance_variable_set).with('@b', 2)
435
+ expect(bar).to receive(:instance_variable_set).with('@c', 3)
435
436
  foo.copy_to(bar)
436
437
  end
437
438
  end