Class: RubyIndexer::ClassesAndModulesTest
- Defined in:
- lib/ruby_indexer/test/classes_and_modules_test.rb
Instance Method Summary collapse
- #test_class_with_statements ⇒ Object
- #test_colon_colon_class ⇒ Object
- #test_colon_colon_class_inside_class ⇒ Object
- #test_colon_colon_module ⇒ Object
- #test_comments_can_be_attached_to_a_class ⇒ Object
- #test_comments_can_be_attached_to_a_namespaced_class ⇒ Object
- #test_comments_can_be_attached_to_a_reopened_class ⇒ Object
- #test_comments_removes_the_leading_pound_and_space ⇒ Object
- #test_deleting_from_index_based_on_file_path ⇒ Object
- #test_dynamically_namespaced_class ⇒ Object
- #test_dynamically_namespaced_module ⇒ Object
- #test_empty_statements_class ⇒ Object
- #test_empty_statements_module ⇒ Object
- #test_keeping_track_of_super_classes ⇒ Object
- #test_module_with_statements ⇒ Object
- #test_namespaced_class ⇒ Object
- #test_namespaced_module ⇒ Object
- #test_nested_modules_and_classes ⇒ Object
- #test_private_class_and_module_indexing ⇒ Object
Methods inherited from TestCase
Instance Method Details
#test_class_with_statements ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 17 def test_class_with_statements index(" class Foo\n def something; end\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Class, \"/fake/path/foo.rb:0-0:2-3\")\nend\n") |
#test_colon_colon_class ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 27 def test_colon_colon_class index(" class ::Foo\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Class, \"/fake/path/foo.rb:0-0:1-3\")\nend\n") |
#test_colon_colon_class_inside_class ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 36 def test_colon_colon_class_inside_class index(" class Bar\n class ::Foo\n end\n end\n RUBY\n\n assert_entry(\"Bar\", Entry::Class, \"/fake/path/foo.rb:0-0:3-3\")\n assert_entry(\"Foo\", Entry::Class, \"/fake/path/foo.rb:1-2:2-5\")\nend\n") |
#test_colon_colon_module ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 85 def test_colon_colon_module index(" module ::Foo\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Module, \"/fake/path/foo.rb:0-0:1-3\")\nend\n") |
#test_comments_can_be_attached_to_a_class ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 147 def test_comments_can_be_attached_to_a_class index(" # This is method comment\n def foo; end\n # This is a Foo comment\n # This is another Foo comment\n class Foo\n # This should not be attached\n end\n\n # Ignore me\n\n # This Bar comment has 1 line padding\n\n class Bar; end\n RUBY\n\n foo_entry = @index[\"Foo\"].first\n assert_equal(\"This is a Foo comment\\nThis is another Foo comment\", foo_entry.comments.join(\"\\n\"))\n\n bar_entry = @index[\"Bar\"].first\n assert_equal(\"This Bar comment has 1 line padding\", bar_entry.comments.join(\"\\n\"))\nend\n") |
#test_comments_can_be_attached_to_a_namespaced_class ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 171 def test_comments_can_be_attached_to_a_namespaced_class index(" # This is a Foo comment\n # This is another Foo comment\n class Foo\n # This is a Bar comment\n class Bar; end\n end\n RUBY\n\n foo_entry = @index[\"Foo\"].first\n assert_equal(\"This is a Foo comment\\nThis is another Foo comment\", foo_entry.comments.join(\"\\n\"))\n\n bar_entry = @index[\"Foo::Bar\"].first\n assert_equal(\"This is a Bar comment\", bar_entry.comments.join(\"\\n\"))\nend\n") |
#test_comments_can_be_attached_to_a_reopened_class ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 188 def test_comments_can_be_attached_to_a_reopened_class index(" # This is a Foo comment\n class Foo; end\n\n # This is another Foo comment\n class Foo; end\n RUBY\n\n first_foo_entry = @index[\"Foo\"][0]\n assert_equal(\"This is a Foo comment\", first_foo_entry.comments.join(\"\\n\"))\n\n second_foo_entry = @index[\"Foo\"][1]\n assert_equal(\"This is another Foo comment\", second_foo_entry.comments.join(\"\\n\"))\nend\n") |
#test_comments_removes_the_leading_pound_and_space ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 204 def test_comments_removes_the_leading_pound_and_space index(" # This is a Foo comment\n class Foo; end\n\n #This is a Bar comment\n class Bar; end\n RUBY\n\n first_foo_entry = @index[\"Foo\"][0]\n assert_equal(\"This is a Foo comment\", first_foo_entry.comments.join(\"\\n\"))\n\n second_foo_entry = @index[\"Bar\"][0]\n assert_equal(\"This is a Bar comment\", second_foo_entry.comments.join(\"\\n\"))\nend\n") |
#test_deleting_from_index_based_on_file_path ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 134 def test_deleting_from_index_based_on_file_path index(" class Foo\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Class, \"/fake/path/foo.rb:0-0:1-3\")\n\n @index.delete(IndexablePath.new(nil, \"/fake/path/foo.rb\"))\n refute_entry(\"Foo\")\n assert_empty(@index.instance_variable_get(:@files_to_entries))\nend\n") |
#test_dynamically_namespaced_class ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 57 def test_dynamically_namespaced_class index(" class self::Bar\n end\n RUBY\n\n refute_entry(\"self::Bar\")\nend\n") |
#test_dynamically_namespaced_module ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 103 def test_dynamically_namespaced_module index(" module self::Bar\n end\n RUBY\n\n refute_entry(\"self::Bar\")\nend\n") |
#test_empty_statements_class ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 8 def test_empty_statements_class index(" class Foo\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Class, \"/fake/path/foo.rb:0-0:1-3\")\nend\n") |
#test_empty_statements_module ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 66 def test_empty_statements_module index(" module Foo\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Module, \"/fake/path/foo.rb:0-0:1-3\")\nend\n") |
#test_keeping_track_of_super_classes ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 243 def test_keeping_track_of_super_classes index(" class Foo < Bar\n end\n\n class Baz\n end\n\n module Something\n class Baz\n end\n\n class Qux < ::Baz\n end\n end\n\n class FinalThing < Something::Baz\n end\n RUBY\n\n foo = T.must(@index[\"Foo\"].first)\n assert_equal(\"Bar\", foo.parent_class)\n\n baz = T.must(@index[\"Baz\"].first)\n assert_nil(baz.parent_class)\n\n qux = T.must(@index[\"Something::Qux\"].first)\n assert_equal(\"::Baz\", qux.parent_class)\n\n final_thing = T.must(@index[\"FinalThing\"].first)\n assert_equal(\"Something::Baz\", final_thing.parent_class)\nend\n") |
#test_module_with_statements ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 75 def test_module_with_statements index(" module Foo\n def something; end\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Module, \"/fake/path/foo.rb:0-0:2-3\")\nend\n") |
#test_namespaced_class ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 48 def test_namespaced_class index(" class Foo::Bar\n end\n RUBY\n\n assert_entry(\"Foo::Bar\", Entry::Class, \"/fake/path/foo.rb:0-0:1-3\")\nend\n") |
#test_namespaced_module ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 94 def test_namespaced_module index(" module Foo::Bar\n end\n RUBY\n\n assert_entry(\"Foo::Bar\", Entry::Module, \"/fake/path/foo.rb:0-0:1-3\")\nend\n") |
#test_nested_modules_and_classes ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 112 def test_nested_modules_and_classes index(" module Foo\n class Bar\n end\n\n module Baz\n class Qux\n class Something\n end\n end\n end\n end\n RUBY\n\n assert_entry(\"Foo\", Entry::Module, \"/fake/path/foo.rb:0-0:10-3\")\n assert_entry(\"Foo::Bar\", Entry::Class, \"/fake/path/foo.rb:1-2:2-5\")\n assert_entry(\"Foo::Baz\", Entry::Module, \"/fake/path/foo.rb:4-2:9-5\")\n assert_entry(\"Foo::Baz::Qux\", Entry::Class, \"/fake/path/foo.rb:5-4:8-7\")\n assert_entry(\"Foo::Baz::Qux::Something\", Entry::Class, \"/fake/path/foo.rb:6-6:7-9\")\nend\n") |
#test_private_class_and_module_indexing ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/ruby_indexer/test/classes_and_modules_test.rb', line 220 def test_private_class_and_module_indexing index(" class A\n class B; end\n private_constant(:B)\n\n module C; end\n private_constant(\"C\")\n\n class D; end\n end\n RUBY\n\n b_const = @index[\"A::B\"].first\n assert_equal(:private, b_const.visibility)\n\n c_const = @index[\"A::C\"].first\n assert_equal(:private, c_const.visibility)\n\n d_const = @index[\"A::D\"].first\n assert_equal(:public, d_const.visibility)\nend\n") |