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,144 +5,144 @@ describe YARD::CodeObjects::MacroObject do
5
5
  Registry.clear
6
6
  end
7
7
 
8
- describe '.create' do
8
+ describe ".create" do
9
9
  def create(*args) MacroObject.create(*args) end
10
10
 
11
- it "should create an object" do
11
+ it "creates an object" do
12
12
  create('foo', '')
13
13
  obj = Registry.at('.macro.foo')
14
- obj.should_not be_nil
14
+ expect(obj).not_to be nil
15
15
  end
16
16
 
17
- it "should use identity map" do
17
+ it "uses identity map" do
18
18
  obj1 = create('foo', '')
19
19
  obj2 = create('foo', '')
20
- obj1.object_id.should == obj2.object_id
20
+ expect(obj1.object_id).to eq obj2.object_id
21
21
  end
22
22
 
23
- it "should allow specifying of macro data" do
23
+ it "allows specifying of macro data" do
24
24
  obj = create('foo', 'MACRODATA')
25
- obj.macro_data.should == 'MACRODATA'
25
+ expect(obj.macro_data).to eq 'MACRODATA'
26
26
  end
27
27
 
28
- it "should attach if a method object is provided" do
29
- obj = create('foo', 'MACRODATA', P('Foo.property'))
30
- obj.method_object.should == P('Foo.property')
31
- obj.should be_attached
28
+ context "if a method object is provided" do
29
+ it "attaches it" do
30
+ obj = create('foo', 'MACRODATA', P('Foo.property'))
31
+ expect(obj.method_object).to eq P('Foo.property')
32
+ expect(obj).to be_attached
33
+ end
32
34
  end
33
35
  end
34
36
 
35
- describe '.find' do
37
+ describe ".find" do
36
38
  before { MacroObject.create('foo', 'DATA') }
37
39
 
38
- it "should search for an object by name" do
39
- MacroObject.find('foo').macro_data.should == 'DATA'
40
+ it "searches for an object by name" do
41
+ expect(MacroObject.find('foo').macro_data).to eq 'DATA'
40
42
  end
41
43
 
42
- it "should accept Symbol" do
43
- MacroObject.find(:foo).macro_data.should == 'DATA'
44
+ it "accepts Symbol" do
45
+ expect(MacroObject.find(:foo).macro_data).to eq 'DATA'
44
46
  end
45
47
  end
46
48
 
47
- describe '.find_or_create' do
48
- it "should look up name if @!macro is present and find object" do
49
+ describe ".find_or_create" do
50
+ it "looks up name if @!macro is present and find object" do
49
51
  macro1 = MacroObject.create('foo', 'FOO')
50
52
  macro2 = MacroObject.find_or_create('foo', "a b c")
51
- macro1.should == macro2
53
+ expect(macro1).to eq macro2
52
54
  end
53
55
 
54
- it "should create new macro if macro by that name does not exist" do
56
+ it "creates new macro if macro by that name does not exist" do
55
57
  MacroObject.find_or_create('foo', "@!method $1")
56
- MacroObject.find('foo').macro_data.should == "@!method $1"
58
+ expect(MacroObject.find('foo').macro_data).to eq "@!method $1"
57
59
  end
58
60
  end
59
61
 
60
- describe '.apply' do
61
- before do
62
- @args = %w(foo a b c)
63
- end
62
+ describe ".apply" do
63
+ let(:args) { %w(foo a b c) }
64
64
 
65
65
  def apply(comments)
66
- MacroObject.apply(comments, @args)
66
+ MacroObject.apply(comments, args)
67
67
  end
68
68
 
69
- it "should only expand macros if @macro is present" do
70
- apply("$1$2$3").should == "$1$2$3"
69
+ it "only expands macros if @macro is present" do
70
+ expect(apply("$1$2$3")).to eq "$1$2$3"
71
71
  end
72
72
 
73
- it "should handle macro text inside block" do
74
- apply("@!macro\n foo$1$2$3\nfoobaz").should == "fooabc\nfoobaz"
73
+ it "handles macro text inside block" do
74
+ expect(apply("@!macro\n foo$1$2$3\nfoobaz")).to eq "fooabc\nfoobaz"
75
75
  end
76
76
 
77
- it "should append docstring to existing macro" do
77
+ it "appends docstring to existing macro" do
78
78
  macro = MacroObject.create('name', '$3$2$1')
79
- result = MacroObject.apply("@!macro name\nfoobar", @args)
80
- result.should == "cba\nfoobar"
79
+ result = MacroObject.apply("@!macro name\nfoobar", args)
80
+ expect(result).to eq "cba\nfoobar"
81
81
  end
82
82
 
83
- it "should use only non macro data if docstring is an existing macro" do
83
+ it "uses only non-macro data if docstring is an existing macro" do
84
84
  data = "@!macro name\n $3$2$1\nEXTRA"
85
- result = MacroObject.apply(data, @args, 'SOURCE')
86
- result.should == "cba\nEXTRA"
87
- MacroObject.apply("@!macro name\nFOO", @args).should == "cba\nFOO"
85
+ result = MacroObject.apply(data, args, 'SOURCE')
86
+ expect(result).to eq "cba\nEXTRA"
87
+ expect(MacroObject.apply("@!macro name\nFOO", args)).to eq "cba\nFOO"
88
88
  end
89
89
 
90
- it "should create macros if they don't exist" do
91
- result = MacroObject.apply("@!macro name\n foo!$1", @args, 'SOURCE')
92
- result.should == "foo!a"
93
- MacroObject.find('name').macro_data.should == 'foo!$1'
90
+ it "creates macros if they don't exist" do
91
+ result = MacroObject.apply("@!macro name\n foo!$1", args, 'SOURCE')
92
+ expect(result).to eq "foo!a"
93
+ expect(MacroObject.find('name').macro_data).to eq 'foo!$1'
94
94
  end
95
95
 
96
- it "should keep other tags" do
97
- apply("@!macro\n foo$1$2$3\n@param name foo\nfoo").should ==
98
- "fooabc\nfoo\n@param name\n foo"
96
+ it "keeps other tags" do
97
+ expect(apply("@!macro\n foo$1$2$3\n@param name foo\nfoo")).to eq(
98
+ "fooabc\nfoo\n@param name\n foo")
99
99
  end
100
100
  end
101
101
 
102
- describe '.expand' do
102
+ describe ".expand" do
103
103
  def expand(comments)
104
104
  args = %w(foo a b c)
105
105
  full_line = 'foo :bar, :baz'
106
106
  MacroObject.expand(comments, args, full_line)
107
107
  end
108
108
 
109
- it "should allow escaping of macro syntax" do
110
- expand("$1\\$2$3").should == "a$2c"
109
+ it "allows escaping of macro syntax" do
110
+ expect(expand("$1\\$2$3")).to eq "a$2c"
111
111
  end
112
112
 
113
- it "should replace $* with the whole statement" do
114
- expand("$* ${*}").should == "foo :bar, :baz foo :bar, :baz"
113
+ it "replaces $* with the whole statement" do
114
+ expect(expand("$* ${*}")).to eq "foo :bar, :baz foo :bar, :baz"
115
115
  end
116
116
 
117
- it "should replace $0 with method name" do
118
- expand("$0 ${0}").should == "foo foo"
117
+ it "replaces $0 with method name" do
118
+ expect(expand("$0 ${0}")).to eq "foo foo"
119
119
  end
120
120
 
121
- it "should replace all $N values with the Nth argument in the method call" do
122
- expand("$1$2$3${3}\nfoobar").should == "abcc\nfoobar"
121
+ it "replaces all $N values with the Nth argument in the method call" do
122
+ expect(expand("$1$2$3${3}\nfoobar")).to eq "abcc\nfoobar"
123
123
  end
124
124
 
125
- it "should replace ${N-M} ranges with N-M arguments (incl. commas)" do
126
- expand("${1-2}x").should == "a, bx"
125
+ it "replaces ${N-M} ranges with N-M arguments (incl. commas)" do
126
+ expect(expand("${1-2}x")).to eq "a, bx"
127
127
  end
128
128
 
129
- it "should handle open ended ranges (${N-})" do
130
- expand("${2-}").should == "b, c"
129
+ it "handles open ended ranges (${N-})" do
130
+ expect(expand("${2-}")).to eq "b, c"
131
131
  end
132
132
 
133
- it "should handle negative indexes ($-N)" do
134
- expand("$-1 ${-2-} ${-2--2}").should == "c b, c b"
133
+ it "handles negative indexes ($-N)" do
134
+ expect(expand("$-1 ${-2-} ${-2--2}")).to eq "c b, c b"
135
135
  end
136
136
 
137
- it "should accept Docstring objects" do
138
- expand(Docstring.new("$1\n@param name foo")).should == "a\n@param name foo"
137
+ it "accepts Docstring objects" do
138
+ expect(expand(Docstring.new("$1\n@param name foo"))).to eq "a\n@param name foo"
139
139
  end
140
140
  end
141
141
 
142
- describe '#expand' do
143
- it "should expand macro given its data" do
142
+ describe "#expand" do
143
+ it "expands a macro given its data" do
144
144
  macro = MacroObject.create_docstring('foo', '$1 $2 THREE!')
145
- macro.expand(['NAME', 'ONE', 'TWO']).should == "ONE TWO THREE!"
145
+ expect(macro.expand(['NAME', 'ONE', 'TWO'])).to eq "ONE TWO THREE!"
146
146
  end
147
147
  end
148
148
  end
@@ -6,170 +6,178 @@ describe YARD::CodeObjects::MethodObject do
6
6
  @yard = ModuleObject.new(:root, :YARD)
7
7
  end
8
8
 
9
- it "should have a path of testing for an instance method in the root" do
10
- meth = MethodObject.new(:root, :testing)
11
- meth.path.should == "#testing"
9
+ context "for an instance method in the root" do
10
+ it "has a path of testing" do
11
+ meth = MethodObject.new(:root, :testing)
12
+ expect(meth.path).to eq "#testing"
13
+ end
12
14
  end
13
15
 
14
- it "should have a path of YARD#testing for an instance method in YARD" do
15
- meth = MethodObject.new(@yard, :testing)
16
- meth.path.should == "YARD#testing"
16
+ context "for an instance method in YARD" do
17
+ it "has a path of YARD#testing" do
18
+ meth = MethodObject.new(@yard, :testing)
19
+ expect(meth.path).to eq "YARD#testing"
20
+ end
17
21
  end
18
22
 
19
- it "should have a path of YARD.testing for a class method in YARD" do
20
- meth = MethodObject.new(@yard, :testing, :class)
21
- meth.path.should == "YARD.testing"
23
+ context "for a class method in YARD" do
24
+ it "has a path of YARD.testing" do
25
+ meth = MethodObject.new(@yard, :testing, :class)
26
+ expect(meth.path).to eq "YARD.testing"
27
+ end
22
28
  end
23
29
 
24
- it "should have a path of ::testing (note the ::) for a class method added to root namespace" do
25
- meth = MethodObject.new(:root, :testing, :class)
26
- meth.path.should == "::testing"
30
+ context "for a class method added to root namespace" do
31
+ it "has a path of ::testing (note the ::)" do
32
+ meth = MethodObject.new(:root, :testing, :class)
33
+ expect(meth.path).to eq "::testing"
34
+ end
27
35
  end
28
36
 
29
- it "should exist in the registry after successful creation" do
37
+ it "exists in the registry after successful creation" do
30
38
  obj = MethodObject.new(@yard, :something, :class)
31
- Registry.at("YARD.something").should_not be_nil
32
- Registry.at("YARD#something").should be_nil
33
- Registry.at("YARD::something").should be_nil
39
+ expect(Registry.at("YARD.something")).not_to be nil
40
+ expect(Registry.at("YARD#something")).to be nil
41
+ expect(Registry.at("YARD::something")).to be nil
34
42
  obj = MethodObject.new(@yard, :somethingelse)
35
- Registry.at("YARD#somethingelse").should_not be_nil
43
+ expect(Registry.at("YARD#somethingelse")).not_to be nil
36
44
  end
37
45
 
38
- it "should allow #scope to be changed after creation" do
46
+ it "allows #scope to be changed after creation" do
39
47
  obj = MethodObject.new(@yard, :something, :class)
40
- Registry.at("YARD.something").should_not be_nil
48
+ expect(Registry.at("YARD.something")).not_to be nil
41
49
  obj.scope = :instance
42
- Registry.at("YARD.something").should be_nil
43
- Registry.at("YARD#something").should_not be_nil
50
+ expect(Registry.at("YARD.something")).to be nil
51
+ expect(Registry.at("YARD#something")).not_to be nil
44
52
  end
45
53
 
46
- it "should create object in :class scope if scope is :module" do
54
+ it "creates object in :class scope if scope is :module" do
47
55
  obj = MethodObject.new(@yard, :module_func, :module)
48
- obj.scope.should == :class
49
- obj.visibility.should == :public
50
- Registry.at('YARD.module_func').should_not be_nil
56
+ expect(obj.scope).to eq :class
57
+ expect(obj.visibility).to eq :public
58
+ expect(Registry.at('YARD.module_func')).not_to be nil
51
59
  end
52
60
 
53
- it "should create second private instance method if scope is :module" do
61
+ it "creates second private instance method if scope is :module" do
54
62
  MethodObject.new(@yard, :module_func, :module)
55
63
  obj = Registry.at('YARD#module_func')
56
- obj.should_not be_nil
57
- obj.visibility.should == :private
58
- obj.scope.should == :instance
64
+ expect(obj).not_to be nil
65
+ expect(obj.visibility).to eq :private
66
+ expect(obj.scope).to eq :instance
59
67
  end
60
68
 
61
- it "should yield block to second method if scope is :module" do
69
+ it "yields block to second method if scope is :module" do
62
70
  MethodObject.new(@yard, :module_func, :module) do |o|
63
71
  o.docstring = 'foo'
64
72
  end
65
- Registry.at('YARD.module_func').docstring.should == 'foo'
66
- Registry.at('YARD#module_func').docstring.should == 'foo'
73
+ expect(Registry.at('YARD.module_func').docstring).to eq 'foo'
74
+ expect(Registry.at('YARD#module_func').docstring).to eq 'foo'
67
75
  end
68
76
 
69
- describe '#name' do
70
- it "should show a prefix for an instance method when prefix=true" do
77
+ describe "#name" do
78
+ it "shows a prefix for an instance method when prefix=true" do
71
79
  obj = MethodObject.new(nil, :something)
72
- obj.name(true).should == "#something"
80
+ expect(obj.name(true)).to eq "#something"
73
81
  end
74
82
 
75
- it "should never show a prefix for a class method" do
83
+ it "never shows a prefix for a class method" do
76
84
  obj = MethodObject.new(nil, :something, :class)
77
- obj.name.should == :"something"
78
- obj.name(true).should == "something"
85
+ expect(obj.name).to eq :"something"
86
+ expect(obj.name(true)).to eq "something"
79
87
  end
80
88
  end
81
89
 
82
- describe '#is_attribute?' do
83
- it "should only return true if attribute is set in namespace for read/write" do
90
+ describe "#is_attribute?" do
91
+ it "only returns true if attribute is set in namespace for read/write" do
84
92
  obj = MethodObject.new(@yard, :foo)
85
93
  @yard.attributes[:instance][:foo] = {:read => obj, :write => nil}
86
- obj.is_attribute?.should be_true
87
- MethodObject.new(@yard, :foo=).is_attribute?.should be_false
94
+ expect(obj.is_attribute?).to be true
95
+ expect(MethodObject.new(@yard, :foo=).is_attribute?).to be false
88
96
  end
89
97
  end
90
98
 
91
- describe '#attr_info' do
92
- it "should return attribute info if namespace is available" do
99
+ describe "#attr_info" do
100
+ it "returns attribute info if namespace is available" do
93
101
  obj = MethodObject.new(@yard, :foo)
94
102
  @yard.attributes[:instance][:foo] = {:read => obj, :write => nil}
95
- obj.attr_info.should == @yard.attributes[:instance][:foo]
103
+ expect(obj.attr_info).to eq @yard.attributes[:instance][:foo]
96
104
  end
97
105
 
98
- it "should return nil if namespace is proxy" do
106
+ it "returns nil if namespace is proxy" do
99
107
  obj = MethodObject.new(P(:ProxyClass), :foo)
100
- MethodObject.new(@yard, :foo).attr_info.should == nil
108
+ expect(MethodObject.new(@yard, :foo).attr_info).to eq nil
101
109
  end
102
110
 
103
- it "should return nil if meth is not an attribute" do
104
- MethodObject.new(@yard, :notanattribute).attr_info.should == nil
111
+ it "returns nil if meth is not an attribute" do
112
+ expect(MethodObject.new(@yard, :notanattribute).attr_info).to eq nil
105
113
  end
106
114
  end
107
115
 
108
- describe '#writer?' do
109
- it "should return true if method is a writer attribute" do
116
+ describe "#writer?" do
117
+ it "returns true if method is a writer attribute" do
110
118
  obj = MethodObject.new(@yard, :foo=)
111
119
  @yard.attributes[:instance][:foo] = {:read => nil, :write => obj}
112
- obj.writer?.should == true
113
- MethodObject.new(@yard, :NOTfoo=).writer?.should == false
120
+ expect(obj.writer?).to be true
121
+ expect(MethodObject.new(@yard, :NOTfoo=).writer?).to be false
114
122
  end
115
123
  end
116
124
 
117
- describe '#reader?' do
118
- it "should return true if method is a reader attribute" do
125
+ describe "#reader?" do
126
+ it "returns true if method is a reader attribute" do
119
127
  obj = MethodObject.new(@yard, :foo)
120
128
  @yard.attributes[:instance][:foo] = {:read => obj, :write => nil}
121
- obj.reader?.should == true
122
- MethodObject.new(@yard, :NOTfoo).reader?.should == false
129
+ expect(obj.reader?).to be true
130
+ expect(MethodObject.new(@yard, :NOTfoo).reader?).to be false
123
131
  end
124
132
  end
125
133
 
126
- describe '#constructor?' do
134
+ describe "#constructor?" do
127
135
  before { @class = ClassObject.new(:root, :MyClass) }
128
136
 
129
- it "should mark the #initialize method as constructor" do
137
+ it "marks the #initialize method as constructor" do
130
138
  MethodObject.new(@class, :initialize)
131
139
  end
132
140
 
133
- it "should not mark Klass.initialize as constructor" do
134
- MethodObject.new(@class, :initialize, :class).constructor?.should be_false
141
+ it "does not mark Klass.initialize as constructor" do
142
+ expect(MethodObject.new(@class, :initialize, :class).constructor?).to be false
135
143
  end
136
144
 
137
- it "should not mark module method #initialize as constructor" do
138
- MethodObject.new(@yard, :initialize).constructor?.should be_false
145
+ it "does not mark module method #initialize as constructor" do
146
+ expect(MethodObject.new(@yard, :initialize).constructor?).to be false
139
147
  end
140
148
  end
141
149
 
142
- describe '#overridden_method' do
150
+ describe "#overridden_method" do
143
151
  before { Registry.clear }
144
152
 
145
- it "should return overridden method from mixin first" do
153
+ it "returns overridden method from mixin first" do
146
154
  YARD.parse_string(<<-eof)
147
155
  module C; def foo; end end
148
156
  class A; def foo; end end
149
157
  class B < A; include C; def foo; end end
150
158
  eof
151
- Registry.at('B#foo').overridden_method.should == Registry.at('C#foo')
159
+ expect(Registry.at('B#foo').overridden_method).to eq Registry.at('C#foo')
152
160
  end
153
161
 
154
- it "should return overridden method from superclass" do
162
+ it "returns overridden method from superclass" do
155
163
  YARD.parse_string(<<-eof)
156
164
  class A; def foo; end end
157
165
  class B < A; def foo; end end
158
166
  eof
159
- Registry.at('B#foo').overridden_method.should == Registry.at('A#foo')
167
+ expect(Registry.at('B#foo').overridden_method).to eq Registry.at('A#foo')
160
168
  end
161
169
 
162
- it "should return nil if none is found" do
170
+ it "returns nil if none is found" do
163
171
  YARD.parse_string(<<-eof)
164
172
  class A; end
165
173
  class B < A; def foo; end end
166
174
  eof
167
- Registry.at('B#foo').overridden_method.should be_nil
175
+ expect(Registry.at('B#foo').overridden_method).to be nil
168
176
  end
169
177
 
170
- it "should return nil if namespace is a proxy" do
178
+ it "returns nil if namespace is a proxy" do
171
179
  YARD.parse_string "def ARGV.foo; end"
172
- Registry.at('ARGV.foo').overridden_method.should be_nil
180
+ expect(Registry.at('ARGV.foo').overridden_method).to be nil
173
181
  end
174
182
  end
175
183
  end