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
@@ -5,7 +5,7 @@ describe YARD::Templates::Helpers::TextHelper do
5
5
  include YARD::Templates::Helpers::TextHelper
6
6
  include YARD::Templates::Helpers::MethodHelper
7
7
 
8
- describe '#signature' do
8
+ describe "#signature" do
9
9
  before do
10
10
  @results = {
11
11
  :regular => "root.foo -> Object",
@@ -30,15 +30,15 @@ describe YARD::Templates::Helpers::TextHelper do
30
30
  it_should_behave_like "signature"
31
31
  end
32
32
 
33
- describe '#align_right' do
34
- it "should align text right" do
33
+ describe "#align_right" do
34
+ it "aligns text right" do
35
35
  text = "Method: #some_method (SomeClass)"
36
- align_right(text).should == ' ' * 40 + text
36
+ expect(align_right(text)).to eq ' ' * 40 + text
37
37
  end
38
38
 
39
- it "should truncate text that is longer than allowed width" do
39
+ it "truncates text that is longer than allowed width" do
40
40
  text = "(Defined in: /home/user/.rip/.packages/some_gem-2460672e333ac07b9190ade88ec9a91c/long/path.rb)"
41
- align_right(text).should == ' ' + text[0,68] + '...'
41
+ expect(align_right(text)).to eq ' ' + text[0,68] + '...'
42
42
  end
43
43
  end
44
44
  end
@@ -7,16 +7,16 @@ describe YARD::Templates::Engine.template(:default, :method) do
7
7
  before { Registry.clear }
8
8
 
9
9
  shared_examples_for "all formats" do
10
- it "should render html format correctly" do
10
+ it "renders html format correctly" do
11
11
  html_equals(Registry.at('#m').format(html_options), @template)
12
12
  end
13
13
 
14
- it "should render text format correctly" do
14
+ it "renders text format correctly" do
15
15
  text_equals(Registry.at('#m').format(text_options), @template)
16
16
  end
17
17
  end
18
18
 
19
- describe 'regular (deprecated) method' do
19
+ describe "regular (deprecated) method" do
20
20
  before do
21
21
  @template = :method001
22
22
  YARD.parse_string <<-'eof'
@@ -36,7 +36,7 @@ describe YARD::Templates::Engine.template(:default, :method) do
36
36
  it_should_behave_like "all formats"
37
37
  end
38
38
 
39
- describe 'method with 1 overload' do
39
+ describe "method with 1 overload" do
40
40
  before do
41
41
  @template = :method002
42
42
  YARD.parse_string <<-'eof'
@@ -52,7 +52,7 @@ describe YARD::Templates::Engine.template(:default, :method) do
52
52
  it_should_behave_like "all formats"
53
53
  end
54
54
 
55
- describe 'method with 2 overloads' do
55
+ describe "method with 2 overloads" do
56
56
  before do
57
57
  @template = :method003
58
58
  YARD.parse_string <<-'eof'
@@ -73,7 +73,7 @@ describe YARD::Templates::Engine.template(:default, :method) do
73
73
  it_should_behave_like "all formats"
74
74
  end
75
75
 
76
- describe 'method void return' do
76
+ describe "method void return" do
77
77
  before do
78
78
  @template = :method004
79
79
  YARD.parse_string <<-'eof'
@@ -85,7 +85,7 @@ describe YARD::Templates::Engine.template(:default, :method) do
85
85
  it_should_behave_like "all formats"
86
86
  end
87
87
 
88
- describe 'method void return in an overload' do
88
+ describe "method void return in an overload" do
89
89
  before do
90
90
  @template = :method005
91
91
  YARD.parse_string <<-'eof'
@@ -65,13 +65,13 @@ describe YARD::Templates::Engine.template(:default, :module) do
65
65
  eof
66
66
  end
67
67
 
68
- it "should render html format correctly" do
68
+ it "renders html format correctly" do
69
69
  html_equals(Registry.at('A').format(html_options(:hide_void_return => true,
70
70
  :verifier => Verifier.new('object.type != :method || object.visibility == :public'))),
71
71
  :module001)
72
72
  end
73
73
 
74
- it "should render text format correctly" do
74
+ it "renders text format correctly" do
75
75
  YARD.parse_string <<-'eof'
76
76
  module A
77
77
  include D, E, F, A::B::C
@@ -81,11 +81,11 @@ describe YARD::Templates::Engine.template(:default, :module) do
81
81
  text_equals(Registry.at('A').format(text_options), :module001)
82
82
  end
83
83
 
84
- it "should render dot format correctly" do
85
- Registry.at('A').format(:format => :dot, :dependencies => true, :full => true).should == example_contents(:module001, 'dot')
84
+ it "renders dot format correctly" do
85
+ expect(Registry.at('A').format(:format => :dot, :dependencies => true, :full => true)).to eq example_contents(:module001, 'dot')
86
86
  end
87
87
 
88
- it "should render groups correctly in html" do
88
+ it "renders groups correctly in html" do
89
89
  Registry.clear
90
90
  YARD.parse_string <<-'eof'
91
91
  module A
@@ -106,7 +106,7 @@ describe YARD::Templates::Engine.template(:default, :module) do
106
106
  html_equals(Registry.at('A').format(html_options), :module002)
107
107
  end
108
108
 
109
- it "should ignore overwritten/private attributes/constants from inherited list" do
109
+ it "ignores overwritten/private attributes/constants from inherited list" do
110
110
  Registry.clear
111
111
  YARD.parse_string <<-'eof'
112
112
  module B
@@ -128,7 +128,7 @@ describe YARD::Templates::Engine.template(:default, :module) do
128
128
  :verifier => Verifier.new('!@private'))), :module003)
129
129
  end
130
130
 
131
- it "should embed mixins with :embed_mixins = ['Foo', 'Bar', 'Baz::A*']" do
131
+ it "embeds mixins with :embed_mixins = ['Foo', 'Bar', 'Baz::A*']" do
132
132
  Registry.clear
133
133
  YARD.parse_string <<-'eof'
134
134
  class A
@@ -52,13 +52,13 @@ describe YARD::Templates::Engine.template(:default, :onefile) do
52
52
  ]
53
53
  end
54
54
 
55
- it "should render html" do
55
+ it "renders html" do
56
56
  render
57
- @files.should == ['index.html']
58
- @output.should include("This is a code comment")
59
- @output.should include("This is a license!")
60
- @output.should include("Class: A")
61
- @output.should include("Foo method")
62
- @output.should include("Bar method")
57
+ expect(@files).to eq ['index.html']
58
+ expect(@output).to include("This is a code comment")
59
+ expect(@output).to include("This is a license!")
60
+ expect(@output).to include("Class: A")
61
+ expect(@output).to include("Foo method")
62
+ expect(@output).to include("Bar method")
63
63
  end
64
64
  end
@@ -3,144 +3,141 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe YARD::Templates::Section do
4
4
  include YARD::Templates
5
5
 
6
- describe '#initialize' do
7
- it "should convert first argument to splat if it is array" do
6
+ describe "#initialize" do
7
+ it "converts first argument to splat if it is array" do
8
8
  s = Section.new(:name, [:foo, :bar])
9
- s.name.should == :name
10
- s[0].name.should == :foo
11
- s[1].name.should == :bar
9
+ expect(s.name).to eq :name
10
+ expect(s[0].name).to eq :foo
11
+ expect(s[1].name).to eq :bar
12
12
  end
13
13
 
14
- it "should allow initialization with Section objects" do
14
+ it "allows initialization with Section objects" do
15
15
  s = Section.new(:name, [:foo, Section.new(:bar)])
16
- s.name.should == :name
17
- s[0].should == Section.new(:foo)
18
- s[1].should == Section.new(:bar)
16
+ expect(s.name).to eq :name
17
+ expect(s[0]).to eq Section.new(:foo)
18
+ expect(s[1]).to eq Section.new(:bar)
19
19
  end
20
20
 
21
- it "should make a list of sections" do
21
+ it "makes a list of sections" do
22
22
  s = Section.new(:name, [:foo, [:bar]])
23
- s.should == Section.new(:name, Section.new(:foo, Section.new(:bar)))
23
+ expect(s).to eq Section.new(:name, Section.new(:foo, Section.new(:bar)))
24
24
  end
25
25
  end
26
26
 
27
- describe '#[]' do
28
- it "should use Array#[] if argument is integer" do
29
- Section.new(:name, [:foo, :bar])[0].name.should == :foo
27
+ describe "#[]" do
28
+ it "uses Array#[] if argument is integer" do
29
+ expect(Section.new(:name, [:foo, :bar])[0].name).to eq :foo
30
30
  end
31
31
 
32
- it "should return new Section object if more than one argument" do
33
- Section.new(:name, :foo, :bar, :baz)[1, 2].should ==
34
- Section.new(:name, :bar, :baz)
32
+ it "returns new Section object if more than one argument" do
33
+ expect(Section.new(:name, :foo, :bar, :baz)[1, 2]).to eq Section.new(:name, :bar, :baz)
35
34
  end
36
35
 
37
- it "should return new Section object if arg is Range" do
38
- Section.new(:name, :foo, :bar, :baz)[1..2].should ==
39
- Section.new(:name, :bar, :baz)
36
+ it "returns new Section object if arg is Range" do
37
+ expect(Section.new(:name, :foo, :bar, :baz)[1..2]).to eq Section.new(:name, :bar, :baz)
40
38
  end
41
39
 
42
- it "should look for section by name if arg is object" do
43
- Section.new(:name, :foo, :bar, [:baz])[:bar][:baz].should ==
44
- Section.new(:baz)
40
+ it "looks for section by name if arg is object" do
41
+ expect(Section.new(:name, :foo, :bar, [:baz])[:bar][:baz]).to eq Section.new(:baz)
45
42
  end
46
43
  end
47
44
 
48
- describe '#eql?' do
49
- it "should check for equality of two equal sections" do
50
- Section.new(:foo, [:a, :b]).should be_eql(Section.new(:foo, :a, :b))
51
- Section.new(:foo, [:a, :b]).should == Section.new(:foo, :a, :b)
45
+ describe "#eql?" do
46
+ it "checks for equality of two equal sections" do
47
+ expect(Section.new(:foo, [:a, :b])).to eql(Section.new(:foo, :a, :b))
48
+ expect(Section.new(:foo, [:a, :b])).to eq Section.new(:foo, :a, :b)
52
49
  end
53
50
 
54
- it "should not be equal if section names are different" do
55
- Section.new(:foo, [:a, :b]).should_not be_eql(Section.new(:bar, :a, :b))
56
- Section.new(:foo, [:a, :b]).should_not == Section.new(:bar, :a, :b)
51
+ it "is not equal if section names are different" do
52
+ expect(Section.new(:foo, [:a, :b])).not_to eql(Section.new(:bar, :a, :b))
53
+ expect(Section.new(:foo, [:a, :b])).not_to eq Section.new(:bar, :a, :b)
57
54
  end
58
55
  end
59
56
 
60
- describe '#==' do
61
- it "should allow comparison to Symbol" do
62
- Section.new(:foo, 2, 3).should == :foo
57
+ describe "#==" do
58
+ it "allows comparison to Symbol" do
59
+ expect(Section.new(:foo, 2, 3)).to eq :foo
63
60
  end
64
61
 
65
- it "should allow comparison to String" do
66
- Section.new("foo", 2, 3).should == "foo"
62
+ it "allows comparison to String" do
63
+ expect(Section.new("foo", 2, 3)).to eq "foo"
67
64
  end
68
65
 
69
- it "should allow comparison to Template" do
66
+ it "allows comparison to Template" do
70
67
  t = YARD::Templates::Engine.template!(:xyzzy, '/full/path/xyzzy')
71
- Section.new(t, 2, 3).should == t
68
+ expect(Section.new(t, 2, 3)).to eq t
72
69
  end
73
70
 
74
- it "should allow comparison to Section" do
75
- Section.new(1, [2, 3]).should == Section.new(1, 2, 3)
71
+ it "allows comparison to Section" do
72
+ expect(Section.new(1, [2, 3])).to eq Section.new(1, 2, 3)
76
73
  end
77
74
 
78
- it "should allow comparison to Object" do
79
- Section.new(1, [2, 3]).should == 1
75
+ it "allows comparison to Object" do
76
+ expect(Section.new(1, [2, 3])).to eq 1
80
77
  end
81
78
 
82
- it "should allow comparison to Array" do
83
- Section.new(1, 2, [3]).should == [1, [2, [3]]]
79
+ it "allows comparison to Array" do
80
+ expect(Section.new(1, 2, [3])).to eq [1, [2, [3]]]
84
81
  end
85
82
  end
86
83
 
87
- describe '#to_a' do
88
- it "should convert Section to regular Array list" do
84
+ describe "#to_a" do
85
+ it "converts Section to regular Array list" do
89
86
  arr = Section.new(1, 2, [3, [4]]).to_a
90
- arr.class.should == Array
91
- arr.should == [1, [2, [3, [4]]]]
87
+ expect(arr.class).to eq Array
88
+ expect(arr).to eq [1, [2, [3, [4]]]]
92
89
  end
93
90
  end
94
91
 
95
- describe '#place' do
96
- it "should place objects as Sections" do
97
- Section.new(1, 2, 3).place(4).before(3).should == [1, [2, 4, 3]]
92
+ describe "#place" do
93
+ it "places objects as Sections" do
94
+ expect(Section.new(1, 2, 3).place(4).before(3)).to eq [1, [2, 4, 3]]
98
95
  end
99
96
 
100
- it "should place objects anywhere inside Section with before/after_any" do
101
- Section.new(1, 2, [3, [4]]).place(5).after_any(4).should == [1, [2, [3, [4, 5]]]]
102
- Section.new(1, 2, [3, [4]]).place(5).before_any(4).should == [1, [2, [3, [5, 4]]]]
97
+ it "places objects anywhere inside Section with before/after_any" do
98
+ expect(Section.new(1, 2, [3, [4]]).place(5).after_any(4)).to eq [1, [2, [3, [4, 5]]]]
99
+ expect(Section.new(1, 2, [3, [4]]).place(5).before_any(4)).to eq [1, [2, [3, [5, 4]]]]
103
100
  end
104
101
 
105
- it "should allow multiple sections to be placed" do
106
- Section.new(1, 2, 3).place(4, 5).after(3).to_a.should == [1, [2, 3, 4, 5]]
107
- Section.new(1, 2, 3).place(4, [5]).after(3).to_a.should == [1, [2, 3, 4, [5]]]
102
+ it "allows multiple sections to be placed" do
103
+ expect(Section.new(1, 2, 3).place(4, 5).after(3).to_a).to eq [1, [2, 3, 4, 5]]
104
+ expect(Section.new(1, 2, 3).place(4, [5]).after(3).to_a).to eq [1, [2, 3, 4, [5]]]
108
105
  end
109
106
  end
110
107
 
111
- describe '#push' do
112
- it "should push objects as Sections" do
108
+ describe "#push" do
109
+ it "pushes objects as Sections" do
113
110
  s = Section.new(:foo)
114
111
  s.push :bar
115
- s[0].should == Section.new(:bar)
112
+ expect(s[0]).to eq Section.new(:bar)
116
113
  end
117
114
 
118
- it "should alias to #<<" do
115
+ it "is aliased as #<<" do
119
116
  s = Section.new(1)
120
117
  s << :index
121
- s[:index].should be_a(Section)
118
+ expect(s[:index]).to be_a(Section)
122
119
  end
123
120
  end
124
121
 
125
- describe '#unshift' do
126
- it "should unshift objects as Sections" do
122
+ describe "#unshift" do
123
+ it "unshifts objects as Sections" do
127
124
  s = Section.new(:foo)
128
125
  s.unshift :bar
129
- s[0].should == Section.new(:bar)
126
+ expect(s[0]).to eq Section.new(:bar)
130
127
  end
131
128
  end
132
129
 
133
- describe '#any' do
134
- it "should find item inside sections" do
130
+ describe "#any" do
131
+ it "finds item inside sections" do
135
132
  s = Section.new(:foo, Section.new(:bar, Section.new(:bar)))
136
133
  s.any(:bar).push(:baz)
137
- s.to_a.should == [:foo, [:bar, [:bar, :baz]]]
134
+ expect(s.to_a).to eq [:foo, [:bar, [:bar, :baz]]]
138
135
  end
139
136
 
140
- it "should find item in any deeply nested set of sections" do
137
+ it "finds item in any deeply nested set of sections" do
141
138
  s = Section.new(:foo, Section.new(:bar, Section.new(:baz)))
142
139
  s.any(:baz).push(:qux)
143
- s.to_a.should == [:foo, [:bar, [:baz, [:qux]]]]
140
+ expect(s.to_a).to eq [:foo, [:bar, [:baz, [:qux]]]]
144
141
  end
145
142
  end
146
143
  end
@@ -15,7 +15,7 @@ def text_equals(result, expected_example)
15
15
  end
16
16
 
17
17
  def text_equals_string(result, expected)
18
- result.should == expected
18
+ expect(result).to eq expected
19
19
  end
20
20
 
21
21
  def html_equals(result, expected_example)
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe YARD::Templates::Engine.template(:default, :tags) do
4
4
  before { Registry.clear }
5
5
 
6
- describe 'all known tags' do
6
+ describe "all known tags" do
7
7
  before do
8
8
  YARD.parse_string <<-'eof'
9
9
  # Comments
@@ -32,20 +32,20 @@ describe YARD::Templates::Engine.template(:default, :tags) do
32
32
  eof
33
33
  end
34
34
 
35
- it "should render text format correctly" do
35
+ it "renders text format correctly" do
36
36
  text_equals(Registry.at('#m').format(text_options), :tag001)
37
37
  end
38
38
  end
39
39
 
40
- describe 'param tags on non-methods' do
41
- it 'should not display @param tags on non-method objects' do
40
+ describe "param tags on non-methods" do
41
+ it "does not display @param tags on non-method objects" do
42
42
  YARD.parse_string <<-'eof'
43
43
  # @param [#to_s] name the name
44
44
  module Foo; end
45
45
  eof
46
46
 
47
47
  proc = lambda { Registry.at('Foo').format(html_options) }
48
- proc.should_not raise_error(NoMethodError)
48
+ expect(proc).not_to raise_error
49
49
  end
50
50
  end
51
51
  end
@@ -9,282 +9,282 @@ describe YARD::Templates::Template do
9
9
  YARD::Templates::ErbCache.clear!
10
10
  end
11
11
 
12
- describe '.include_parent' do
13
- it "should not include parent directory if parent directory is a template root path" do
12
+ describe ".include_parent" do
13
+ it "does not include parent directory if parent directory is a template root path" do
14
14
  mod = template('q')
15
- mod.should_not include(template(''))
15
+ expect(mod).not_to include(template(''))
16
16
  end
17
17
 
18
- it "should include overridden parent directory" do
19
- Engine.stub!(:template_paths).and_return(['/foo', '/bar'])
20
- File.should_receive(:directory?).with('/foo/a/b').and_return(true)
21
- File.should_receive(:directory?).with('/bar/a/b').and_return(false)
22
- File.should_receive(:directory?).with('/foo/a').at_least(1).times.and_return(true)
23
- File.should_receive(:directory?).with('/bar/a').at_least(1).times.and_return(true)
18
+ it "includes overridden parent directory" do
19
+ allow(Engine).to receive(:template_paths).and_return(['/foo', '/bar'])
20
+ expect(File).to receive(:directory?).with('/foo/a/b').and_return(true)
21
+ expect(File).to receive(:directory?).with('/bar/a/b').and_return(false)
22
+ expect(File).to receive(:directory?).with('/foo/a').at_least(1).times.and_return(true)
23
+ expect(File).to receive(:directory?).with('/bar/a').at_least(1).times.and_return(true)
24
24
  ancestors = Engine.template('a/b').ancestors.map {|c| c.class_name }
25
- ancestors[0, 3].should == %w( Template__foo_a_b Template__bar_a Template__foo_a )
25
+ expect(ancestors[0, 3]).to eq %w( Template__foo_a_b Template__bar_a Template__foo_a )
26
26
  end
27
27
 
28
- it "should include parent directory template if exists" do
28
+ it "includes parent directory template if exists" do
29
29
  mod1 = template('x')
30
30
  mod2 = template('x/y')
31
- mod2.should include(mod1)
31
+ expect(mod2).to include(mod1)
32
32
  end
33
33
  end
34
34
 
35
- describe '.full_paths' do
36
- it "should list full_path" do
35
+ describe ".full_paths" do
36
+ it "lists full_path" do
37
37
  mod = template(:a)
38
- mod.full_paths.should == ['/full/path/a']
38
+ expect(mod.full_paths).to eq ['/full/path/a']
39
39
  end
40
40
 
41
- it "should list paths of included modules" do
41
+ it "lists paths of included modules" do
42
42
  mod = template(:a)
43
43
  mod.send(:include, template(:b))
44
- mod.full_paths.should == ['/full/path/a', '/full/path/b']
44
+ expect(mod.full_paths).to eq ['/full/path/a', '/full/path/b']
45
45
  end
46
46
 
47
- it "should list paths from modules of included modules" do
47
+ it "lists paths from modules of included modules" do
48
48
  mod = template(:c)
49
49
  mod.send(:include, template(:d))
50
50
  mod.send(:include, template(:a))
51
- mod.full_paths.should == ['c', 'a', 'b', 'd'].map {|o| '/full/path/' + o }
51
+ expect(mod.full_paths).to eq ['c', 'a', 'b', 'd'].map {|o| '/full/path/' + o }
52
52
  end
53
53
 
54
- it "should only list full paths of modules that respond to full_paths" do
54
+ it "only lists full paths of modules that respond to full_paths" do
55
55
  mod = template(:d)
56
56
  mod.send(:include, Enumerable)
57
- mod.full_paths.should == ['/full/path/d']
57
+ expect(mod.full_paths).to eq ['/full/path/d']
58
58
  end
59
59
  end
60
60
 
61
- describe '.load_setup_rb' do
62
- it "should load setup.rb file for module" do
63
- File.should_receive(:file?).with('/full/path/e/setup.rb').and_return(true)
64
- File.should_receive(:read).with('/full/path/e/setup.rb').and_return('def success; end')
65
- template(:e).new.should respond_to(:success)
61
+ describe ".load_setup_rb" do
62
+ it "loads setup.rb file for module" do
63
+ expect(File).to receive(:file?).with('/full/path/e/setup.rb').and_return(true)
64
+ expect(File).to receive(:read).with('/full/path/e/setup.rb').and_return('def success; end')
65
+ expect(template(:e).new).to respond_to(:success)
66
66
  end
67
67
  end
68
68
 
69
- describe '.T' do
70
- it "should load template from absolute path" do
69
+ describe ".T" do
70
+ it "loads template from absolute path" do
71
71
  mod = template(:a)
72
- Engine.should_receive(:template).with('other')
72
+ expect(Engine).to receive(:template).with('other')
73
73
  mod.T('other')
74
74
  end
75
75
  end
76
76
 
77
- describe '.find_file' do
78
- it "should find file in module's full_path" do
79
- File.should_receive(:file?).with('/full/path/a/basename').and_return(false)
80
- File.should_receive(:file?).with('/full/path/b/basename').and_return(true)
81
- template(:a).find_file('basename').should == '/full/path/b/basename'
77
+ describe ".find_file" do
78
+ it "finds file in the module's full_path" do
79
+ expect(File).to receive(:file?).with('/full/path/a/basename').and_return(false)
80
+ expect(File).to receive(:file?).with('/full/path/b/basename').and_return(true)
81
+ expect(template(:a).find_file('basename')).to eq '/full/path/b/basename'
82
82
  end
83
83
 
84
- it "should return nil if no file is found" do
85
- File.should_receive(:file?).with('/full/path/a/basename').and_return(false)
86
- File.should_receive(:file?).with('/full/path/b/basename').and_return(false)
87
- template(:a).find_file('basename').should be_nil
84
+ it "returns nil if no file is found" do
85
+ expect(File).to receive(:file?).with('/full/path/a/basename').and_return(false)
86
+ expect(File).to receive(:file?).with('/full/path/b/basename').and_return(false)
87
+ expect(template(:a).find_file('basename')).to be nil
88
88
  end
89
89
  end
90
90
 
91
- describe '.find_nth_file' do
92
- it "should find 2nd existing file in template paths" do
93
- File.should_receive(:file?).with('/full/path/a/basename').and_return(true)
94
- File.should_receive(:file?).with('/full/path/b/basename').and_return(true)
95
- template(:a).find_nth_file('basename', 2).should == '/full/path/b/basename'
91
+ describe ".find_nth_file" do
92
+ it "finds 2nd existing file in template paths" do
93
+ expect(File).to receive(:file?).with('/full/path/a/basename').and_return(true)
94
+ expect(File).to receive(:file?).with('/full/path/b/basename').and_return(true)
95
+ expect(template(:a).find_nth_file('basename', 2)).to eq '/full/path/b/basename'
96
96
  end
97
97
 
98
- it "should return nil if no file is found" do
99
- File.should_receive(:file?).with('/full/path/a/basename').and_return(true)
100
- File.should_receive(:file?).with('/full/path/b/basename').and_return(true)
101
- template(:a).find_nth_file('basename', 3).should be_nil
98
+ it "returns nil if no file is found" do
99
+ expect(File).to receive(:file?).with('/full/path/a/basename').and_return(true)
100
+ expect(File).to receive(:file?).with('/full/path/b/basename').and_return(true)
101
+ expect(template(:a).find_nth_file('basename', 3)).to be nil
102
102
  end
103
103
  end
104
104
 
105
- describe '.extra_includes' do
106
- it "should be included when a module is initialized" do
105
+ describe ".extra_includes" do
106
+ it "is included when a module is initialized" do
107
107
  module MyModule; end
108
108
  Template.extra_includes << MyModule
109
- template(:e).new.should be_kind_of(MyModule)
109
+ expect(template(:e).new).to be_kind_of(MyModule)
110
110
  end
111
111
 
112
- it "should support lambdas in list" do
112
+ it "supports lambdas in list" do
113
113
  module MyModule2; end
114
114
  Template.extra_includes << lambda {|opts| MyModule2 if opts.format == :html }
115
- template(:f).new(:format => :html).should be_kind_of(MyModule2)
115
+ expect(template(:f).new(:format => :html)).to be_kind_of(MyModule2)
116
116
  metaclass = (class << template(:g).new(:format => :text); self end)
117
- metaclass.ancestors.should_not include(MyModule2)
117
+ expect(metaclass.ancestors).not_to include(MyModule2)
118
118
  end
119
119
  end
120
120
 
121
- describe '.is_a?' do
122
- it "should be kind of Template" do
123
- template(:e).is_a?(Template).should == true
121
+ describe ".is_a?" do
122
+ it "is kind of Template" do
123
+ expect(template(:e).is_a?(Template)).to be true
124
124
  end
125
125
  end
126
126
 
127
- describe '#T' do
128
- it "should delegate to class method" do
129
- template(:e).should_receive(:T).with('test')
127
+ describe "#T" do
128
+ it "delegates to class method" do
129
+ expect(template(:e)).to receive(:T).with('test')
130
130
  template(:e).new.T('test')
131
131
  end
132
132
  end
133
133
 
134
- describe '#init' do
135
- it "should be called during initialization" do
134
+ describe "#init" do
135
+ it "is called during initialization" do
136
136
  module YARD::Templates::Engine::Template__full_path_e
137
137
  def init; sections 1, 2, 3 end
138
138
  end
139
- template(:e).new.sections.should == Section.new(nil, 1, 2, 3)
139
+ expect(template(:e).new.sections).to eq Section.new(nil, 1, 2, 3)
140
140
  end
141
141
  end
142
142
 
143
- describe '#file' do
144
- it "should read the file if it exists" do
145
- File.should_receive(:file?).with('/full/path/e/abc').and_return(true)
146
- IO.should_receive(:read).with('/full/path/e/abc').and_return('hello world')
147
- template(:e).new.file('abc').should == 'hello world'
143
+ describe "#file" do
144
+ it "reads the file if it exists" do
145
+ expect(File).to receive(:file?).with('/full/path/e/abc').and_return(true)
146
+ expect(IO).to receive(:read).with('/full/path/e/abc').and_return('hello world')
147
+ expect(template(:e).new.file('abc')).to eq 'hello world'
148
148
  end
149
149
 
150
- it "should raise ArgumentError if the file does not exist" do
151
- File.should_receive(:file?).with('/full/path/e/abc').and_return(false)
152
- lambda { template(:e).new.file('abc') }.should raise_error(ArgumentError)
150
+ it "raises ArgumentError if the file does not exist" do
151
+ expect(File).to receive(:file?).with('/full/path/e/abc').and_return(false)
152
+ expect { template(:e).new.file('abc') }.to raise_error(ArgumentError)
153
153
  end
154
154
 
155
- it "should replace {{{__super__}}} with inherited template contents if allow_inherited=true" do
156
- File.should_receive(:file?).with('/full/path/a/abc').twice.and_return(true)
157
- File.should_receive(:file?).with('/full/path/b/abc').and_return(true)
158
- IO.should_receive(:read).with('/full/path/a/abc').and_return('foo {{{__super__}}}')
159
- IO.should_receive(:read).with('/full/path/b/abc').and_return('bar')
160
- template(:a).new.file('abc', true).should == "foo bar"
155
+ it "replaces {{{__super__}}} with inherited template contents if allow_inherited=true" do
156
+ expect(File).to receive(:file?).with('/full/path/a/abc').twice.and_return(true)
157
+ expect(File).to receive(:file?).with('/full/path/b/abc').and_return(true)
158
+ expect(IO).to receive(:read).with('/full/path/a/abc').and_return('foo {{{__super__}}}')
159
+ expect(IO).to receive(:read).with('/full/path/b/abc').and_return('bar')
160
+ expect(template(:a).new.file('abc', true)).to eq "foo bar"
161
161
  end
162
162
 
163
- it "should not replace {{{__super__}}} with inherited template contents if allow_inherited=false" do
164
- File.should_receive(:file?).with('/full/path/a/abc').and_return(true)
165
- IO.should_receive(:read).with('/full/path/a/abc').and_return('foo {{{__super__}}}')
166
- template(:a).new.file('abc').should == "foo {{{__super__}}}"
163
+ it "does not replace {{{__super__}}} with inherited template contents if allow_inherited=false" do
164
+ expect(File).to receive(:file?).with('/full/path/a/abc').and_return(true)
165
+ expect(IO).to receive(:read).with('/full/path/a/abc').and_return('foo {{{__super__}}}')
166
+ expect(template(:a).new.file('abc')).to eq "foo {{{__super__}}}"
167
167
  end
168
168
  end
169
169
 
170
- describe '#superb' do
171
- it "should return the inherited erb template contents" do
172
- File.should_receive(:file?).with('/full/path/a/test.erb').and_return(true)
173
- File.should_receive(:file?).with('/full/path/b/test.erb').and_return(true)
174
- IO.should_receive(:read).with('/full/path/b/test.erb').and_return('bar')
170
+ describe "#superb" do
171
+ it "returns the inherited erb template contents" do
172
+ expect(File).to receive(:file?).with('/full/path/a/test.erb').and_return(true)
173
+ expect(File).to receive(:file?).with('/full/path/b/test.erb').and_return(true)
174
+ expect(IO).to receive(:read).with('/full/path/b/test.erb').and_return('bar')
175
175
  template = template(:a).new
176
176
  template.section = :test
177
- template.superb.should == "bar"
177
+ expect(template.superb).to eq "bar"
178
178
  end
179
179
 
180
- it "should work inside an erb template" do
181
- File.should_receive(:file?).with('/full/path/a/test.erb').twice.and_return(true)
182
- File.should_receive(:file?).with('/full/path/b/test.erb').and_return(true)
183
- IO.should_receive(:read).with('/full/path/a/test.erb').and_return('foo<%= superb %>!')
184
- IO.should_receive(:read).with('/full/path/b/test.erb').and_return('bar')
180
+ it "works inside an erb template" do
181
+ expect(File).to receive(:file?).with('/full/path/a/test.erb').twice.and_return(true)
182
+ expect(File).to receive(:file?).with('/full/path/b/test.erb').and_return(true)
183
+ expect(IO).to receive(:read).with('/full/path/a/test.erb').and_return('foo<%= superb %>!')
184
+ expect(IO).to receive(:read).with('/full/path/b/test.erb').and_return('bar')
185
185
  template = template(:a).new
186
186
  template.section = :test
187
- template.erb(:test).should == "foobar!"
187
+ expect(template.erb(:test)).to eq "foobar!"
188
188
  end
189
189
  end
190
190
 
191
- describe '#sections' do
192
- it "should allow sections to be set if arguments are provided" do
191
+ describe "#sections" do
192
+ it "allows sections to be set if arguments are provided" do
193
193
  mod = template(:e).new
194
194
  mod.sections 1, 2, [3]
195
- mod.sections.should == Section.new(nil, 1, 2, [3])
195
+ expect(mod.sections).to eq Section.new(nil, 1, 2, [3])
196
196
  end
197
197
  end
198
198
 
199
- describe '#run' do
200
- it "should render all sections" do
199
+ describe "#run" do
200
+ it "renders all sections" do
201
201
  mod = template(:e).new
202
- mod.should_receive(:render_section).with(Section.new(:a)).and_return('a')
203
- mod.should_receive(:render_section).with(Section.new(:b)).and_return('b')
204
- mod.should_receive(:render_section).with(Section.new(:c)).and_return('c')
202
+ allow(mod).to receive(:render_section) { |section| section.name.to_s }
205
203
  mod.sections :a, :b, :c
206
- mod.run.should == 'abc'
204
+ expect(mod.run).to eq 'abc'
207
205
  end
208
206
 
209
- it "should render all sections with options" do
207
+ it "renders all sections with options" do
210
208
  mod = template(:e).new
211
- mod.should_receive(:render_section).with(Section.new(:a)).and_return('a')
212
- mod.should_receive(:add_options).with(:a => 1).and_yield
209
+ allow(mod).to receive(:render_section) { |section| section.name.to_s }
210
+ expect(mod).to receive(:add_options).with(:a => 1).and_yield
213
211
  mod.sections :a
214
- mod.run(:a => 1).should == 'a'
212
+ expect(mod.run(:a => 1)).to eq 'a'
215
213
  end
216
214
 
217
- it "should run section list if provided" do
215
+ it "runs section list if provided" do
218
216
  mod = template(:e).new
219
- mod.should_receive(:render_section).with(Section.new(:q))
220
- mod.should_receive(:render_section).with(Section.new(:x))
217
+ expect(mod).to receive(:render_section).exactly(2).times do |section|
218
+ expect([:q, :x]).to include(section.name)
219
+ section.name.to_s
220
+ end
221
221
  mod.run({}, [:q, :x])
222
222
  end
223
223
 
224
- it "should accept a nil section as empty string" do
224
+ it "accepts a nil section as empty string" do
225
225
  mod = template(:e).new
226
- mod.should_receive(:render_section).with(Section.new(:a))
226
+ allow(mod).to receive(:render_section) { nil }
227
227
  mod.sections :a
228
- mod.run.should == ""
228
+ expect(mod.run).to eq ""
229
229
  end
230
230
  end
231
231
 
232
- describe '#add_options' do
233
- it "should set instance variables in addition to options" do
232
+ describe "#add_options" do
233
+ it "sets instance variables in addition to options" do
234
234
  mod = template(:f).new
235
235
  mod.send(:add_options, {:a => 1, :b => 2})
236
- mod.options.should == {:a => 1, :b => 2}
237
- mod.instance_variable_get("@a").should == 1
238
- mod.instance_variable_get("@b").should == 2
236
+ expect(mod.options).to eq({:a => 1, :b => 2})
237
+ expect(mod.instance_variable_get("@a")).to eq 1
238
+ expect(mod.instance_variable_get("@b")).to eq 2
239
239
  end
240
240
 
241
- it "should set instance variables and options only for the block" do
241
+ it "sets instance variables and options only for the block" do
242
242
  mod = template(:f).new
243
243
  mod.send(:add_options, {:a => 100, :b => 200}) do
244
- mod.options.should == {:a => 100, :b => 200}
244
+ expect(mod.options).to eq({:a => 100, :b => 200})
245
245
  end
246
- mod.options.should_not == {:a => 100, :b => 200}
246
+ expect(mod.options).not_to eq({:a => 100, :b => 200})
247
247
  end
248
248
  end
249
249
 
250
- describe '#render_section' do
251
- it "should call method if method exists by section name as Symbol" do
250
+ describe "#render_section" do
251
+ it "calls method if method exists by section name as Symbol" do
252
252
  mod = template(:f).new
253
- mod.should_receive(:respond_to?).with(:a).and_return(true)
254
- mod.should_receive(:respond_to?).with('a').and_return(true)
255
- mod.should_receive(:send).with(:a).and_return('a')
256
- mod.should_receive(:send).with('a').and_return('a')
257
- mod.run({}, [:a, 'a']).should == 'aa'
253
+ expect(mod).to receive(:respond_to?).with(:a).and_return(true)
254
+ expect(mod).to receive(:respond_to?).with('a').and_return(true)
255
+ expect(mod).to receive(:send).with(:a).and_return('a')
256
+ expect(mod).to receive(:send).with('a').and_return('a')
257
+ expect(mod.run({}, [:a, 'a'])).to eq 'aa'
258
258
  end
259
259
 
260
- it "should call erb if no method exists by section name" do
260
+ it "calls erb if no method exists by section name" do
261
261
  mod = template(:f).new
262
- mod.should_receive(:respond_to?).with(:a).and_return(false)
263
- mod.should_receive(:respond_to?).with('a').and_return(false)
264
- mod.should_receive(:erb).with(:a).and_return('a')
265
- mod.should_receive(:erb).with('a').and_return('a')
266
- mod.run({}, [:a, 'a']).should == 'aa'
262
+ expect(mod).to receive(:respond_to?).with(:a).and_return(false)
263
+ expect(mod).to receive(:respond_to?).with('a').and_return(false)
264
+ expect(mod).to receive(:erb).with(:a).and_return('a')
265
+ expect(mod).to receive(:erb).with('a').and_return('a')
266
+ expect(mod.run({}, [:a, 'a'])).to eq 'aa'
267
267
  end
268
268
 
269
- it "should run a template if section is one" do
269
+ it "runs a template if section is one" do
270
270
  mod2 = template(:g)
271
- mod2.should_receive(:run)
271
+ expect(mod2).to receive(:run)
272
272
  mod = template(:f).new
273
273
  mod.sections mod2
274
274
  mod.run
275
275
  end
276
276
 
277
- it "should run a template instance if section is one" do
277
+ it "runs a template instance if section is one" do
278
278
  mod2 = template(:g).new
279
- mod2.should_receive(:run)
279
+ expect(mod2).to receive(:run)
280
280
  mod = template(:f).new
281
281
  mod.sections mod2
282
282
  mod.run
283
283
  end
284
284
  end
285
285
 
286
- describe '#yield' do
287
- it "should yield a subsection" do
286
+ describe "#yield" do
287
+ it "yields a subsection" do
288
288
  mod = template(:e).new
289
289
  mod.sections :a, [:b, :c]
290
290
  class << mod
@@ -293,10 +293,10 @@ describe YARD::Templates::Template do
293
293
  def c; "c" end
294
294
  end
295
295
 
296
- mod.run.should == "(b)"
296
+ expect(mod.run).to eq "(b)"
297
297
  end
298
298
 
299
- it "should yield a subsection within a yielded subsection" do
299
+ it "yields a subsection within a yielded subsection" do
300
300
  mod = template(:e).new
301
301
  mod.sections :a, [:b, [:c]]
302
302
  class << mod
@@ -305,10 +305,10 @@ describe YARD::Templates::Template do
305
305
  def c; "c" end
306
306
  end
307
307
 
308
- mod.run.should == "(c)"
308
+ expect(mod.run).to eq "(c)"
309
309
  end
310
310
 
311
- it "should support arbitrary nesting" do
311
+ it "supports arbitrary nesting" do
312
312
  mod = template(:e).new
313
313
  mod.sections :a, [:b, [:c, [:d, [:e]]]]
314
314
  class << mod
@@ -319,10 +319,10 @@ describe YARD::Templates::Template do
319
319
  def e; "e" end
320
320
  end
321
321
 
322
- mod.run.should == "(e)"
322
+ expect(mod.run).to eq "(e)"
323
323
  end
324
324
 
325
- it "should yield first two elements if yield is called twice" do
325
+ it "yields first two elements if yield is called twice" do
326
326
  mod = template(:e).new
327
327
  mod.sections :a, [:b, :c, :d]
328
328
  class << mod
@@ -331,10 +331,10 @@ describe YARD::Templates::Template do
331
331
  def c; "c" end
332
332
  end
333
333
 
334
- mod.run.should == "(bc)"
334
+ expect(mod.run).to eq "(bc)"
335
335
  end
336
336
 
337
- it "should ignore any subsections inside subsection yields" do
337
+ it "ignores any subsections inside subsection yields" do
338
338
  mod = template(:e).new
339
339
  mod.sections :a, [:b, [:c], :d]
340
340
  class << mod
@@ -343,10 +343,10 @@ describe YARD::Templates::Template do
343
343
  def d; "d" end
344
344
  end
345
345
 
346
- mod.run.should == "(bd)"
346
+ expect(mod.run).to eq "(bd)"
347
347
  end
348
348
 
349
- it "should allow extra options passed via yield" do
349
+ it "allows extra options passed via yield" do
350
350
  mod = template(:e).new
351
351
  mod.sections :a, [:b]
352
352
  class << mod
@@ -354,12 +354,12 @@ describe YARD::Templates::Template do
354
354
  def b; options.x + @x end
355
355
  end
356
356
 
357
- mod.run.should == "(aa)"
357
+ expect(mod.run).to eq "(aa)"
358
358
  end
359
359
  end
360
360
 
361
- describe '#yieldall' do
362
- it "should yield all subsections" do
361
+ describe "#yieldall" do
362
+ it "yields all subsections" do
363
363
  mod = template(:e).new
364
364
  mod.sections :a, [:b, [:d, [:e]], :c]
365
365
  class << mod
@@ -370,10 +370,10 @@ describe YARD::Templates::Template do
370
370
  def e; 'e' end
371
371
  end
372
372
 
373
- mod.run.should == "(bdec)"
373
+ expect(mod.run).to eq "(bdec)"
374
374
  end
375
375
 
376
- it "should yield options to all subsections" do
376
+ it "yields options to all subsections" do
377
377
  mod = template(:e).new
378
378
  mod.sections :a, [:b, :c]
379
379
  class << mod
@@ -381,10 +381,10 @@ describe YARD::Templates::Template do
381
381
  def b; @x end
382
382
  def c; @x end
383
383
  end
384
- mod.run.should == "(22)"
384
+ expect(mod.run).to eq "(22)"
385
385
  end
386
386
 
387
- it "should yield all subsections more than once" do
387
+ it "yields all subsections more than once" do
388
388
  mod = template(:e).new
389
389
  mod.sections :a, [:b]
390
390
  class << mod
@@ -392,10 +392,10 @@ describe YARD::Templates::Template do
392
392
  def b; "b" end
393
393
  end
394
394
 
395
- mod.run.should == "(bb)"
395
+ expect(mod.run).to eq "(bb)"
396
396
  end
397
397
 
398
- it "should not yield if no yieldall is called" do
398
+ it "does not yield if no yieldall is called" do
399
399
  mod = template(:e).new
400
400
  mod.sections :a, [:b]
401
401
  class << mod
@@ -403,7 +403,7 @@ describe YARD::Templates::Template do
403
403
  def b; "b" end
404
404
  end
405
405
 
406
- mod.run.should == "()"
406
+ expect(mod.run).to eq "()"
407
407
  end
408
408
  end
409
409
  end