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
@@ -6,86 +6,86 @@ describe YARD::CLI::Config do
6
6
  before do
7
7
  @config = YARD::CLI::Config.new
8
8
  YARD::Config.options = YARD::Config::DEFAULT_CONFIG_OPTIONS.dup
9
- YARD::Config.stub!(:save)
9
+ allow(YARD::Config).to receive(:save)
10
10
  end
11
11
 
12
12
  def run(*args)
13
13
  @config.run(*args)
14
14
  end
15
15
 
16
- describe 'Listing configuration' do
17
- it "should accept --list" do
16
+ describe "Listing configuration" do
17
+ it "accepts --list" do
18
18
  opts = YARD::Config.options
19
- YAML.should_receive(:dump).twice.and_return("--- foo\nbar\nbaz")
20
- log.should_receive(:puts).twice.with("bar\nbaz")
19
+ expect(YAML).to receive(:dump).twice.and_return("--- foo\nbar\nbaz")
20
+ expect(log).to receive(:puts).twice.with("bar\nbaz")
21
21
  run
22
22
  run('--list')
23
- YARD::Config.options.should == opts
23
+ expect(YARD::Config.options).to eq opts
24
24
  end
25
25
  end
26
26
 
27
- describe 'Viewing an item' do
28
- it "should view item if no value is given" do
27
+ describe "Viewing an item" do
28
+ it "views item if no value is given" do
29
29
  YARD::Config.options[:foo] = 'bar'
30
- log.should_receive(:puts).with('"bar"')
30
+ expect(log).to receive(:puts).with('"bar"')
31
31
  run 'foo'
32
- YARD::Config.options[:foo].should == 'bar'
32
+ expect(YARD::Config.options[:foo]).to eq 'bar'
33
33
  end
34
34
  end
35
35
 
36
- describe 'Modifying an item' do
37
- it "should accept --reset to set value" do
36
+ describe "Modifying an item" do
37
+ it "accepts --reset to set value" do
38
38
  YARD::Config.options[:load_plugins] = 'foo'
39
39
  run('--reset', 'load_plugins')
40
- YARD::Config.options[:load_plugins].should == false
40
+ expect(YARD::Config.options[:load_plugins]).to be false
41
41
  end
42
42
 
43
- it "should accept --as-list to force single item as list" do
43
+ it "accepts --as-list to force single item as list" do
44
44
  run('--as-list', 'foo', 'bar')
45
- YARD::Config.options[:foo].should == ['bar']
45
+ expect(YARD::Config.options[:foo]).to eq ['bar']
46
46
  end
47
47
 
48
- it "should accept --append to append values to existing key" do
48
+ it "accepts --append to append values to existing key" do
49
49
  YARD::Config.options[:foo] = ['bar']
50
50
  run('--append', 'foo', 'baz', 'quux')
51
- YARD::Config.options[:foo].should == ['bar', 'baz', 'quux']
51
+ expect(YARD::Config.options[:foo]).to eq ['bar', 'baz', 'quux']
52
52
  run('-a', 'foo', 'last')
53
- YARD::Config.options[:foo].should == ['bar', 'baz', 'quux', 'last']
53
+ expect(YARD::Config.options[:foo]).to eq ['bar', 'baz', 'quux', 'last']
54
54
  end
55
55
 
56
- it "should turn key into list if --append is used on single item" do
56
+ it "turns key into list if --append is used on single item" do
57
57
  YARD::Config.options[:foo] = 'bar'
58
58
  run('-a', 'foo', 'baz')
59
- YARD::Config.options[:foo].should == ['bar', 'baz']
59
+ expect(YARD::Config.options[:foo]).to eq ['bar', 'baz']
60
60
  end
61
61
 
62
- it "should modify item if value is given" do
62
+ it "modifies item if value is given" do
63
63
  run('foo', 'xxx')
64
- YARD::Config.options[:foo].should == 'xxx'
64
+ expect(YARD::Config.options[:foo]).to eq 'xxx'
65
65
  end
66
66
 
67
- it "should turn list of values into array of values" do
67
+ it "turns list of values into array of values" do
68
68
  run('foo', 'a', 'b', '1', 'true', 'false')
69
- YARD::Config.options[:foo].should == ['a', 'b', 1, true, false]
69
+ expect(YARD::Config.options[:foo]).to eq ['a', 'b', 1, true, false]
70
70
  end
71
71
 
72
- it "should turn number into numeric Ruby type" do
72
+ it "turns number into numeric Ruby type" do
73
73
  run('foo', '1')
74
- YARD::Config.options[:foo].should == 1
74
+ expect(YARD::Config.options[:foo]).to eq 1
75
75
  end
76
76
 
77
- it "should turn true into TrueClass" do
77
+ it "turns true into TrueClass" do
78
78
  run('foo', 'true')
79
- YARD::Config.options[:foo].should == true
79
+ expect(YARD::Config.options[:foo]).to be true
80
80
  end
81
81
 
82
- it "should turn false into FalseClass" do
82
+ it "turns false into FalseClass" do
83
83
  run('foo', 'false')
84
- YARD::Config.options[:foo].should == false
84
+ expect(YARD::Config.options[:foo]).to be false
85
85
  end
86
86
 
87
- it "should save on modification" do
88
- YARD::Config.should_receive(:save)
87
+ it "saves on modification" do
88
+ expect(YARD::Config).to receive(:save)
89
89
  run('foo', 'true')
90
90
  end
91
91
  end
@@ -4,20 +4,20 @@ require 'open-uri'
4
4
 
5
5
  describe YARD::CLI::Diff do
6
6
  before do
7
- CLI::Yardoc.stub!(:run)
8
- CLI::Gems.stub!(:run)
7
+ allow(CLI::Yardoc).to receive(:run)
8
+ allow(CLI::Gems).to receive(:run)
9
9
  @diff = CLI::Diff.new
10
10
  end
11
11
 
12
- describe 'Argument handling' do
13
- it "should exit if there is only one gem name" do
14
- @diff.should_receive(:exit)
15
- log.should_receive(:puts).with(/Usage/)
12
+ describe "Argument handling" do
13
+ it "exits if there is only one gem name" do
14
+ expect(@diff).to receive(:exit)
15
+ expect(log).to receive(:puts).with(/Usage/)
16
16
  @diff.run
17
17
  end
18
18
  end
19
19
 
20
- describe 'Diffing' do
20
+ describe "Diffing" do
21
21
  before do
22
22
  @objects1 = nil
23
23
  @objects2 = nil
@@ -29,7 +29,7 @@ describe YARD::CLI::Diff do
29
29
  @objects1 ||= %w( C#fooey C#baz D.bar )
30
30
  @objects2 ||= %w( A A::B A::B::C A.foo A#foo B C.foo C.bar C#baz )
31
31
  @objects = [@objects1, @objects2]
32
- @diff.should_receive(:load_gem_data).ordered.with('gem1') do
32
+ expect(@diff).to receive(:load_gem_data).ordered.with('gem1') do
33
33
  Registry.clear
34
34
  YARD.parse_string <<-eof
35
35
  class C
@@ -41,7 +41,7 @@ describe YARD::CLI::Diff do
41
41
  end
42
42
  eof
43
43
  end
44
- @diff.should_receive(:load_gem_data).ordered.with('gem2') do
44
+ expect(@diff).to receive(:load_gem_data).ordered.with('gem2') do
45
45
  Registry.clear
46
46
  YARD.parse_string <<-eof
47
47
  module A
@@ -58,14 +58,14 @@ describe YARD::CLI::Diff do
58
58
  end
59
59
  eof
60
60
  end
61
- log.stub!(:print) {|data| @data << data }
62
- log.stub!(:puts) {|*args| @data << args.join("\n"); @data << "\n" }
61
+ allow(log).to receive(:print) {|data| @data << data }
62
+ allow(log).to receive(:puts) {|*args| @data << args.join("\n"); @data << "\n" }
63
63
  @diff.run(*(args + ['gem1', 'gem2']))
64
64
  end
65
65
 
66
- it "should show differences between objects" do
66
+ it "shows differences between objects" do
67
67
  run
68
- @data.string.should == <<-eof
68
+ expect(@data.string).to eq <<-eof
69
69
  Added objects:
70
70
 
71
71
  A ((stdin):1) (...)
@@ -85,9 +85,9 @@ Removed objects:
85
85
  eof
86
86
  end
87
87
 
88
- it "should accept --compact" do
88
+ it "accepts --compact" do
89
89
  run('--compact')
90
- @data.string.should == <<-eof
90
+ expect(@data.string).to eq <<-eof
91
91
  A A ((stdin):1) (...)
92
92
  A A::B::C ((stdin):3)
93
93
  A C.bar ((stdin):10)
@@ -98,10 +98,10 @@ D D ((stdin):5) (...)
98
98
  eof
99
99
  end
100
100
 
101
- it "should accept -a/--all" do
101
+ it "accepts -a/--all" do
102
102
  ['-a', '--all'].each do |opt|
103
103
  run(opt)
104
- @data.string.should == <<-eof
104
+ expect(@data.string).to eq <<-eof
105
105
  Added objects:
106
106
 
107
107
  A ((stdin):1)
@@ -126,9 +126,9 @@ eof
126
126
  end
127
127
  end
128
128
 
129
- it "should accept --compact and --all" do
129
+ it "accepts --compact and --all" do
130
130
  run('--compact', '--all')
131
- @data.string.should == <<-eof
131
+ expect(@data.string).to eq <<-eof
132
132
  A A ((stdin):1)
133
133
  A A#foo ((stdin):6)
134
134
  A A.foo ((stdin):5)
@@ -143,9 +143,9 @@ D D.bar ((stdin):6)
143
143
  eof
144
144
  end
145
145
 
146
- it "should accept --no-modified" do
146
+ it "accepts --no-modified" do
147
147
  run('--compact', '--no-modified')
148
- @data.string.should == <<-eof
148
+ expect(@data.string).to eq <<-eof
149
149
  A A ((stdin):1) (...)
150
150
  A A::B::C ((stdin):3)
151
151
  A C.bar ((stdin):10)
@@ -155,9 +155,9 @@ D D ((stdin):5) (...)
155
155
  eof
156
156
  end
157
157
 
158
- it "should accept --query" do
158
+ it "accepts --query" do
159
159
  run('--compact', '--query', 'o.type == :method')
160
- @data.string.should == <<-eof
160
+ expect(@data.string).to eq <<-eof
161
161
  A A#foo ((stdin):6)
162
162
  A A.foo ((stdin):5)
163
163
  A C.bar ((stdin):10)
@@ -169,91 +169,87 @@ eof
169
169
  end
170
170
  end
171
171
 
172
- describe 'File searching' do
172
+ describe "File searching" do
173
173
  before do
174
- @diff.stub!(:generate_yardoc)
174
+ allow(@diff).to receive(:generate_yardoc)
175
175
  end
176
176
 
177
- it "should search for gem/.yardoc" do
178
- File.should_receive(:directory?).with('gem1/.yardoc').and_return(true)
179
- File.should_receive(:directory?).with('gem2/.yardoc').and_return(true)
180
- Registry.should_receive(:load_yardoc).with('gem1/.yardoc')
181
- Registry.should_receive(:load_yardoc).with('gem2/.yardoc')
177
+ it "searches for gem/.yardoc" do
178
+ expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(true)
179
+ expect(File).to receive(:directory?).with('gem2/.yardoc').and_return(true)
180
+ expect(Registry).to receive(:load_yardoc).with('gem1/.yardoc')
181
+ expect(Registry).to receive(:load_yardoc).with('gem2/.yardoc')
182
182
  @diff.run('gem1', 'gem2')
183
183
  end
184
184
 
185
- it "should search for argument as yardoc" do
186
- File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
187
- File.should_receive(:directory?).with('gem2/.yardoc').and_return(false)
188
- File.should_receive(:directory?).with('gem1').and_return(true)
189
- File.should_receive(:directory?).with('gem2').and_return(true)
190
- Registry.should_receive(:load_yardoc).with('gem1')
191
- Registry.should_receive(:load_yardoc).with('gem2')
185
+ it "searches for argument as yardoc" do
186
+ expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(false)
187
+ expect(File).to receive(:directory?).with('gem2/.yardoc').and_return(false)
188
+ expect(File).to receive(:directory?).with('gem1').and_return(true)
189
+ expect(File).to receive(:directory?).with('gem2').and_return(true)
190
+ expect(Registry).to receive(:load_yardoc).with('gem1')
191
+ expect(Registry).to receive(:load_yardoc).with('gem2')
192
192
  @diff.run('gem1', 'gem2')
193
193
  end
194
194
 
195
- it "should search for installed gem" do
196
- File.should_receive(:directory?).with('gem1-1.0.0.gem/.yardoc').and_return(false)
197
- File.should_receive(:directory?).with('gem2-1.0.0/.yardoc').and_return(false)
198
- File.should_receive(:directory?).with('gem1-1.0.0.gem').and_return(false)
199
- File.should_receive(:directory?).with('gem2-1.0.0').and_return(false)
200
- gemmock = mock(:gemmock)
201
- spec1 = mock(:spec)
202
- spec2 = mock(:spec)
203
- gemmock.should_receive(:find_name).at_least(1).times.and_return([spec1, spec2])
204
- Gem.should_receive(:source_index).at_least(1).times.and_return(gemmock)
205
- spec1.stub!(:full_name).and_return('gem1-1.0.0')
206
- spec1.stub!(:name).and_return('gem1')
207
- spec1.stub!(:version).and_return('1.0.0')
208
- spec2.stub!(:full_name).and_return('gem2-1.0.0')
209
- spec2.stub!(:name).and_return('gem2')
210
- spec2.stub!(:version).and_return('1.0.0')
211
- Registry.should_receive(:yardoc_file_for_gem).with('gem1', '= 1.0.0').and_return('/path/to/file')
212
- Registry.should_receive(:yardoc_file_for_gem).with('gem2', '= 1.0.0').and_return(nil)
213
- Registry.should_receive(:load_yardoc).with('/path/to/file')
214
- CLI::Gems.should_receive(:run).with('gem2', '1.0.0').and_return(nil)
215
- Dir.stub!(:chdir)
195
+ it "searches for installed gem" do
196
+ expect(File).to receive(:directory?).with('gem1-1.0.0.gem/.yardoc').and_return(false)
197
+ expect(File).to receive(:directory?).with('gem2-1.0.0/.yardoc').and_return(false)
198
+ expect(File).to receive(:directory?).with('gem1-1.0.0.gem').and_return(false)
199
+ expect(File).to receive(:directory?).with('gem2-1.0.0').and_return(false)
200
+ gemmock = double(:gemmock)
201
+ spec1 = double(:spec)
202
+ spec2 = double(:spec)
203
+ expect(gemmock).to receive(:find_name).at_least(1).times.and_return([spec1, spec2])
204
+ expect(Gem).to receive(:source_index).at_least(1).times.and_return(gemmock)
205
+ allow(spec1).to receive(:full_name).and_return('gem1-1.0.0')
206
+ allow(spec1).to receive(:name).and_return('gem1')
207
+ allow(spec1).to receive(:version).and_return('1.0.0')
208
+ allow(spec2).to receive(:full_name).and_return('gem2-1.0.0')
209
+ allow(spec2).to receive(:name).and_return('gem2')
210
+ allow(spec2).to receive(:version).and_return('1.0.0')
211
+ expect(Registry).to receive(:yardoc_file_for_gem).with('gem1', '= 1.0.0').and_return('/path/to/file')
212
+ expect(Registry).to receive(:yardoc_file_for_gem).with('gem2', '= 1.0.0').and_return(nil)
213
+ expect(Registry).to receive(:load_yardoc).with('/path/to/file')
214
+ expect(CLI::Gems).to receive(:run).with('gem2', '1.0.0').and_return(nil)
215
+ allow(Dir).to receive(:chdir)
216
216
  @diff.run('gem1-1.0.0.gem', 'gem2-1.0.0')
217
217
  end
218
218
 
219
- it "should search for .gem file" do
220
- File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
221
- File.should_receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
222
- File.should_receive(:directory?).with('gem1').and_return(false)
223
- File.should_receive(:directory?).with('gem2.gem').and_return(false)
224
- File.should_receive(:directory?).any_number_of_times
225
- File.should_receive(:exist?).with('gem1.gem').and_return(true)
226
- File.should_receive(:exist?).with('gem2.gem').and_return(true)
227
- File.should_receive(:exist?).any_number_of_times
228
- File.should_receive(:open).with('gem1.gem', 'rb')
229
- File.should_receive(:open).with('gem2.gem', 'rb')
230
- FileUtils.stub(:mkdir_p)
231
- Gem::Package.stub(:open)
232
- FileUtils.stub(:rm_rf)
219
+ it "searches for .gem file" do
220
+ expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(false)
221
+ expect(File).to receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
222
+ expect(File).to receive(:directory?).with('gem1').and_return(false)
223
+ expect(File).to receive(:directory?).with('gem2.gem').and_return(false)
224
+ expect(File).to receive(:exist?).with('gem1.gem').and_return(true)
225
+ expect(File).to receive(:exist?).with('gem2.gem').and_return(true)
226
+ expect(File).to receive(:open).with('gem1.gem', 'rb')
227
+ expect(File).to receive(:open).with('gem2.gem', 'rb')
228
+ allow(FileUtils).to receive(:mkdir_p)
229
+ allow(Gem::Package).to receive(:open)
230
+ allow(FileUtils).to receive(:rm_rf)
233
231
  @diff.run('gem1', 'gem2.gem')
234
232
  end
235
233
 
236
- it "should search for .gem file on rubygems.org" do
237
- File.should_receive(:directory?).with('gem1/.yardoc').and_return(false)
238
- File.should_receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
239
- File.should_receive(:directory?).with('gem1').and_return(false)
240
- File.should_receive(:directory?).with('gem2.gem').and_return(false)
241
- File.should_receive(:directory?).any_number_of_times
242
- File.should_receive(:exist?).with('gem1.gem').and_return(false)
243
- File.should_receive(:exist?).with('gem2.gem').and_return(false)
244
- File.should_receive(:exist?).any_number_of_times
245
- @diff.should_receive(:open).with('http://rubygems.org/downloads/gem1.gem')
246
- @diff.should_receive(:open).with('http://rubygems.org/downloads/gem2.gem')
247
- FileUtils.stub(:mkdir_p)
248
- Gem::Package.stub(:open)
249
- FileUtils.stub(:rm_rf)
234
+ it "searches for .gem file on rubygems.org" do
235
+ expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(false)
236
+ expect(File).to receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
237
+ expect(File).to receive(:directory?).with('gem1').and_return(false)
238
+ expect(File).to receive(:directory?).with('gem2.gem').and_return(false)
239
+ expect(File).to receive(:exist?).with('gem1.gem').and_return(false)
240
+ expect(File).to receive(:exist?).with('gem2.gem').and_return(false)
241
+ expect(@diff).to receive(:open).with('http://rubygems.org/downloads/gem1.gem')
242
+ expect(@diff).to receive(:open).with('http://rubygems.org/downloads/gem2.gem')
243
+ allow(FileUtils).to receive(:mkdir_p)
244
+ allow(Gem::Package).to receive(:open)
245
+ allow(FileUtils).to receive(:rm_rf)
250
246
  @diff.run('gem1', 'gem2.gem')
251
247
  end
252
248
 
253
- it "should error if gem is not found" do
254
- log.should_receive(:error).with("Cannot find gem gem1")
255
- log.should_receive(:error).with("Cannot find gem gem2.gem")
256
- @diff.stub!(:load_gem_data).and_return(false)
249
+ it "raises an error if gem is not found" do
250
+ expect(log).to receive(:error).with("Cannot find gem gem1")
251
+ expect(log).to receive(:error).with("Cannot find gem gem2.gem")
252
+ allow(@diff).to receive(:load_gem_data).and_return(false)
257
253
  @diff.run('gem1', 'gem2.gem')
258
254
  end
259
255
  end
@@ -2,29 +2,29 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe YARD::CLI::Display do
4
4
  before do
5
- Registry.stub(:load)
5
+ allow(Registry).to receive(:load)
6
6
  @object = CodeObjects::ClassObject.new(:root, :Foo)
7
7
  @object.docstring = 'Foo bar'
8
8
  end
9
9
 
10
10
  it "displays an object" do
11
11
  YARD::CLI::Display.run('-f', 'text', 'Foo')
12
- log.io.string.strip.should eq(@object.format.strip)
12
+ expect(log.io.string.strip).to eq(@object.format.strip)
13
13
  end
14
14
 
15
15
  it "wraps output with -l (defaulting to layout)" do
16
16
  YARD::CLI::Display.run('-l', '-f', 'html', 'Foo')
17
17
  formatted_output = @object.format(:format => :html).strip
18
18
  actual_output = log.io.string.strip
19
- actual_output.should_not eq(formatted_output)
20
- actual_output.should include(formatted_output)
19
+ expect(actual_output).not_to eq(formatted_output)
20
+ expect(actual_output).to include(formatted_output)
21
21
  end
22
22
 
23
23
  it "wraps output with --layout onefile" do
24
24
  YARD::CLI::Display.run('--layout', 'onefile', '-f', 'html', 'Foo')
25
25
  formatted_output = @object.format(:format => :html).strip
26
26
  actual_output = log.io.string.strip
27
- actual_output.should_not eq(formatted_output)
28
- actual_output.should include(formatted_output)
27
+ expect(actual_output).not_to eq(formatted_output)
28
+ expect(actual_output).to include(formatted_output)
29
29
  end
30
30
  end
@@ -19,62 +19,62 @@ describe YARD::CLI::Gems do
19
19
 
20
20
  def build_specs(*specs)
21
21
  specs.each do |themock|
22
- Registry.should_receive(:yardoc_file_for_gem).with(themock.name, "= #{themock.version}").and_return(themock.yardoc_file)
23
- File.should_receive(:directory?).with(themock.yardoc_file).and_return(@rebuild)
24
- File.should_receive(:directory?).with(themock.full_gem_path).and_return(true)
25
- Registry.should_receive(:yardoc_file_for_gem).with(themock.name, "= #{themock.version}", true).and_return(themock.yardoc_file)
26
- Dir.should_receive(:chdir).with(themock.full_gem_path)
22
+ expect(Registry).to receive(:yardoc_file_for_gem).with(themock.name, "= #{themock.version}").and_return(themock.yardoc_file)
23
+ expect(File).to receive(:directory?).with(themock.yardoc_file).and_return(@rebuild)
24
+ expect(File).to receive(:directory?).with(themock.full_gem_path).and_return(true)
25
+ expect(Registry).to receive(:yardoc_file_for_gem).with(themock.name, "= #{themock.version}", true).and_return(themock.yardoc_file)
26
+ expect(Dir).to receive(:chdir).with(themock.full_gem_path)
27
27
  end
28
- Registry.should_receive(:clear).exactly(specs.size).times
29
- CLI::Yardoc.should_receive(:run).exactly(specs.size).times
28
+ expect(Registry).to receive(:clear).exactly(specs.size).times
29
+ expect(CLI::Yardoc).to receive(:run).exactly(specs.size).times
30
30
  end
31
31
 
32
- describe '#run' do
33
- it "should build all gem indexes if no gem is specified" do
32
+ describe "#run" do
33
+ it "builds all gem indexes if no gem is specified" do
34
34
  build_specs(@gem1, @gem2)
35
- Gem.source_index.should_receive(:find_name).with('').and_return([@gem1, @gem2])
35
+ expect(Gem.source_index).to receive(:find_name).with('').and_return([@gem1, @gem2])
36
36
  CLI::Gems.run
37
37
  end
38
38
 
39
- it "should allow gem to be specified" do
39
+ it "allows gem to be specified" do
40
40
  build_specs(@gem1)
41
- Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 0').and_return([@gem1])
41
+ expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 0').and_return([@gem1])
42
42
  CLI::Gems.run(@gem1.name)
43
43
  end
44
44
 
45
- it "should allow multiple gems to be specified for building" do
45
+ it "allows multiple gems to be specified for building" do
46
46
  build_specs(@gem1, @gem2)
47
- Gem.source_index.should_receive(:find_name).with(@gem1.name, @gem1.version).and_return([@gem1])
48
- Gem.source_index.should_receive(:find_name).with(@gem2.name, '>= 0').and_return([@gem2])
47
+ expect(Gem.source_index).to receive(:find_name).with(@gem1.name, @gem1.version).and_return([@gem1])
48
+ expect(Gem.source_index).to receive(:find_name).with(@gem2.name, '>= 0').and_return([@gem2])
49
49
  CLI::Gems.run(@gem1.name, @gem1.version, @gem2.name)
50
50
  end
51
51
 
52
- it "should allow version to be specified with gem" do
52
+ it "allows version to be specified with gem" do
53
53
  build_specs(@gem1)
54
- Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 1.0').and_return([@gem1])
54
+ expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 1.0').and_return([@gem1])
55
55
  CLI::Gems.run(@gem1.name, '>= 1.0')
56
56
  end
57
57
 
58
- it "should warn if one of the gems is not found, but it should process others" do
58
+ it "warns if one of the gems is not found, but it should process others" do
59
59
  build_specs(@gem2)
60
- Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
61
- Gem.source_index.should_receive(:find_name).with(@gem2.name, '>= 0').and_return([@gem2])
62
- log.should_receive(:warn).with(/#{@gem1.name} >= 2.0 could not be found/)
60
+ expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
61
+ expect(Gem.source_index).to receive(:find_name).with(@gem2.name, '>= 0').and_return([@gem2])
62
+ expect(log).to receive(:warn).with(/#{@gem1.name} >= 2.0 could not be found/)
63
63
  CLI::Gems.run(@gem1.name, '>= 2.0', @gem2.name)
64
64
  end
65
65
 
66
- it "should fail if specified gem(s) is/are not found" do
67
- CLI::Yardoc.should_not_receive(:run)
68
- Gem.source_index.should_receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
69
- log.should_receive(:warn).with(/#{@gem1.name} >= 2.0 could not be found/)
70
- log.should_receive(:error).with(/No specified gems could be found/)
66
+ it "fails if specified gem(s) is/are not found" do
67
+ expect(CLI::Yardoc).not_to receive(:run)
68
+ expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
69
+ expect(log).to receive(:warn).with(/#{@gem1.name} >= 2.0 could not be found/)
70
+ expect(log).to receive(:error).with(/No specified gems could be found/)
71
71
  CLI::Gems.run(@gem1.name, '>= 2.0')
72
72
  end
73
73
 
74
- it "should accept --rebuild" do
74
+ it "accepts --rebuild" do
75
75
  @rebuild = true
76
76
  build_specs(@gem1)
77
- Gem.source_index.should_receive(:find_name).with('').and_return([@gem1])
77
+ expect(Gem.source_index).to receive(:find_name).with('').and_return([@gem1])
78
78
  CLI::Gems.run('--rebuild')
79
79
  end
80
80
  end