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
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe YARD::CodeObjects::ClassObject do
4
- describe '#inheritance_tree' do
4
+ describe "#inheritance_tree" do
5
5
  before(:all) do
6
6
  Registry.clear
7
7
  @mixin = ModuleObject.new(:root, :SomeMixin)
@@ -19,28 +19,28 @@ describe YARD::CodeObjects::ClassObject do
19
19
  @yard.instance_mixins << @mixin
20
20
  end
21
21
 
22
- it "should show the proper inheritance tree" do
23
- @yard.inheritance_tree.should == [@yard, @superyard, P(:String)]
22
+ it "shows the proper inheritance tree" do
23
+ expect(@yard.inheritance_tree).to eq [@yard, @superyard, P(:String)]
24
24
  end
25
25
 
26
- it "should show proper inheritance tree when mixins are included" do
27
- @yard.inheritance_tree(true).should == [@yard, @mixin, @superyard, @mixin4, @mixin2, @mixin3, P(:String)]
26
+ it "shows proper inheritance tree when mixins are included" do
27
+ expect(@yard.inheritance_tree(true)).to eq [@yard, @mixin, @superyard, @mixin4, @mixin2, @mixin3, P(:String)]
28
28
  end
29
29
 
30
- it "should not modify the object's mixin list when mixins are included" do
30
+ it "does not modify the object's mixin list when mixins are included" do
31
31
  @class1 = ClassObject.new(:root, :A)
32
32
  @class2 = ClassObject.new(:root, :B)
33
33
  @class2.superclass = @class1
34
34
 
35
35
  @class2.inheritance_tree(true)
36
- @class2.mixins.should == []
36
+ expect(@class2.mixins).to eq []
37
37
  end
38
38
 
39
- it "should list class mixins in inheritance tree" do
39
+ it "lists class mixins in inheritance tree" do
40
40
  mod = ModuleObject.new(:root, :ClassMethods)
41
41
  klass = ClassObject.new(:root, :ReceivingClass)
42
42
  klass.class_mixins << mod
43
- klass.inheritance_tree(true).should == [klass, mod]
43
+ expect(klass.inheritance_tree(true)).to eq [klass, mod]
44
44
  end
45
45
  end
46
46
 
@@ -78,45 +78,45 @@ describe YARD::CodeObjects::ClassObject do
78
78
  eof
79
79
  end
80
80
 
81
- it "should show inherited methods by default" do
81
+ it "shows inherited methods by default" do
82
82
  meths = P(:YARD).meths
83
- meths.should include(P("YARD#mymethod"))
84
- meths.should include(P("SuperYard#foo"))
85
- meths.should include(P("SuperYard#foo2"))
86
- meths.should include(P("SuperYard.bar"))
83
+ expect(meths).to include(P("YARD#mymethod"))
84
+ expect(meths).to include(P("SuperYard#foo"))
85
+ expect(meths).to include(P("SuperYard#foo2"))
86
+ expect(meths).to include(P("SuperYard.bar"))
87
87
  end
88
88
 
89
- it "should allow :inherited to be set to false" do
89
+ it "allows :inherited to be set to false" do
90
90
  meths = P(:YARD).meths(:inherited => false)
91
- meths.should include(P("YARD#mymethod"))
92
- meths.should_not include(P("SuperYard#foo"))
93
- meths.should_not include(P("SuperYard#foo2"))
94
- meths.should_not include(P("SuperYard.bar"))
91
+ expect(meths).to include(P("YARD#mymethod"))
92
+ expect(meths).not_to include(P("SuperYard#foo"))
93
+ expect(meths).not_to include(P("SuperYard#foo2"))
94
+ expect(meths).not_to include(P("SuperYard.bar"))
95
95
  end
96
96
 
97
- it "should not show overridden methods" do
97
+ it "does not show overridden methods" do
98
98
  meths = P(:YARD).meths
99
- meths.should include(P("YARD#bar"))
100
- meths.should_not include(P("SuperYard#bar"))
99
+ expect(meths).to include(P("YARD#bar"))
100
+ expect(meths).not_to include(P("SuperYard#bar"))
101
101
 
102
102
  meths = P(:YARD).inherited_meths
103
- meths.should_not include(P("YARD#bar"))
104
- meths.should_not include(P("YARD#mymethod"))
105
- meths.should include(P("SuperYard#foo"))
106
- meths.should include(P("SuperYard#foo2"))
107
- meths.should include(P("SuperYard.bar"))
103
+ expect(meths).not_to include(P("YARD#bar"))
104
+ expect(meths).not_to include(P("YARD#mymethod"))
105
+ expect(meths).to include(P("SuperYard#foo"))
106
+ expect(meths).to include(P("SuperYard#foo2"))
107
+ expect(meths).to include(P("SuperYard.bar"))
108
108
  end
109
109
 
110
- it "should not show inherited methods overridden by other subclasses" do
110
+ it "does not show inherited methods overridden by other subclasses" do
111
111
  meths = P(:YARD).inherited_meths
112
- meths.should include(P('MiddleYard#middle'))
113
- meths.should_not include(P('SuperYard#middle'))
112
+ expect(meths).to include(P('MiddleYard#middle'))
113
+ expect(meths).not_to include(P('SuperYard#middle'))
114
114
  end
115
115
 
116
- it "should show mixed in methods before superclass method" do
116
+ it "shows mixed in methods before superclass method" do
117
117
  meths = P(:FinalYard).meths
118
- meths.should include(P('IncludedYard#foo'))
119
- meths.should_not include(P('SuperYard#foo'))
118
+ expect(meths).to include(P('IncludedYard#foo'))
119
+ expect(meths).not_to include(P('SuperYard#foo'))
120
120
  end
121
121
  end
122
122
 
@@ -142,55 +142,55 @@ describe YARD::CodeObjects::ClassObject do
142
142
  eof
143
143
  end
144
144
 
145
- it "should list inherited constants by default" do
145
+ it "lists inherited constants by default" do
146
146
  consts = P(:SubYard).constants
147
- consts.should include(P("YARD::CONST1"))
148
- consts.should include(P("SubYard::CONST3"))
147
+ expect(consts).to include(P("YARD::CONST1"))
148
+ expect(consts).to include(P("SubYard::CONST3"))
149
149
 
150
150
  consts = P(:SubYard).inherited_constants
151
- consts.should include(P("YARD::CONST1"))
152
- consts.should_not include(P("YARD::CONST2"))
153
- consts.should_not include(P("SubYard::CONST2"))
154
- consts.should_not include(P("SubYard::CONST3"))
151
+ expect(consts).to include(P("YARD::CONST1"))
152
+ expect(consts).not_to include(P("YARD::CONST2"))
153
+ expect(consts).not_to include(P("SubYard::CONST2"))
154
+ expect(consts).not_to include(P("SubYard::CONST3"))
155
155
  end
156
156
 
157
- it "should not list inherited constants if turned off" do
157
+ it "does not list inherited constants if turned off" do
158
158
  consts = P(:SubYard).constants(:inherited => false)
159
- consts.should_not include(P("YARD::CONST1"))
160
- consts.should include(P("SubYard::CONST3"))
159
+ expect(consts).not_to include(P("YARD::CONST1"))
160
+ expect(consts).to include(P("SubYard::CONST3"))
161
161
  end
162
162
 
163
- it "should not include an inherited constant if it is overridden by the object" do
163
+ it "does not include an inherited constant if it is overridden by the object" do
164
164
  consts = P(:SubYard).constants
165
- consts.should include(P("SubYard::CONST2"))
166
- consts.should_not include(P("YARD::CONST2"))
165
+ expect(consts).to include(P("SubYard::CONST2"))
166
+ expect(consts).not_to include(P("YARD::CONST2"))
167
167
  end
168
168
 
169
- it "should not include an inherited constant if it is overridden by another subclass" do
169
+ it "does not include an inherited constant if it is overridden by another subclass" do
170
170
  consts = P(:SubYard).inherited_constants
171
- consts.should include(P("SUPERYARD::CONST4"))
172
- consts.should_not include(P("YARD::CONST4"))
171
+ expect(consts).to include(P("SUPERYARD::CONST4"))
172
+ expect(consts).not_to include(P("YARD::CONST4"))
173
173
  end
174
174
 
175
- it "should not set a superclass on BasicObject class" do
175
+ it "does not set a superclass on BasicObject class" do
176
176
  o = ClassObject.new(:root, :Object)
177
- o.superclass.should == P(:BasicObject)
177
+ expect(o.superclass).to eq P(:BasicObject)
178
178
  end
179
179
 
180
- it "should set superclass of Object to BasicObject" do
180
+ it "sets superclass of Object to BasicObject" do
181
181
  o = ClassObject.new(:root, :BasicObject)
182
- o.superclass.should be_nil
182
+ expect(o.superclass).to be nil
183
183
  end
184
184
 
185
- it "should raise ArgumentError if superclass == self" do
186
- lambda do
185
+ it "raises ArgumentError if superclass == self" do
186
+ expect do
187
187
  o = ClassObject.new(:root, :Object) do |o|
188
188
  o.superclass = :Object
189
189
  end
190
- end.should raise_error(ArgumentError)
190
+ end.to raise_error(ArgumentError)
191
191
  end
192
192
 
193
- it "should tell the world if it is an exception class" do
193
+ it "tells the world if it is an exception class" do
194
194
  o = ClassObject.new(:root, :MyClass)
195
195
  o2 = ClassObject.new(:root, :OtherClass)
196
196
  o2.superclass = :SystemCallError
@@ -199,27 +199,27 @@ describe YARD::CodeObjects::ClassObject do
199
199
  o4 = ClassObject.new(:root, :Object)
200
200
 
201
201
  o.superclass = :Object
202
- o.is_exception?.should == false
202
+ expect(o.is_exception?).to be false
203
203
 
204
204
  o.superclass = :Exception
205
- o.is_exception?.should == true
205
+ expect(o.is_exception?).to be true
206
206
 
207
207
  o.superclass = :NoMethodError
208
- o.is_exception?.should == true
208
+ expect(o.is_exception?).to be true
209
209
 
210
210
  o.superclass = o2
211
- o.is_exception?.should == true
211
+ expect(o.is_exception?).to be true
212
212
 
213
213
  o.superclass = o3
214
- o.is_exception?.should == true
214
+ expect(o.is_exception?).to be true
215
215
  end
216
216
 
217
- it "should not raise ArgumentError if superclass is proxy in different namespace" do
218
- lambda do
217
+ it "does not raise ArgumentError if superclass is proxy in different namespace" do
218
+ expect do
219
219
  o = ClassObject.new(:root, :X) do |o|
220
220
  o.superclass = P('OTHER::X')
221
221
  end
222
- end.should_not raise_error(ArgumentError)
222
+ end.not_to raise_error
223
223
  end
224
224
  end
225
225
  end
@@ -3,31 +3,33 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe YARD::CodeObjects::CodeObjectList do
4
4
  before { Registry.clear }
5
5
 
6
- it "pushing a value should only allow CodeObjects::Base, String or Symbol" do
7
- list = CodeObjectList.new(nil)
8
- lambda { list.push(:hash => 1) }.should raise_error(ArgumentError)
9
- list << "Test"
10
- list << :Test2
11
- list << ModuleObject.new(nil, :YARD)
12
- list.size.should == 3
6
+ describe "#push" do
7
+ it "only allows CodeObjects::Base, String or Symbol" do
8
+ list = CodeObjectList.new(nil)
9
+ expect { list.push(:hash => 1) }.to raise_error(ArgumentError)
10
+ list << "Test"
11
+ list << :Test2
12
+ list << ModuleObject.new(nil, :YARD)
13
+ expect(list.size).to eq 3
14
+ end
13
15
  end
14
16
 
15
17
  it "added value should be a proxy if parameter was String or Symbol" do
16
18
  list = CodeObjectList.new(nil)
17
19
  list << "Test"
18
- list.first.class.should == Proxy
20
+ expect(list.first.class).to eq Proxy
19
21
  end
20
22
 
21
- it "should contain a unique list of objects" do
23
+ it "contains a unique list of objects" do
22
24
  obj = ModuleObject.new(nil, :YARD)
23
25
  list = CodeObjectList.new(nil)
24
26
 
25
27
  list << P(:YARD)
26
28
  list << obj
27
- list.size.should == 1
29
+ expect(list.size).to eq 1
28
30
 
29
31
  list << :Test
30
32
  list << "Test"
31
- list.size.should == 2
33
+ expect(list.size).to eq 2
32
34
  end
33
35
  end
@@ -1,82 +1,92 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- describe YARD::CodeObjects, "CONSTANTMATCH" do
4
- it "should match a constant" do
5
- "Constant"[CodeObjects::CONSTANTMATCH].should == "Constant"
6
- "identifier"[CodeObjects::CONSTANTMATCH].should be_nil
7
- "File.new"[CodeObjects::CONSTANTMATCH].should == "File"
3
+ describe YARD::CodeObjects do
4
+ describe :CONSTANTMATCH do
5
+ it "matches a constant" do
6
+ expect("Constant"[CodeObjects::CONSTANTMATCH]).to eq "Constant"
7
+ expect("identifier"[CodeObjects::CONSTANTMATCH]).to be nil
8
+ expect("File.new"[CodeObjects::CONSTANTMATCH]).to eq "File"
9
+ end
8
10
  end
9
- end
10
11
 
11
- describe YARD::CodeObjects, "NAMESPACEMATCH" do
12
- it "should match a namespace (multiple constants with ::)" do
13
- "Constant"[CodeObjects::NAMESPACEMATCH].should == "Constant"
14
- "A::B::C.new"[CodeObjects::NAMESPACEMATCH].should == "A::B::C"
12
+ describe :CONSTANTSTART do
13
+ it "matches a constant" do
14
+ expect("Constant"[CodeObjects::CONSTANTSTART]).to eq "C"
15
+ expect("identifier"[CodeObjects::CONSTANTSTART]).to be nil
16
+ expect("File.new"[CodeObjects::CONSTANTSTART]).to eq "F"
17
+ end
15
18
  end
16
- end
17
19
 
18
- describe YARD::CodeObjects, "METHODNAMEMATCH" do
19
- it "should match a method name" do
20
- "method"[CodeObjects::METHODNAMEMATCH].should == "method"
21
- "[]()"[CodeObjects::METHODNAMEMATCH].should == "[]"
22
- "-@"[CodeObjects::METHODNAMEMATCH].should == "-@"
23
- "method?"[CodeObjects::METHODNAMEMATCH].should == "method?"
24
- "method!!"[CodeObjects::METHODNAMEMATCH].should == "method!"
20
+ describe :NAMESPACEMATCH do
21
+ it "matches a namespace (multiple constants with ::)" do
22
+ expect("Constant"[CodeObjects::NAMESPACEMATCH]).to eq "Constant"
23
+ expect("A::B::C.new"[CodeObjects::NAMESPACEMATCH]).to eq "A::B::C"
24
+ end
25
25
  end
26
- end
27
26
 
28
- describe YARD::CodeObjects, "METHODMATCH" do
29
- it "should match a full class method path" do
30
- "method"[CodeObjects::METHODMATCH].should == "method"
31
- "A::B::C.method?"[CodeObjects::METHODMATCH].should == "A::B::C.method?"
32
- "A::B::C :: method"[CodeObjects::METHODMATCH].should == "A::B::C :: method"
33
- "SomeClass . method"[CodeObjects::METHODMATCH].should == "SomeClass . method"
27
+ describe :METHODNAMEMATCH do
28
+ it "matches a method name" do
29
+ expect("method"[CodeObjects::METHODNAMEMATCH]).to eq "method"
30
+ expect("[]()"[CodeObjects::METHODNAMEMATCH]).to eq "[]"
31
+ expect("-@"[CodeObjects::METHODNAMEMATCH]).to eq "-@"
32
+ expect("method?"[CodeObjects::METHODNAMEMATCH]).to eq "method?"
33
+ expect("method!!"[CodeObjects::METHODNAMEMATCH]).to eq "method!"
34
+ end
34
35
  end
35
36
 
36
- it "should match self.method" do
37
- "self :: method!"[CodeObjects::METHODMATCH].should == "self :: method!"
38
- "self.is_a?"[CodeObjects::METHODMATCH].should == "self.is_a?"
39
- end
40
- end
37
+ describe :METHODMATCH do
38
+ it "matches a full class method path" do
39
+ expect("method"[CodeObjects::METHODMATCH]).to eq "method"
40
+ expect("A::B::C.method?"[CodeObjects::METHODMATCH]).to eq "A::B::C.method?"
41
+ expect("A::B::C :: method"[CodeObjects::METHODMATCH]).to eq "A::B::C :: method"
42
+ expect("SomeClass . method"[CodeObjects::METHODMATCH]).to eq "SomeClass . method"
43
+ end
41
44
 
42
- describe YARD::CodeObjects, "BUILTIN_EXCEPTIONS" do
43
- it "should include all base exceptions" do
44
- YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
45
- eval(name).should <= Exception
45
+ it "matches self.method" do
46
+ expect("self :: method!"[CodeObjects::METHODMATCH]).to eq "self :: method!"
47
+ expect("self.is_a?"[CodeObjects::METHODMATCH]).to eq "self.is_a?"
46
48
  end
47
49
  end
48
- end
49
50
 
50
- describe YARD::CodeObjects, "BUILTIN_CLASSES" do
51
- it "should include all base classes" do
52
- YARD::CodeObjects::BUILTIN_CLASSES.each do |name|
53
- next if name == "MatchingData" && !defined?(::MatchingData)
54
- next if name == "Continuation"
55
- eval(name).should be_instance_of(Class)
51
+ describe :BUILTIN_EXCEPTIONS do
52
+ it "includes all base exceptions" do
53
+ YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
54
+ expect(eval(name)).to be <= Exception
55
+ end
56
56
  end
57
57
  end
58
58
 
59
- it "should include all exceptions" do
60
- YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
61
- YARD::CodeObjects::BUILTIN_CLASSES.should include(name)
59
+ describe :BUILTIN_CLASSES do
60
+ it "includes all base classes" do
61
+ YARD::CodeObjects::BUILTIN_CLASSES.each do |name|
62
+ next if name == "MatchingData" && !defined?(::MatchingData)
63
+ next if name == "Continuation"
64
+ expect(eval(name)).to be_instance_of(Class)
65
+ end
66
+ end
67
+
68
+ it "includes all exceptions" do
69
+ YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
70
+ expect(YARD::CodeObjects::BUILTIN_CLASSES).to include(name)
71
+ end
62
72
  end
63
73
  end
64
- end
65
74
 
66
- describe YARD::CodeObjects, "BUILTIN_ALL" do
67
- it "should include classes modules and exceptions" do
68
- a = YARD::CodeObjects::BUILTIN_ALL
69
- b = YARD::CodeObjects::BUILTIN_CLASSES
70
- c = YARD::CodeObjects::BUILTIN_MODULES
71
- a.should == b+c
75
+ describe :BUILTIN_ALL do
76
+ it "includes classes, modules, and exceptions" do
77
+ a = YARD::CodeObjects::BUILTIN_ALL
78
+ b = YARD::CodeObjects::BUILTIN_CLASSES
79
+ c = YARD::CodeObjects::BUILTIN_MODULES
80
+ expect(a).to eq b+c
81
+ end
72
82
  end
73
- end
74
83
 
75
- describe YARD::CodeObjects, "BUILTIN_MODULES" do
76
- it "should include all base modules" do
77
- YARD::CodeObjects::BUILTIN_MODULES.each do |name|
78
- next if YARD.ruby19? && ["Precision"].include?(name)
79
- eval(name).should be_instance_of(Module)
84
+ describe :BUILTIN_MODULES do
85
+ it "includes all base modules" do
86
+ YARD::CodeObjects::BUILTIN_MODULES.each do |name|
87
+ next if YARD.ruby19? && ["Precision"].include?(name)
88
+ expect(eval(name)).to be_instance_of(Module)
89
+ end
80
90
  end
81
91
  end
82
- end
92
+ end
@@ -1,147 +1,159 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe YARD::CodeObjects::ExtraFileObject do
4
- describe '#initialize' do
5
- it "should attempt to read contents from filesystem if contents=nil" do
6
- File.should_receive(:read).with('file.txt').and_return('')
4
+ describe "#initialize" do
5
+ it "attempts to read contents from filesystem if contents=nil" do
6
+ expect(File).to receive(:read).with('file.txt').and_return('')
7
7
  ExtraFileObject.new('file.txt')
8
8
  end
9
9
 
10
- it "should raise Errno::ENOENT if contents=nil and file does not exist" do
11
- lambda { ExtraFileObject.new('file.txt') }.should raise_error(Errno::ENOENT)
10
+ it "raises Errno::ENOENT if contents=nil and file does not exist" do
11
+ expect { ExtraFileObject.new('file.txt') }.to raise_error(Errno::ENOENT)
12
12
  end
13
13
 
14
- it "should not attempt to read from disk if contents are provided" do
14
+ it "does not attempt to read from disk if contents are provided" do
15
+ # TODO: no assertions here!
15
16
  ExtraFileObject.new('file.txt', 'CONTENTS')
16
17
  end
17
18
 
18
- it "should set filename to filename" do
19
+ it "sets filename to filename" do
19
20
  file = ExtraFileObject.new('a/b/c/file.txt', 'CONTENTS')
20
- file.filename.should == "a/b/c/file.txt"
21
+ expect(file.filename).to eq "a/b/c/file.txt"
21
22
  end
22
23
 
23
- it "should parse out attributes at top of the file" do
24
+ it "parses out attributes at top of the file" do
24
25
  file = ExtraFileObject.new('file.txt', "# @title X\n# @some_attribute Y\nFOO BAR")
25
- file.attributes[:title].should == "X"
26
- file.attributes[:some_attribute].should == "Y"
27
- file.contents.should == "FOO BAR"
26
+ expect(file.attributes[:title]).to eq "X"
27
+ expect(file.attributes[:some_attribute]).to eq "Y"
28
+ expect(file.contents).to eq "FOO BAR"
28
29
  end
29
30
 
30
- it "should allow whitespace prior to '#' marker when parsing attributes" do
31
+ it "allows whitespace prior to '#' marker when parsing attributes" do
31
32
  file = ExtraFileObject.new('file.txt', " \t # @title X\nFOO BAR")
32
- file.attributes[:title].should == "X"
33
- file.contents.should == "FOO BAR"
33
+ expect(file.attributes[:title]).to eq "X"
34
+ expect(file.contents).to eq "FOO BAR"
34
35
  end
35
36
 
36
- it "should parse out old-style #!markup shebang format" do
37
+ it "allows the attributes section to be wrapped in an HTML comment" do
38
+ file = ExtraFileObject.new('file.txt', "<!--\n# @title X\n-->\nFOO BAR")
39
+ expect(file.attributes[:title]).to eq "X"
40
+ expect(file.contents).to eq "FOO BAR"
41
+ end
42
+
43
+ it "allows whitespace around ignored HTML comment" do
44
+ file = ExtraFileObject.new('file.txt', " \t <!-- \n# @title X\n \t --> \nFOO BAR")
45
+ expect(file.attributes[:title]).to eq "X"
46
+ expect(file.contents).to eq "FOO BAR"
47
+ end
48
+
49
+ it "parses out old-style #!markup shebang format" do
37
50
  file = ExtraFileObject.new('file.txt', "#!foobar\nHello")
38
- file.attributes[:markup].should == "foobar"
51
+ expect(file.attributes[:markup]).to eq "foobar"
39
52
  end
40
53
 
41
- it "should not parse old-style #!markup if any whitespace is found" do
54
+ it "does not parse old-style #!markup if any whitespace is found" do
42
55
  file = ExtraFileObject.new('file.txt', " #!foobar\nHello")
43
- file.attributes[:markup].should be_nil
44
- file.contents.should == " #!foobar\nHello"
56
+ expect(file.attributes[:markup]).to be nil
57
+ expect(file.contents).to eq " #!foobar\nHello"
45
58
  end
46
59
 
47
- it "should not parse out attributes if there are newlines prior to attributes" do
60
+ it "does not parse out attributes if there are newlines prior to attributes" do
48
61
  file = ExtraFileObject.new('file.txt', "\n# @title\nFOO BAR")
49
- file.attributes.should be_empty
50
- file.contents.should == "\n# @title\nFOO BAR"
62
+ expect(file.attributes).to be_empty
63
+ expect(file.contents).to eq "\n# @title\nFOO BAR"
51
64
  end
52
65
 
53
- it "should set contents to data after attributes" do
66
+ it "sets contents to data after attributes" do
54
67
  file = ExtraFileObject.new('file.txt', "# @title\nFOO BAR")
55
- file.contents.should == "FOO BAR"
68
+ expect(file.contents).to eq "FOO BAR"
56
69
  end
57
70
 
58
- it "should preserve newlines" do
71
+ it "preserves newlines" do
59
72
  file = ExtraFileObject.new('file.txt', "FOO\r\nBAR\nBAZ")
60
- file.contents.should == "FOO\r\nBAR\nBAZ"
73
+ expect(file.contents).to eq "FOO\r\nBAR\nBAZ"
61
74
  end
62
75
 
63
- it "should not include newlines in attribute data" do
76
+ it "does not include newlines in attribute data" do
64
77
  file = ExtraFileObject.new('file.txt', "# @title FooBar\r\nHello world")
65
- file.attributes[:title].should == "FooBar"
78
+ expect(file.attributes[:title]).to eq "FooBar"
66
79
  end
67
80
 
68
- it "should force encoding to @encoding attribute if present" do
69
- log.should_not_receive(:warn)
81
+ it "forces encoding to @encoding attribute if present" do
82
+ expect(log).not_to receive(:warn)
70
83
  data = "# @encoding sjis\nFOO"
71
84
  data.force_encoding('binary')
72
85
  file = ExtraFileObject.new('file.txt', data)
73
- ['Shift_JIS', 'Windows-31J'].should include(file.contents.encoding.to_s)
86
+ expect(['Shift_JIS', 'Windows-31J']).to include(file.contents.encoding.to_s)
74
87
  end if YARD.ruby19?
75
88
 
76
- it "should warn if @encoding is invalid" do
77
- log.should_receive(:warn).with("Invalid encoding `INVALID' in file.txt")
89
+ it "warns if @encoding is invalid" do
90
+ expect(log).to receive(:warn).with("Invalid encoding `INVALID' in file.txt")
78
91
  data = "# @encoding INVALID\nFOO"
79
92
  encoding = data.encoding
80
93
  file = ExtraFileObject.new('file.txt', data)
81
- file.contents.encoding.should == encoding
94
+ expect(file.contents.encoding).to eq encoding
82
95
  end if YARD.ruby19?
83
96
 
84
- it "should ignore encoding in 1.8.x (or encoding-unaware platforms)" do
85
- log.should_not_receive(:warn)
97
+ it "ignores encoding in 1.8.x (or encoding-unaware platforms)" do
98
+ expect(log).not_to receive(:warn)
86
99
  file = ExtraFileObject.new('file.txt', "# @encoding INVALID\nFOO")
87
100
  end if YARD.ruby18?
88
101
 
89
- it "should attempt to re-parse data as 8bit ascii if parsing fails" do
90
- log.should_not_receive(:warn)
102
+ it "attempts to re-parse data as 8-bit ascii if parsing fails" do
103
+ expect(log).not_to receive(:warn)
91
104
  str, out = *(["\xB0"] * 2)
92
105
  if str.respond_to?(:force_encoding)
93
106
  str.force_encoding('utf-8')
94
107
  out.force_encoding('binary')
95
108
  end
96
109
  file = ExtraFileObject.new('file.txt', str)
97
- file.contents.should == out
110
+ expect(file.contents).to eq out
98
111
  end
99
112
  end
100
113
 
101
- describe '#name' do
102
- it "should be set to basename (not extension) of filename" do
114
+ describe "#name" do
115
+ it "returns basename (not extension) of filename" do
103
116
  file = ExtraFileObject.new('file.txt', '')
104
- file.name.should == 'file'
117
+ expect(file.name).to eq 'file'
105
118
  end
106
119
  end
107
120
 
108
- describe '#title' do
109
- it "should return @title attribute if present" do
121
+ describe "#title" do
122
+ it "returns @title attribute if present" do
110
123
  file = ExtraFileObject.new('file.txt', '# @title FOO')
111
- file.title.should == 'FOO'
124
+ expect(file.title).to eq 'FOO'
112
125
  end
113
126
 
114
- it "should return #name if no @title attribute exists" do
127
+ it "returns #name if no @title attribute exists" do
115
128
  file = ExtraFileObject.new('file.txt', '')
116
- file.title.should == 'file'
129
+ expect(file.title).to eq 'file'
117
130
  end
118
131
  end
119
132
 
120
- describe '#locale=' do
121
- it "should translate contents" do
133
+ describe "#locale=" do
134
+ it "translates contents" do
122
135
  file = ExtraFileObject.new('file.txt', 'Hello')
123
136
  file.locale = 'fr'
124
137
  fr_locale = I18n::Locale.new('fr')
125
138
  fr_messages = fr_locale.instance_variable_get(:@messages)
126
139
  fr_messages["Hello"] = 'Bonjour'
127
- Registry.should_receive(:locale).with('fr').and_return(fr_locale)
128
- file.contents.should == 'Bonjour'
140
+ expect(Registry).to receive(:locale).with('fr').and_return(fr_locale)
141
+ expect(file.contents).to eq 'Bonjour'
129
142
  end
130
143
  end
131
144
 
132
- describe '#==' do
133
- it "should define equality on filename alone" do
145
+ describe "#==" do
146
+ it "defines equality based on filename alone" do
134
147
  file1 = ExtraFileObject.new('file.txt', 'A')
135
148
  file2 = ExtraFileObject.new('file.txt', 'B')
136
- file1.should == file2
137
- file1.should be_eql(file2)
138
- file1.should be_equal(file2)
149
+ expect(file1).to eq file2
150
+ expect(file1).to eql file2
151
+ expect(file1).to equal file2
139
152
 
140
153
  # Another way to test the equality interface
141
154
  a = [file1]
142
155
  a |= [file2]
143
- a.size.should == 1
156
+ expect(a.size).to eq 1
144
157
  end
145
-
146
158
  end
147
159
  end