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,32 +1,32 @@
1
1
  require File.join(File.dirname(__FILE__), "spec_helper")
2
2
 
3
3
  describe YARD::Logger do
4
- describe '#show_backtraces' do
5
- it "should be true if debug level is on" do
4
+ describe "#show_backtraces" do
5
+ it "is true if debug level is on" do
6
6
  log.show_backtraces = true
7
7
  log.enter_level(Logger::DEBUG) do
8
8
  log.show_backtraces = false
9
- log.show_backtraces.should == true
9
+ expect(log.show_backtraces).to be true
10
10
  end
11
- log.show_backtraces.should == false
11
+ expect(log.show_backtraces).to be false
12
12
  end
13
13
  end
14
14
 
15
- describe '#backtrace' do
15
+ describe "#backtrace" do
16
16
  before { log.show_backtraces = true }
17
- after { log.show_backtraces = false }
17
+ after { log.show_backtraces = false }
18
18
 
19
- it "should log backtrace in error by default" do
20
- log.should_receive(:error).with("RuntimeError: foo")
21
- log.should_receive(:error).with("Stack trace:\n\tline1\n\tline2\n")
19
+ it "logs backtrace in error by default" do
20
+ expect(log).to receive(:error).with("RuntimeError: foo")
21
+ expect(log).to receive(:error).with("Stack trace:\n\tline1\n\tline2\n")
22
22
  exc = RuntimeError.new("foo")
23
23
  exc.set_backtrace(['line1', 'line2'])
24
24
  log.enter_level(Logger::INFO) { log.backtrace(exc) }
25
25
  end
26
26
 
27
- it "should allow backtrace to be entered in other modes" do
28
- log.should_receive(:warn).with("RuntimeError: foo")
29
- log.should_receive(:warn).with("Stack trace:\n\tline1\n\tline2\n")
27
+ it "allows backtrace to be entered in other modes" do
28
+ expect(log).to receive(:warn).with("RuntimeError: foo")
29
+ expect(log).to receive(:warn).with("Stack trace:\n\tline1\n\tline2\n")
30
30
  exc = RuntimeError.new("foo")
31
31
  exc.set_backtrace(['line1', 'line2'])
32
32
  log.enter_level(Logger::INFO) { log.backtrace(exc, :warn) }
@@ -6,38 +6,38 @@ describe YARD::Options do
6
6
  def initialize; self.foo = "abc" end
7
7
  end
8
8
 
9
- describe '.default_attr' do
10
- it "should allow default attributes to be defined with symbols" do
9
+ describe ".default_attr" do
10
+ it "allows default attributes to be defined with symbols" do
11
11
  class DefaultOptions1 < YARD::Options
12
12
  default_attr :foo, 'HELLO'
13
13
  end
14
14
  o = DefaultOptions1.new
15
15
  o.reset_defaults
16
- o.foo.should == 'HELLO'
16
+ expect(o.foo).to eq 'HELLO'
17
17
  end
18
18
 
19
- it "should call lambda if value is a Proc" do
19
+ it "calls lambda if value is a Proc" do
20
20
  class DefaultOptions2 < YARD::Options
21
21
  default_attr :foo, lambda { 100 }
22
22
  end
23
23
  o = DefaultOptions2.new
24
24
  o.reset_defaults
25
- o.foo.should == 100
25
+ expect(o.foo).to eq 100
26
26
  end
27
27
  end
28
28
 
29
- describe '#reset_defaults' do
30
- it "should not define defaults until reset is called" do
29
+ describe "#reset_defaults" do
30
+ it "does not define defaults until reset is called" do
31
31
  class ResetDefaultOptions1 < YARD::Options
32
32
  default_attr :foo, 'FOO'
33
33
  end
34
- ResetDefaultOptions1.new.foo.should be_nil
34
+ expect(ResetDefaultOptions1.new.foo).to be nil
35
35
  o = ResetDefaultOptions1.new
36
36
  o.reset_defaults
37
- o.foo.should == 'FOO'
37
+ expect(o.foo).to eq 'FOO'
38
38
  end
39
39
 
40
- it "should use defaults from superclass as well" do
40
+ it "uses defaults from superclass as well" do
41
41
  class ResetDefaultOptions2 < YARD::Options
42
42
  default_attr :foo, 'FOO'
43
43
  end
@@ -45,127 +45,127 @@ describe YARD::Options do
45
45
  end
46
46
  o = ResetDefaultOptions3.new
47
47
  o.reset_defaults
48
- o.foo.should == 'FOO'
48
+ expect(o.foo).to eq 'FOO'
49
49
  end
50
50
  end
51
51
 
52
- describe '#delete' do
53
- it "should delete an option" do
52
+ describe "#delete" do
53
+ it "deletes an option" do
54
54
  o = FooOptions.new
55
55
  o.delete(:foo)
56
- o.to_hash.should == {}
56
+ expect(o.to_hash).to eq({})
57
57
  end
58
58
 
59
- it "should not error if an option is deleted that does not exist" do
59
+ it "does not error if an option is deleted that does not exist" do
60
60
  o = FooOptions.new
61
61
  o.delete(:foo)
62
62
  o.delete(:foo)
63
- o.to_hash.should == {}
63
+ expect(o.to_hash).to eq({})
64
64
  end
65
65
  end
66
66
 
67
- describe '#[]' do
68
- it "should handle getting option values using hash syntax" do
69
- FooOptions.new[:foo].should == "abc"
67
+ describe "#[]" do
68
+ it "handles getting option values using hash syntax" do
69
+ expect(FooOptions.new[:foo]).to eq "abc"
70
70
  end
71
71
  end
72
72
 
73
- describe '#[]=' do
74
- it "should handle setting options using hash syntax" do
73
+ describe "#[]=" do
74
+ it "handles setting options using hash syntax" do
75
75
  o = FooOptions.new
76
76
  o[:foo] = "xyz"
77
- o[:foo].should == "xyz"
77
+ expect(o[:foo]).to eq "xyz"
78
78
  end
79
79
 
80
- it "should allow setting of unregistered keys" do
80
+ it "allows setting of unregistered keys" do
81
81
  o = FooOptions.new
82
82
  o[:bar] = "foo"
83
- o[:bar].should == "foo"
83
+ expect(o[:bar]).to eq "foo"
84
84
  end
85
85
  end
86
86
 
87
- describe '#method_missing' do
88
- it "should allow setting of unregistered keys" do
87
+ describe "#method_missing" do
88
+ it "allows setting of unregistered keys" do
89
89
  o = FooOptions.new
90
90
  o.bar = 'foo'
91
- o.bar.should == 'foo'
91
+ expect(o.bar).to eq 'foo'
92
92
  end
93
93
 
94
- it "should allow getting values of unregistered keys (return nil)" do
95
- FooOptions.new.bar.should be_nil
94
+ it "allows getting values of unregistered keys (return nil)" do
95
+ expect(FooOptions.new.bar).to be nil
96
96
  end
97
97
 
98
- it "should print debugging messages about unregistered keys" do
99
- log.should_receive(:debug).with("Attempting to access unregistered key bar on FooOptions")
98
+ it "prints debugging messages about unregistered keys" do
99
+ expect(log).to receive(:debug).with("Attempting to access unregistered key bar on FooOptions")
100
100
  FooOptions.new.bar
101
- log.should_receive(:debug).with("Attempting to set unregistered key bar on FooOptions")
101
+ expect(log).to receive(:debug).with("Attempting to set unregistered key bar on FooOptions")
102
102
  FooOptions.new.bar = 1
103
103
  end
104
104
  end
105
105
 
106
- describe '#update' do
107
- it "should allow updating of options" do
108
- FooOptions.new.update(:foo => "xyz").foo.should == "xyz"
106
+ describe "#update" do
107
+ it "allows updating of options" do
108
+ expect(FooOptions.new.update(:foo => "xyz").foo).to eq "xyz"
109
109
  end
110
110
 
111
- it "should not ignore keys with no setter (OpenStruct behaviour)" do
111
+ it "does not ignore keys with no setter (OpenStruct behaviour)" do
112
112
  o = FooOptions.new
113
113
  o.update(:bar => "xyz")
114
- o.to_hash.should == {:foo => "abc", :bar => "xyz"}
114
+ expect(o.to_hash).to eq({:foo => "abc", :bar => "xyz"})
115
115
  end
116
116
  end
117
117
 
118
- describe '#merge' do
119
- it "should update a new object" do
118
+ describe "#merge" do
119
+ it "updates a new object" do
120
120
  o = FooOptions.new
121
- o.merge(:foo => "xyz").object_id.should_not == o.object_id
122
- o.merge(:foo => "xyz").to_hash.should == {:foo => "xyz"}
121
+ expect(o.merge(:foo => "xyz").object_id).not_to eq o.object_id
122
+ expect(o.merge(:foo => "xyz").to_hash).to eq({:foo => "xyz"})
123
123
  end
124
124
 
125
- it "should add in values from original object" do
125
+ it "adds in values from original object" do
126
126
  o = FooOptions.new
127
127
  o.update(:bar => "foo")
128
- o.merge(:baz => 1).to_hash.should == {:foo => "abc", :bar => "foo", :baz => 1}
128
+ expect(o.merge(:baz => 1).to_hash).to eq({:foo => "abc", :bar => "foo", :baz => 1})
129
129
  end
130
130
  end
131
131
 
132
- describe '#to_hash' do
133
- it "should convert all instance variables and symbolized keys" do
132
+ describe "#to_hash" do
133
+ it "converts all instance variables and symbolized keys" do
134
134
  class ToHashOptions1 < YARD::Options
135
135
  attr_accessor :foo, :bar, :baz
136
136
  def initialize; @foo = 1; @bar = 2; @baz = "hello" end
137
137
  end
138
138
  o = ToHashOptions1.new
139
139
  hash = o.to_hash
140
- hash.keys.should include(:foo, :bar, :baz)
141
- hash[:foo].should == 1
142
- hash[:bar].should == 2
143
- hash[:baz].should == "hello"
140
+ expect(hash.keys).to include(:foo, :bar, :baz)
141
+ expect(hash[:foo]).to eq 1
142
+ expect(hash[:bar]).to eq 2
143
+ expect(hash[:baz]).to eq "hello"
144
144
  end
145
145
 
146
- it "should use accessor when converting values to hash" do
146
+ it "uses accessor when converting values to hash" do
147
147
  class ToHashOptions2 < YARD::Options
148
148
  def initialize; @foo = 1 end
149
149
  def foo; "HELLO#{@foo}" end
150
150
  end
151
151
  o = ToHashOptions2.new
152
- o.to_hash.should == {:foo => "HELLO1"}
152
+ expect(o.to_hash).to eq({:foo => "HELLO1"})
153
153
  end
154
154
 
155
- it "should ignore ivars with no accessor" do
155
+ it "ignores ivars with no accessor" do
156
156
  class ToHashOptions3 < YARD::Options
157
157
  attr_accessor :foo
158
158
  def initialize; @foo = 1; @bar = "NOIGNORE" end
159
159
  end
160
160
  o = ToHashOptions3.new
161
- o.to_hash.should == {:foo => 1, :bar => "NOIGNORE"}
161
+ expect(o.to_hash).to eq({:foo => 1, :bar => "NOIGNORE"})
162
162
  end
163
163
  end
164
164
 
165
- describe '#tap' do
166
- it "should support #tap(&block) (even in 1.8.6)" do
165
+ describe "#tap" do
166
+ it "supports #tap(&block) (even in 1.8.6)" do
167
167
  o = FooOptions.new.tap {|o| o.foo = :BAR }
168
- o.to_hash.should == {:foo => :BAR}
168
+ expect(o.to_hash).to eq({:foo => :BAR})
169
169
  end
170
170
  end
171
171
  end
@@ -1,24 +1,24 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
3
  describe YARD::Parser::Base do
4
- describe '#initialize' do
4
+ describe "#initialize" do
5
5
  class MyParser < Parser::Base; def initialize(a, b) end end
6
6
 
7
- it "should take 2 arguments" do
8
- lambda { YARD::Parser::Base.new }.should raise_error(ArgumentError,
7
+ it "takes 2 arguments" do
8
+ expect { YARD::Parser::Base.new }.to raise_error(ArgumentError,
9
9
  /wrong (number|#) of arguments|given 0, expected 2/)
10
10
  end
11
11
 
12
- it "should raise NotImplementedError on #initialize" do
13
- lambda { YARD::Parser::Base.new('a', 'b') }.should raise_error(NotImplementedError)
12
+ it "raises NotImplementedError on #initialize" do
13
+ expect { YARD::Parser::Base.new('a', 'b') }.to raise_error(NotImplementedError)
14
14
  end
15
15
 
16
- it "should raise NotImplementedError on #parse" do
17
- lambda { MyParser.new('a', 'b').parse }.should raise_error(NotImplementedError)
16
+ it "raises NotImplementedError on #parse" do
17
+ expect { MyParser.new('a', 'b').parse }.to raise_error(NotImplementedError)
18
18
  end
19
19
 
20
- it "should raise NotImplementedError on #tokenize" do
21
- lambda { MyParser.new('a', 'b').tokenize }.should raise_error(NotImplementedError)
20
+ it "raises NotImplementedError on #tokenize" do
21
+ expect { MyParser.new('a', 'b').tokenize }.to raise_error(NotImplementedError)
22
22
  end
23
23
  end
24
24
  end
@@ -1,60 +1,60 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
3
  describe YARD::Parser::C::CParser do
4
- describe '#parse' do
4
+ describe "#parse" do
5
5
  def parse(contents)
6
6
  Registry.clear
7
7
  YARD.parse_string(contents, :c)
8
8
  end
9
9
 
10
- describe 'Array class' do
10
+ describe "Array class" do
11
11
  before(:all) do
12
12
  file = File.join(File.dirname(__FILE__), 'examples', 'array.c.txt')
13
13
  parse(File.read(file))
14
14
  end
15
15
 
16
- it "should parse Array class" do
16
+ it "parses Array class" do
17
17
  obj = YARD::Registry.at('Array')
18
- obj.should_not be_nil
19
- obj.docstring.should_not be_blank
18
+ expect(obj).not_to be nil
19
+ expect(obj.docstring).not_to be_blank
20
20
  end
21
21
 
22
- it "should parse method" do
22
+ it "parses method" do
23
23
  obj = YARD::Registry.at('Array#initialize')
24
- obj.docstring.should_not be_blank
25
- obj.tags(:overload).size.should > 1
24
+ expect(obj.docstring).not_to be_blank
25
+ expect(obj.tags(:overload).size).to be > 1
26
26
  end
27
27
  end
28
28
 
29
- describe 'Source located in extra files' do
29
+ describe "Source located in extra files" do
30
30
  before(:all) do
31
31
  @multifile = File.join(File.dirname(__FILE__), 'examples', 'multifile.c.txt')
32
32
  @extrafile = File.join(File.dirname(__FILE__), 'examples', 'extrafile.c.txt')
33
33
  @contents = File.read(@multifile)
34
34
  end
35
35
 
36
- it "should look for methods in extra files (if 'in' comment is found)" do
36
+ it "looks for methods in extra files (if 'in' comment is found)" do
37
37
  extra_contents = File.read(@extrafile)
38
- File.should_receive(:read).with('extra.c').and_return(extra_contents)
38
+ expect(File).to receive(:read).with('extra.c').and_return(extra_contents)
39
39
  parse(@contents)
40
- Registry.at('Multifile#extra').docstring.should == 'foo'
40
+ expect(Registry.at('Multifile#extra').docstring).to eq 'foo'
41
41
  end
42
42
 
43
- it "should stop searching for extra source file gracefully if file is not found" do
44
- File.should_receive(:read).with('extra.c').and_raise(Errno::ENOENT)
45
- log.should_receive(:warn).with("Missing source file `extra.c' when parsing Multifile#extra")
43
+ it "stops searching for extra source file gracefully if file is not found" do
44
+ expect(File).to receive(:read).with('extra.c').and_raise(Errno::ENOENT)
45
+ expect(log).to receive(:warn).with("Missing source file `extra.c' when parsing Multifile#extra")
46
46
  parse(@contents)
47
- Registry.at('Multifile#extra').docstring.should == ''
47
+ expect(Registry.at('Multifile#extra').docstring).to eq ''
48
48
  end
49
49
 
50
- it "should differentiate between a struct and a pointer to a struct retval" do
50
+ it "differentiates between a struct and a pointer to a struct retval" do
51
51
  parse(@contents)
52
- Registry.at('Multifile#hello_mars').docstring.should == 'Hello Mars'
52
+ expect(Registry.at('Multifile#hello_mars').docstring).to eq 'Hello Mars'
53
53
  end
54
54
  end
55
55
 
56
- describe 'Foo class' do
57
- it 'should not include comments in docstring source' do
56
+ describe "Foo class" do
57
+ it "does not include comments in docstring source" do
58
58
  parse <<-eof
59
59
  /*
60
60
  * Hello world
@@ -67,13 +67,13 @@ describe YARD::Parser::C::CParser do
67
67
  rb_define_method(rb_cFoo, "foo", foo, 1);
68
68
  }
69
69
  eof
70
- Registry.at('Foo#foo').source.gsub(/\s\s+/, ' ').should ==
71
- "VALUE foo(VALUE x) { int value = x;\n}"
70
+ expect(Registry.at('Foo#foo').source.gsub(/\s\s+/, ' ')).to eq(
71
+ "VALUE foo(VALUE x) { int value = x;\n}")
72
72
  end
73
73
  end
74
74
 
75
- describe 'Constant' do
76
- it 'should not truncate docstring' do
75
+ describe "Constant" do
76
+ it "does not truncate docstring" do
77
77
  parse <<-eof
78
78
  #define MSK_DEADBEEF 0xdeadbeef
79
79
  void
@@ -86,13 +86,13 @@ describe YARD::Parser::C::CParser do
86
86
  }
87
87
  eof
88
88
  constant = Registry.at('Mask::DEADBEEF')
89
- constant.value.should == '0xdeadbeef'
90
- constant.docstring.should == "This constant is frequently used to indicate a\nsoftware crash or deadlock in embedded systems."
89
+ expect(constant.value).to eq '0xdeadbeef'
90
+ expect(constant.docstring).to eq "This constant is frequently used to indicate a\nsoftware crash or deadlock in embedded systems."
91
91
  end
92
92
  end
93
93
 
94
- describe 'Macros' do
95
- it "should handle param## inside of macros" do
94
+ describe "Macros" do
95
+ it "handles param## inside of macros" do
96
96
  thr = Thread.new do
97
97
  parse <<-eof
98
98
  void
@@ -127,8 +127,8 @@ describe YARD::Parser::C::CParser do
127
127
  end
128
128
  end
129
129
 
130
- describe 'C macros in declaration' do
131
- it "should handle C macros in method declaration" do
130
+ describe "C macros in declaration" do
131
+ it "handles C macros in method declaration" do
132
132
  Registry.clear
133
133
  parse <<-eof
134
134
  // docstring
@@ -141,49 +141,49 @@ describe YARD::Parser::C::CParser do
141
141
  }
142
142
  eof
143
143
 
144
- Registry.at('Foo#func').docstring.should == "docstring"
144
+ expect(Registry.at('Foo#func').docstring).to eq "docstring"
145
145
  end
146
146
  end
147
147
  end
148
148
 
149
- describe 'Override comments' do
149
+ describe "Override comments" do
150
150
  before(:all) do
151
151
  Registry.clear
152
152
  override_file = File.join(File.dirname(__FILE__), 'examples', 'override.c.txt')
153
153
  @override_parser = YARD.parse_string(File.read(override_file), :c)
154
154
  end
155
155
 
156
- it "should parse GMP::Z class" do
156
+ it "parses GMP::Z class" do
157
157
  z = YARD::Registry.at('GMP::Z')
158
- z.should_not be_nil
159
- z.docstring.should_not be_blank
158
+ expect(z).not_to be nil
159
+ expect(z.docstring).not_to be_blank
160
160
  end
161
161
 
162
- it "should parse GMP::Z methods w/ bodies" do
162
+ it "parses GMP::Z methods w/ bodies" do
163
163
  add = YARD::Registry.at('GMP::Z#+')
164
- add.docstring.should_not be_blank
165
- add.source.should_not be_nil
166
- add.source.should_not be_empty
164
+ expect(add.docstring).not_to be_blank
165
+ expect(add.source).not_to be nil
166
+ expect(add.source).not_to be_empty
167
167
 
168
168
  add_self = YARD::Registry.at('GMP::Z#+')
169
- add_self.docstring.should_not be_blank
170
- add_self.source.should_not be_nil
171
- add_self.source.should_not be_empty
169
+ expect(add_self.docstring).not_to be_blank
170
+ expect(add_self.source).not_to be nil
171
+ expect(add_self.source).not_to be_empty
172
172
 
173
173
  sqrtrem = YARD::Registry.at('GMP::Z#+')
174
- sqrtrem.docstring.should_not be_blank
175
- sqrtrem.source.should_not be_nil
176
- sqrtrem.source.should_not be_empty
174
+ expect(sqrtrem.docstring).not_to be_blank
175
+ expect(sqrtrem.source).not_to be nil
176
+ expect(sqrtrem.source).not_to be_empty
177
177
  end
178
178
 
179
- it "should parse GMP::Z methods w/o bodies" do
179
+ it "parses GMP::Z methods w/o bodies" do
180
180
  neg = YARD::Registry.at('GMP::Z#neg')
181
- neg.docstring.should_not be_blank
182
- neg.source.should be_nil
181
+ expect(neg.docstring).not_to be_blank
182
+ expect(neg.source).to be nil
183
183
 
184
184
  neg_self = YARD::Registry.at('GMP::Z#neg')
185
- neg_self.docstring.should_not be_blank
186
- neg_self.source.should be_nil
185
+ expect(neg_self.docstring).not_to be_blank
186
+ expect(neg_self.source).to be nil
187
187
  end
188
188
  end
189
189
  end