yard 0.8.7.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/LICENSE +2 -2
  4. data/README.md +2 -2
  5. data/Rakefile +1 -1
  6. data/bin/yard +0 -0
  7. data/bin/yardoc +0 -0
  8. data/bin/yri +0 -0
  9. data/docs/GettingStarted.md +88 -6
  10. data/docs/images/handlers-class-diagram.png +0 -0
  11. data/docs/images/overview-class-diagram.png +0 -0
  12. data/docs/images/parser-class-diagram.png +0 -0
  13. data/docs/templates/default/fulldoc/html/full_list_tag.erb +6 -4
  14. data/lib/yard/autoload.rb +3 -0
  15. data/lib/yard/cli/yardoc.rb +1 -1
  16. data/lib/yard/code_objects/base.rb +4 -1
  17. data/lib/yard/code_objects/extra_file_object.rb +3 -1
  18. data/lib/yard/code_objects/proxy.rb +2 -2
  19. data/lib/yard/docstring.rb +11 -6
  20. data/lib/yard/handlers/base.rb +1 -2
  21. data/lib/yard/handlers/c/base.rb +19 -0
  22. data/lib/yard/handlers/c/handler_methods.rb +42 -8
  23. data/lib/yard/handlers/c/init_handler.rb +1 -1
  24. data/lib/yard/handlers/c/method_handler.rb +3 -3
  25. data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
  26. data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
  27. data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
  28. data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
  29. data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
  30. data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
  31. data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
  32. data/lib/yard/logging.rb +1 -0
  33. data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
  34. data/lib/yard/parser/source_parser.rb +6 -6
  35. data/lib/yard/rake/yardoc_task.rb +2 -2
  36. data/lib/yard/serializers/file_system_serializer.rb +33 -1
  37. data/lib/yard/server/commands/display_file_command.rb +8 -3
  38. data/lib/yard/server/commands/display_object_command.rb +7 -3
  39. data/lib/yard/server/doc_server_helper.rb +2 -8
  40. data/lib/yard/server/doc_server_serializer.rb +2 -4
  41. data/lib/yard/server/router.rb +1 -1
  42. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
  43. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
  44. data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
  45. data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
  46. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
  47. data/lib/yard/tags/directives.rb +1 -0
  48. data/lib/yard/tags/library.rb +9 -7
  49. data/lib/yard/tags/overload_tag.rb +4 -1
  50. data/lib/yard/templates/helpers/html_helper.rb +4 -3
  51. data/lib/yard/templates/template_options.rb +3 -0
  52. data/lib/yard/version.rb +1 -1
  53. data/spec/cli/command_parser_spec.rb +14 -14
  54. data/spec/cli/command_spec.rb +11 -11
  55. data/spec/cli/config_spec.rb +32 -32
  56. data/spec/cli/diff_spec.rb +86 -90
  57. data/spec/cli/display_spec.rb +6 -6
  58. data/spec/cli/gems_spec.rb +28 -28
  59. data/spec/cli/graph_spec.rb +8 -8
  60. data/spec/cli/help_spec.rb +8 -8
  61. data/spec/cli/i18n_spec.rb +33 -37
  62. data/spec/cli/list_spec.rb +2 -2
  63. data/spec/cli/markup_types_spec.rb +3 -3
  64. data/spec/cli/server_spec.rb +74 -88
  65. data/spec/cli/stats_spec.rb +14 -14
  66. data/spec/cli/yardoc_spec.rb +316 -321
  67. data/spec/cli/yri_spec.rb +45 -45
  68. data/spec/code_objects/base_spec.rb +174 -173
  69. data/spec/code_objects/class_object_spec.rb +65 -65
  70. data/spec/code_objects/code_object_list_spec.rb +13 -11
  71. data/spec/code_objects/constants_spec.rb +68 -58
  72. data/spec/code_objects/extra_file_object_spec.rb +71 -59
  73. data/spec/code_objects/macro_object_spec.rb +64 -64
  74. data/spec/code_objects/method_object_spec.rb +80 -72
  75. data/spec/code_objects/module_object_spec.rb +47 -47
  76. data/spec/code_objects/namespace_object_spec.rb +51 -51
  77. data/spec/code_objects/proxy_spec.rb +54 -54
  78. data/spec/config_spec.rb +104 -104
  79. data/spec/core_ext/array_spec.rb +5 -5
  80. data/spec/core_ext/file_spec.rb +33 -33
  81. data/spec/core_ext/hash_spec.rb +5 -5
  82. data/spec/core_ext/insertion_spec.rb +18 -18
  83. data/spec/core_ext/module_spec.rb +6 -6
  84. data/spec/core_ext/string_spec.rb +17 -17
  85. data/spec/core_ext/symbol_hash_spec.rb +42 -39
  86. data/spec/docstring_parser_spec.rb +65 -65
  87. data/spec/docstring_spec.rb +137 -130
  88. data/spec/handlers/alias_handler_spec.rb +39 -39
  89. data/spec/handlers/attribute_handler_spec.rb +35 -35
  90. data/spec/handlers/base_spec.rb +60 -51
  91. data/spec/handlers/c/alias_handler_spec.rb +6 -6
  92. data/spec/handlers/c/attribute_handler_spec.rb +12 -12
  93. data/spec/handlers/c/class_handler_spec.rb +35 -22
  94. data/spec/handlers/c/constant_handler_spec.rb +24 -22
  95. data/spec/handlers/c/init_handler_spec.rb +10 -10
  96. data/spec/handlers/c/method_handler_spec.rb +150 -65
  97. data/spec/handlers/c/mixin_handler_spec.rb +5 -5
  98. data/spec/handlers/c/module_handler_spec.rb +27 -15
  99. data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
  100. data/spec/handlers/c/path_handler_spec.rb +8 -8
  101. data/spec/handlers/c/spec_helper.rb +10 -0
  102. data/spec/handlers/c/struct_handler_spec.rb +3 -3
  103. data/spec/handlers/class_condition_handler_spec.rb +18 -18
  104. data/spec/handlers/class_handler_spec.rb +97 -97
  105. data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
  106. data/spec/handlers/class_variable_handler_spec.rb +3 -3
  107. data/spec/handlers/constant_handler_spec.rb +32 -29
  108. data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
  109. data/spec/handlers/dsl_handler_spec.rb +108 -109
  110. data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
  111. data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
  112. data/spec/handlers/exception_handler_spec.rb +23 -23
  113. data/spec/handlers/extend_handler_spec.rb +9 -9
  114. data/spec/handlers/legacy_base_spec.rb +60 -60
  115. data/spec/handlers/method_condition_handler_spec.rb +5 -5
  116. data/spec/handlers/method_handler_spec.rb +92 -92
  117. data/spec/handlers/mixin_handler_spec.rb +25 -25
  118. data/spec/handlers/module_function_handler_spec.rb +24 -24
  119. data/spec/handlers/module_handler_spec.rb +15 -15
  120. data/spec/handlers/private_class_method_handler_spec.rb +4 -48
  121. data/spec/handlers/private_constant_handler_spec.rb +8 -8
  122. data/spec/handlers/processor_spec.rb +12 -12
  123. data/spec/handlers/public_class_method_handler_spec.rb +10 -0
  124. data/spec/handlers/ruby/base_spec.rb +16 -16
  125. data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
  126. data/spec/handlers/spec_helper.rb +1 -1
  127. data/spec/handlers/visibility_handler_spec.rb +25 -21
  128. data/spec/handlers/yield_handler_spec.rb +28 -28
  129. data/spec/i18n/locale_spec.rb +16 -16
  130. data/spec/i18n/message_spec.rb +8 -8
  131. data/spec/i18n/messages_spec.rb +14 -14
  132. data/spec/i18n/pot_generator_spec.rb +32 -32
  133. data/spec/i18n/text_spec.rb +22 -22
  134. data/spec/logging_spec.rb +12 -12
  135. data/spec/options_spec.rb +56 -56
  136. data/spec/parser/base_spec.rb +9 -9
  137. data/spec/parser/c_parser_spec.rb +50 -50
  138. data/spec/parser/ruby/ast_node_spec.rb +7 -7
  139. data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
  140. data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
  141. data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
  142. data/spec/parser/source_parser_spec.rb +224 -224
  143. data/spec/parser/tag_parsing_spec.rb +6 -7
  144. data/spec/rake/yardoc_task_spec.rb +38 -48
  145. data/spec/registry_spec.rb +143 -143
  146. data/spec/registry_store_spec.rb +165 -165
  147. data/spec/rubygems/doc_manager_spec.rb +38 -38
  148. data/spec/serializers/file_system_serializer_spec.rb +53 -33
  149. data/spec/serializers/yardoc_serializer_spec.rb +15 -15
  150. data/spec/server/adapter_spec.rb +15 -15
  151. data/spec/server/commands/base_spec.rb +29 -29
  152. data/spec/server/commands/library_command_spec.rb +12 -12
  153. data/spec/server/commands/static_file_command_spec.rb +28 -28
  154. data/spec/server/doc_server_helper_spec.rb +8 -8
  155. data/spec/server/doc_server_serializer_spec.rb +23 -18
  156. data/spec/server/rack_adapter_spec.rb +6 -6
  157. data/spec/server/router_spec.rb +39 -39
  158. data/spec/server/static_caching_spec.rb +16 -16
  159. data/spec/server/webrick_servlet_spec.rb +6 -7
  160. data/spec/server_spec.rb +3 -3
  161. data/spec/spec_helper.rb +11 -2
  162. data/spec/tags/default_factory_spec.rb +64 -64
  163. data/spec/tags/default_tag_spec.rb +5 -5
  164. data/spec/tags/directives_spec.rb +121 -121
  165. data/spec/tags/library_spec.rb +14 -14
  166. data/spec/tags/overload_tag_spec.rb +24 -24
  167. data/spec/tags/ref_tag_list_spec.rb +12 -12
  168. data/spec/templates/class_spec.rb +3 -3
  169. data/spec/templates/constant_spec.rb +4 -4
  170. data/spec/templates/engine_spec.rb +47 -48
  171. data/spec/templates/examples/class001.html +129 -101
  172. data/spec/templates/examples/class002.html +31 -27
  173. data/spec/templates/examples/method001.html +54 -47
  174. data/spec/templates/examples/method002.html +33 -28
  175. data/spec/templates/examples/method003.html +70 -64
  176. data/spec/templates/examples/method004.html +13 -9
  177. data/spec/templates/examples/method005.html +38 -32
  178. data/spec/templates/examples/module001.html +343 -339
  179. data/spec/templates/examples/module002.html +147 -124
  180. data/spec/templates/examples/module003.html +94 -81
  181. data/spec/templates/examples/module004.html +40 -33
  182. data/spec/templates/helpers/base_helper_spec.rb +91 -95
  183. data/spec/templates/helpers/html_helper_spec.rb +276 -279
  184. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
  185. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
  186. data/spec/templates/helpers/markup_helper_spec.rb +57 -57
  187. data/spec/templates/helpers/method_helper_spec.rb +20 -20
  188. data/spec/templates/helpers/shared_signature_examples.rb +33 -31
  189. data/spec/templates/helpers/text_helper_spec.rb +6 -6
  190. data/spec/templates/method_spec.rb +7 -7
  191. data/spec/templates/module_spec.rb +7 -7
  192. data/spec/templates/onefile_spec.rb +7 -7
  193. data/spec/templates/section_spec.rb +66 -69
  194. data/spec/templates/spec_helper.rb +1 -1
  195. data/spec/templates/tag_spec.rb +5 -5
  196. data/spec/templates/template_spec.rb +158 -158
  197. data/spec/verifier_spec.rb +52 -52
  198. data/templates/default/fulldoc/html/css/full_list.css +32 -31
  199. data/templates/default/fulldoc/html/css/style.css +212 -77
  200. data/templates/default/fulldoc/html/frames.erb +6 -15
  201. data/templates/default/fulldoc/html/full_list.erb +14 -21
  202. data/templates/default/fulldoc/html/full_list_class.erb +1 -1
  203. data/templates/default/fulldoc/html/full_list_file.erb +6 -4
  204. data/templates/default/fulldoc/html/full_list_method.erb +8 -6
  205. data/templates/default/fulldoc/html/js/app.js +100 -76
  206. data/templates/default/fulldoc/html/js/full_list.js +170 -135
  207. data/templates/default/fulldoc/html/setup.rb +50 -7
  208. data/templates/default/layout/html/breadcrumb.erb +0 -2
  209. data/templates/default/layout/html/headers.erb +2 -1
  210. data/templates/default/layout/html/layout.erb +16 -10
  211. data/templates/default/layout/html/script_setup.erb +1 -2
  212. data/templates/default/layout/html/search.erb +7 -2
  213. data/templates/default/layout/html/setup.rb +16 -0
  214. data/templates/default/method/html/header.erb +7 -6
  215. data/templates/default/module/html/attribute_summary.erb +1 -1
  216. data/templates/default/module/html/box_info.erb +24 -18
  217. data/templates/default/module/html/constant_summary.erb +9 -11
  218. data/templates/default/module/html/item_summary.erb +1 -1
  219. data/templates/default/module/html/method_summary.erb +1 -1
  220. data/templates/guide/fulldoc/html/setup.rb +1 -1
  221. data/yard.gemspec +1 -2
  222. metadata +10 -7
  223. data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
  224. data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
  225. data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
@@ -3,174 +3,174 @@ require File.join(File.dirname(__FILE__), "spec_helper")
3
3
  require 'yaml'
4
4
 
5
5
  describe YARD::Config do
6
- describe '.load' do
6
+ describe ".load" do
7
7
  before do
8
- File.should_receive(:file?).twice.with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
8
+ expect(File).to receive(:file?).twice.with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
9
9
  end
10
10
 
11
- it "should use default options if no ~/.yard/config is found" do
12
- File.should_receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
13
- File.should_receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
11
+ it "uses default options if no ~/.yard/config is found" do
12
+ expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
13
+ expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
14
14
  YARD::Config.load
15
- YARD::Config.options.should == YARD::Config::DEFAULT_CONFIG_OPTIONS
15
+ expect(YARD::Config.options).to eq YARD::Config::DEFAULT_CONFIG_OPTIONS
16
16
  end
17
17
 
18
- it "should overwrite options with data in ~/.yard/config" do
19
- File.should_receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(true)
20
- File.should_receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
21
- YAML.should_receive(:load_file).with(YARD::Config::CONFIG_FILE).and_return({'test' => true})
18
+ it "overwrites options with data in ~/.yard/config" do
19
+ expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(true)
20
+ expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
21
+ expect(YAML).to receive(:load_file).with(YARD::Config::CONFIG_FILE).and_return({'test' => true})
22
22
  YARD::Config.load
23
- YARD::Config.options[:test].should be_true
23
+ expect(YARD::Config.options[:test]).to be true
24
24
  end
25
25
 
26
- it "should ignore any plugins specified in '~/.yard/ignored_plugins'" do
27
- File.should_receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
28
- File.should_receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(true)
29
- File.should_receive(:read).with(YARD::Config::IGNORED_PLUGINS).and_return('yard-plugin plugin2')
26
+ it "ignores any plugins specified in '~/.yard/ignored_plugins'" do
27
+ expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
28
+ expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(true)
29
+ expect(File).to receive(:read).with(YARD::Config::IGNORED_PLUGINS).and_return('yard-plugin plugin2')
30
30
  YARD::Config.load
31
- YARD::Config.options[:ignored_plugins].should == ['yard-plugin', 'yard-plugin2']
32
- YARD::Config.should_not_receive(:require).with('yard-plugin2')
33
- YARD::Config.load_plugin('yard-plugin2').should == false
31
+ expect(YARD::Config.options[:ignored_plugins]).to eq ['yard-plugin', 'yard-plugin2']
32
+ expect(YARD::Config).not_to receive(:require).with('yard-plugin2')
33
+ expect(YARD::Config.load_plugin('yard-plugin2')).to be false
34
34
  end
35
35
 
36
- it "should load safe_mode setting from --safe command line option" do
37
- File.should_receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
38
- File.should_receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
36
+ it "loads safe_mode setting from --safe command line option" do
37
+ expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
38
+ expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
39
39
  ARGV.replace(['--safe'])
40
40
  YARD::Config.load
41
- YARD::Config.options[:safe_mode].should be_true
41
+ expect(YARD::Config.options[:safe_mode]).to be true
42
42
  ARGV.replace([''])
43
43
  end
44
44
  end
45
45
 
46
- describe '.save' do
47
- it "should save options to config file" do
48
- YARD::Config.stub!(:options).and_return(:a => 1, :b => %w(a b c))
49
- file = mock(:file)
50
- File.should_receive(:open).with(YARD::Config::CONFIG_FILE, 'w').and_yield(file)
51
- file.should_receive(:write).with(YAML.dump(:a => 1, :b => %w(a b c)))
46
+ describe ".save" do
47
+ it "saves options to config file" do
48
+ allow(YARD::Config).to receive(:options).and_return(:a => 1, :b => %w(a b c))
49
+ file = double(:file)
50
+ expect(File).to receive(:open).with(YARD::Config::CONFIG_FILE, 'w').and_yield(file)
51
+ expect(file).to receive(:write).with(YAML.dump(:a => 1, :b => %w(a b c)))
52
52
  YARD::Config.save
53
53
  end
54
54
  end
55
55
 
56
- describe '.load_plugin' do
57
- it "should load a plugin by 'name' as 'yard-name'" do
58
- YARD::Config.should_receive(:require).with('yard-foo')
59
- log.should_receive(:debug).with(/Loading plugin 'yard-foo'/).once
60
- YARD::Config.load_plugin('foo').should == true
56
+ describe ".load_plugin" do
57
+ it "loads a plugin by 'name' as 'yard-name'" do
58
+ expect(YARD::Config).to receive(:require).with('yard-foo')
59
+ expect(log).to receive(:debug).with(/Loading plugin 'yard-foo'/).once
60
+ expect(YARD::Config.load_plugin('foo')).to be true
61
61
  end
62
62
 
63
- it "should not load plugins like 'doc-*'" do
64
- YARD::Config.should_not_receive(:require).with('yard-doc-core')
63
+ it "does not load plugins like 'doc-*'" do
64
+ expect(YARD::Config).not_to receive(:require).with('yard-doc-core')
65
65
  YARD::Config.load_plugin('doc-core')
66
66
  YARD::Config.load_plugin('yard-doc-core')
67
67
  end
68
68
 
69
- it "should load plugin by 'yard-name' as 'yard-name'" do
70
- YARD::Config.should_receive(:require).with('yard-foo')
71
- log.should_receive(:debug).with(/Loading plugin 'yard-foo'/).once
72
- YARD::Config.load_plugin('yard-foo').should == true
69
+ it "loads plugin by 'yard-name' as 'yard-name'" do
70
+ expect(YARD::Config).to receive(:require).with('yard-foo')
71
+ expect(log).to receive(:debug).with(/Loading plugin 'yard-foo'/).once
72
+ expect(YARD::Config.load_plugin('yard-foo')).to be true
73
73
  end
74
74
 
75
- it "should load plugin by 'yard_name' as 'yard_name'" do
76
- YARD::Config.should_receive(:require).with('yard_foo')
77
- log.should_receive(:debug).with(/Loading plugin 'yard_foo'/).once
75
+ it "loads plugin by 'yard_name' as 'yard_name'" do
76
+ expect(YARD::Config).to receive(:require).with('yard_foo')
77
+ expect(log).to receive(:debug).with(/Loading plugin 'yard_foo'/).once
78
78
  log.show_backtraces = false
79
- YARD::Config.load_plugin('yard_foo').should == true
79
+ expect(YARD::Config.load_plugin('yard_foo')).to be true
80
80
  end
81
81
 
82
- it "should log error if plugin is not found" do
83
- YARD::Config.should_receive(:require).with('yard-foo').and_raise(LoadError)
84
- log.should_receive(:warn).with(/Error loading plugin 'yard-foo'/).once
85
- YARD::Config.load_plugin('yard-foo').should == false
82
+ it "logs error if plugin is not found" do
83
+ expect(YARD::Config).to receive(:require).with('yard-foo').and_raise(LoadError)
84
+ expect(log).to receive(:warn).with(/Error loading plugin 'yard-foo'/).once
85
+ expect(YARD::Config.load_plugin('yard-foo')).to be false
86
86
  end
87
87
 
88
- it "should sanitize plugin name (remove /'s)" do
89
- YARD::Config.should_receive(:require).with('yard-foofoo')
90
- YARD::Config.load_plugin('foo/foo').should == true
88
+ it "sanitizes plugin name (remove /'s)" do
89
+ expect(YARD::Config).to receive(:require).with('yard-foofoo')
90
+ expect(YARD::Config.load_plugin('foo/foo')).to be true
91
91
  end
92
92
 
93
- it "should ignore plugins in :ignore_plugins" do
94
- YARD::Config.stub!(:options).and_return(:ignored_plugins => ['yard-foo', 'yard-bar'])
95
- YARD::Config.load_plugin('foo').should == false
96
- YARD::Config.load_plugin('bar').should == false
93
+ it "ignores plugins in :ignore_plugins" do
94
+ allow(YARD::Config).to receive(:options).and_return(:ignored_plugins => ['yard-foo', 'yard-bar'])
95
+ expect(YARD::Config.load_plugin('foo')).to be false
96
+ expect(YARD::Config.load_plugin('bar')).to be false
97
97
  end
98
98
  end
99
99
 
100
- describe '.load_plugins' do
101
- it "should load gem plugins if :load_plugins is true" do
102
- YARD::Config.stub!(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
103
- YARD::Config.stub!(:load_plugin)
104
- YARD::Config.should_receive(:require).with('rubygems')
100
+ describe ".load_plugins" do
101
+ it "loads gem plugins if :load_plugins is true" do
102
+ allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
103
+ allow(YARD::Config).to receive(:load_plugin)
104
+ expect(YARD::Config).to receive(:require).with('rubygems')
105
105
  YARD::Config.load_plugins
106
106
  end
107
107
 
108
- it "should ignore gem loading if RubyGems cannot load" do
109
- YARD::Config.stub!(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
110
- YARD::Config.should_receive(:require).with('rubygems').and_raise(LoadError)
111
- YARD::Config.load_plugins.should == false
108
+ it "ignores gem loading if RubyGems cannot load" do
109
+ allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
110
+ expect(YARD::Config).to receive(:require).with('rubygems').and_raise(LoadError)
111
+ expect(YARD::Config.load_plugins).to be false
112
112
  end
113
113
 
114
- it "should load certain plugins automatically when specified in :autoload_plugins" do
115
- File.should_receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
116
- YARD::Config.stub!(:options).and_return(:load_plugins => false, :ignored_plugins => [], :autoload_plugins => ['yard-plugin'])
117
- YARD::Config.should_receive(:require).with('yard-plugin').and_return(true)
118
- YARD::Config.load_plugins.should == true
114
+ it "loads certain plugins automatically when specified in :autoload_plugins" do
115
+ expect(File).to receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
116
+ allow(YARD::Config).to receive(:options).and_return(:load_plugins => false, :ignored_plugins => [], :autoload_plugins => ['yard-plugin'])
117
+ expect(YARD::Config).to receive(:require).with('yard-plugin').and_return(true)
118
+ expect(YARD::Config.load_plugins).to be true
119
119
  end
120
120
 
121
- it "should parse --plugin from command line arguments" do
122
- YARD::Config.should_receive(:arguments).at_least(1).times.and_return(%w(--plugin foo --plugin bar a b c))
123
- YARD::Config.should_receive(:load_plugin).with('foo').and_return(true)
124
- YARD::Config.should_receive(:load_plugin).with('bar').and_return(true)
125
- YARD::Config.load_plugins.should == true
121
+ it "parses --plugin from command line arguments" do
122
+ expect(YARD::Config).to receive(:arguments).at_least(1).times.and_return(%w(--plugin foo --plugin bar a b c))
123
+ expect(YARD::Config).to receive(:load_plugin).with('foo').and_return(true)
124
+ expect(YARD::Config).to receive(:load_plugin).with('bar').and_return(true)
125
+ expect(YARD::Config.load_plugins).to be true
126
126
  end
127
127
 
128
- it "should load --plugin arguments from .yardopts" do
129
- File.should_receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).twice.and_return(true)
130
- File.should_receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
131
- File.should_receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
132
- File.should_receive(:read_binary).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).twice.and_return('--plugin foo')
133
- YARD::Config.should_receive(:load_plugin).with('foo')
128
+ it "loads --plugin arguments from .yardopts" do
129
+ expect(File).to receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).twice.and_return(true)
130
+ expect(File).to receive(:file?).with(YARD::Config::CONFIG_FILE).and_return(false)
131
+ expect(File).to receive(:file?).with(YARD::Config::IGNORED_PLUGINS).and_return(false)
132
+ expect(File).to receive(:read_binary).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).twice.and_return('--plugin foo')
133
+ expect(YARD::Config).to receive(:load_plugin).with('foo')
134
134
  YARD::Config.load
135
135
  end
136
136
 
137
- it "should load any gem plugins starting with 'yard_' or 'yard-'" do
138
- File.should_receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
139
- YARD::Config.stub!(:options).and_return(:load_plugins => true, :ignored_plugins => ['yard_plugin'], :autoload_plugins => [])
137
+ it "loads any gem plugins starting with 'yard_' or 'yard-'" do
138
+ expect(File).to receive(:file?).with(CLI::Yardoc::DEFAULT_YARDOPTS_FILE).and_return(false)
139
+ allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => ['yard_plugin'], :autoload_plugins => [])
140
140
  plugins = {
141
- 'yard' => mock('yard'),
142
- 'yard_plugin' => mock('yard_plugin'),
143
- 'yard-plugin' => mock('yard-plugin'),
144
- 'my-yard-plugin' => mock('yard-plugin'),
145
- 'rspec' => mock('rspec'),
141
+ 'yard' => double('yard'),
142
+ 'yard_plugin' => double('yard_plugin'),
143
+ 'yard-plugin' => double('yard-plugin'),
144
+ 'my-yard-plugin' => double('yard-plugin'),
145
+ 'rspec' => double('rspec'),
146
146
  }
147
147
  plugins.each do |k, v|
148
- v.should_receive(:name).at_least(1).times.and_return(k)
148
+ expect(v).to receive(:name).at_least(1).times.and_return(k)
149
149
  end
150
150
 
151
- source_mock = mock(:source_index)
152
- source_mock.should_receive(:find_name).with('').and_return(plugins.values)
153
- Gem.should_receive(:source_index).and_return(source_mock)
154
- YARD::Config.should_receive(:load_plugin).with('yard_plugin').and_return(false)
155
- YARD::Config.should_receive(:load_plugin).with('yard-plugin').and_return(true)
156
- YARD::Config.load_plugins.should == true
151
+ source_mock = double(:source_index)
152
+ expect(source_mock).to receive(:find_name).with('').and_return(plugins.values)
153
+ expect(Gem).to receive(:source_index).and_return(source_mock)
154
+ expect(YARD::Config).to receive(:load_plugin).with('yard_plugin').and_return(false)
155
+ expect(YARD::Config).to receive(:load_plugin).with('yard-plugin').and_return(true)
156
+ expect(YARD::Config.load_plugins).to be true
157
157
  end
158
158
 
159
- it "should log an error if a gem raises an error" do
160
- YARD::Config.stub!(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
159
+ it "logs an error if a gem raises an error" do
160
+ allow(YARD::Config).to receive(:options).and_return(:load_plugins => true, :ignored_plugins => [], :autoload_plugins => [])
161
161
  plugins = {
162
- 'yard-plugin' => mock('yard-plugin')
162
+ 'yard-plugin' => double('yard-plugin')
163
163
  }
164
164
  plugins.each do |k, v|
165
- v.should_receive(:name).at_least(1).times.and_return(k)
165
+ expect(v).to receive(:name).at_least(1).times.and_return(k)
166
166
  end
167
167
 
168
- source_mock = mock(:source_index)
169
- source_mock.should_receive(:find_name).with('').and_return(plugins.values)
170
- Gem.should_receive(:source_index).and_return(source_mock)
171
- YARD::Config.should_receive(:load_plugin).with('yard-plugin').and_raise(Gem::LoadError)
172
- log.should_receive(:warn).with(/Error loading plugin 'yard-plugin'/)
173
- YARD::Config.load_plugins.should == false
168
+ source_mock = double(:source_index)
169
+ expect(source_mock).to receive(:find_name).with('').and_return(plugins.values)
170
+ expect(Gem).to receive(:source_index).and_return(source_mock)
171
+ expect(YARD::Config).to receive(:load_plugin).with('yard-plugin').and_raise(Gem::LoadError)
172
+ expect(log).to receive(:warn).with(/Error loading plugin 'yard-plugin'/)
173
+ expect(YARD::Config.load_plugins).to be false
174
174
  end
175
175
  end
176
176
  end
@@ -1,13 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe Array do
4
- describe '#place' do
5
- it "should create an Insertion object" do
6
- [].place('x').should be_kind_of(Insertion)
4
+ describe "#place" do
5
+ it "creates an Insertion object" do
6
+ expect([].place('x')).to be_kind_of(Insertion)
7
7
  end
8
8
 
9
- it "should allow multiple objects to be placed" do
10
- [1, 2].place('x', 'y', 'z').before(2).should == [1, 'x', 'y', 'z', 2]
9
+ it "allows multiple objects to be placed" do
10
+ expect([1, 2].place('x', 'y', 'z').before(2)).to eq [1, 'x', 'y', 'z', 2]
11
11
  end
12
12
  end
13
13
  end
@@ -2,66 +2,66 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe File do
4
4
  describe ".relative_path" do
5
- it "should return the relative path between two files" do
6
- File.relative_path('a/b/c/d.html', 'a/b/d/q.html').should == '../d/q.html'
5
+ it "returns the relative path between two files" do
6
+ expect(File.relative_path('a/b/c/d.html', 'a/b/d/q.html')).to eq '../d/q.html'
7
7
  end
8
8
 
9
- it "should return the relative path between two directories" do
10
- File.relative_path('a/b/c/d/', 'a/b/d/').should == '../d'
9
+ it "returns the relative path between two directories" do
10
+ expect(File.relative_path('a/b/c/d/', 'a/b/d/')).to eq '../d'
11
11
  end
12
12
 
13
- it "should return only the to file if from file is in the same directory as the to file" do
14
- File.relative_path('a/b/c/d', 'a/b/c/e').should == 'e'
13
+ it "returns only the to file if from file is in the same directory as the to file" do
14
+ expect(File.relative_path('a/b/c/d', 'a/b/c/e')).to eq 'e'
15
15
  end
16
16
 
17
- it "should handle non-normalized paths" do
18
- File.relative_path('Hello/./I/Am/Fred', 'Hello/Fred').should == '../../Fred'
19
- File.relative_path('A//B/C', 'Q/X').should == '../../Q/X'
17
+ it "handles non-normalized paths" do
18
+ expect(File.relative_path('Hello/./I/Am/Fred', 'Hello/Fred')).to eq '../../Fred'
19
+ expect(File.relative_path('A//B/C', 'Q/X')).to eq '../../Q/X'
20
20
  end
21
21
  end
22
22
 
23
- describe '.cleanpath' do
24
- it "should clean double brackets" do
25
- File.cleanpath('A//B/C').should == "A/B/C"
23
+ describe ".cleanpath" do
24
+ it "cleans double brackets" do
25
+ expect(File.cleanpath('A//B/C')).to eq "A/B/C"
26
26
  end
27
27
 
28
- it "should clean a path with ." do
29
- File.cleanpath('Hello/./I/.Am/Fred').should == "Hello/I/.Am/Fred"
28
+ it "cleans a path with ." do
29
+ expect(File.cleanpath('Hello/./I/.Am/Fred')).to eq "Hello/I/.Am/Fred"
30
30
  end
31
31
 
32
- it "should clean a path with .." do
33
- File.cleanpath('Hello/../World').should == "World"
32
+ it "cleans a path with .." do
33
+ expect(File.cleanpath('Hello/../World')).to eq "World"
34
34
  end
35
35
 
36
- it "should clean a path with multiple .." do
37
- File.cleanpath('A/B/C/../../D').should == "A/D"
36
+ it "cleans a path with multiple .." do
37
+ expect(File.cleanpath('A/B/C/../../D')).to eq "A/D"
38
38
  end
39
39
 
40
- it "should clean a path ending in .." do
41
- File.cleanpath('A/B/C/D/..').should == "A/B/C"
40
+ it "cleans a path ending in .." do
41
+ expect(File.cleanpath('A/B/C/D/..')).to eq "A/B/C"
42
42
  end
43
43
 
44
- it "should pass the initial directory" do
45
- File.cleanpath('C/../../D').should == "../D"
44
+ it "passes the initial directory" do
45
+ expect(File.cleanpath('C/../../D')).to eq "../D"
46
46
  end
47
47
 
48
- it "should not remove multiple '../' at the beginning" do
49
- File.cleanpath('../../A/B').should == '../../A/B'
48
+ it "does not remove multiple '../' at the beginning" do
49
+ expect(File.cleanpath('../../A/B')).to eq '../../A/B'
50
50
  end
51
51
  end
52
52
 
53
- describe '.open!' do
54
- it "should create the path before opening" do
55
- File.should_receive(:directory?).with('/path/to').and_return(false)
56
- FileUtils.should_receive(:mkdir_p).with('/path/to')
57
- File.should_receive(:open).with('/path/to/file', 'w')
53
+ describe ".open!" do
54
+ it "creates the path before opening" do
55
+ expect(File).to receive(:directory?).with('/path/to').and_return(false)
56
+ expect(FileUtils).to receive(:mkdir_p).with('/path/to')
57
+ expect(File).to receive(:open).with('/path/to/file', 'w')
58
58
  File.open!('/path/to/file', 'w')
59
59
  end
60
60
 
61
- it "should just open the file if the path exists" do
62
- File.should_receive(:directory?).with('/path/to').and_return(true)
63
- FileUtils.should_not_receive(:mkdir_p)
64
- File.should_receive(:open).with('/path/to/file', 'w')
61
+ it "just opens the file if the path exists" do
62
+ expect(File).to receive(:directory?).with('/path/to').and_return(true)
63
+ expect(FileUtils).not_to receive(:mkdir_p)
64
+ expect(File).to receive(:open).with('/path/to/file', 'w')
65
65
  File.open!('/path/to/file', 'w')
66
66
  end
67
67
  end
@@ -1,14 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe Hash do
4
- describe '.[]' do
5
- it "should accept an Array argument (Ruby 1.8.6 and older)" do
4
+ describe ".[]" do
5
+ it "accepts an Array argument (Ruby 1.8.6 and older)" do
6
6
  list = [['foo', 'bar'], ['foo2', 'bar2']]
7
- Hash[list].should == {'foo' => 'bar', 'foo2' => 'bar2'}
7
+ expect(Hash[list]).to eq({'foo' => 'bar', 'foo2' => 'bar2'})
8
8
  end
9
9
 
10
- it "should accept an array as a key" do
11
- Hash[['a', 'b'], 1].should == {['a', 'b'] => 1}
10
+ it "accepts an array as a key" do
11
+ expect(Hash[['a', 'b'], 1]).to eq({['a', 'b'] => 1})
12
12
  end
13
13
  end
14
14
  end
@@ -1,37 +1,37 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe Insertion do
4
- describe '#before' do
5
- it "should place an object before another" do
6
- [1, 2].place(3).before(2).should == [1, 3, 2]
7
- [1, 2].place(3).before(1).should == [3, 1, 2]
8
- [1, [4], 2].place(3).before(2).should == [1, [4], 3, 2]
4
+ describe "#before" do
5
+ it "places an object before another" do
6
+ expect([1, 2].place(3).before(2)).to eq [1, 3, 2]
7
+ expect([1, 2].place(3).before(1)).to eq [3, 1, 2]
8
+ expect([1, [4], 2].place(3).before(2)).to eq [1, [4], 3, 2]
9
9
  end
10
10
  end
11
11
 
12
- describe '#after' do
13
- it "should place an object after another" do
14
- [1, 2].place(3).after(2).should == [1, 2, 3]
12
+ describe "#after" do
13
+ it "places an object after another" do
14
+ expect([1, 2].place(3).after(2)).to eq [1, 2, 3]
15
15
  end
16
16
 
17
- it "should no longer place an object after another and its subsections (0.6)" do
18
- [1, [2]].place(3).after(1).should == [1, 3, [2]]
17
+ it "no longer places an object after another and its subsections (0.6)" do
18
+ expect([1, [2]].place(3).after(1)).to eq [1, 3, [2]]
19
19
  end
20
20
 
21
- it "should place an array after an object" do
22
- [1, 2, 3].place([4]).after(1).should == [1, [4], 2, 3]
21
+ it "places an array after an object" do
22
+ expect([1, 2, 3].place([4]).after(1)).to eq [1, [4], 2, 3]
23
23
  end
24
24
  end
25
25
 
26
- describe '#before_any' do
27
- it "should place an object before another anywhere inside list (including sublists)" do
28
- [1, 2, [3]].place(4).before_any(3).should == [1, 2, [4, 3]]
26
+ describe "#before_any" do
27
+ it "places an object before another anywhere inside list (including sublists)" do
28
+ expect([1, 2, [3]].place(4).before_any(3)).to eq [1, 2, [4, 3]]
29
29
  end
30
30
  end
31
31
 
32
- describe '#after_any' do
33
- it "should place an object after another anywhere inside list (including sublists)" do
34
- [1, 2, [3]].place(4).after_any(3).should == [1, 2, [3, 4]]
32
+ describe "#after_any" do
33
+ it "places an object after another anywhere inside list (including sublists)" do
34
+ expect([1, 2, [3]].place(4).after_any(3)).to eq [1, 2, [3, 4]]
35
35
  end
36
36
  end
37
37
  end