Class: RubyIndexer::MethodTest

Inherits:
TestCase
  • Object
show all
Defined in:
lib/ruby_indexer/test/method_test.rb

Instance Method Summary collapse

Methods inherited from TestCase

#setup

Instance Method Details

#test_method_with_destructed_parametersObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ruby_indexer/test/method_test.rb', line 57

def test_method_with_destructed_parameters
  index(<<~RUBY)
    class Foo
      def bar((a, (b, )))
      end
    end
  RUBY

  assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5")
  entry = T.must(@index["bar"].first)
  assert_equal(1, entry.parameters.length)
  parameter = entry.parameters.first
  assert_equal(:"(a, (b, ))", parameter.name)
  assert_instance_of(Entry::RequiredParameter, parameter)
end

#test_method_with_no_parametersObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/ruby_indexer/test/method_test.rb', line 8

def test_method_with_no_parameters
  index(<<~RUBY)
    class Foo
      def bar
      end
    end
  RUBY

  assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5")
end

#test_method_with_parametersObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ruby_indexer/test/method_test.rb', line 41

def test_method_with_parameters
  index(<<~RUBY)
    class Foo
      def bar(a)
      end
    end
  RUBY

  assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5")
  entry = T.must(@index["bar"].first)
  assert_equal(1, entry.parameters.length)
  parameter = entry.parameters.first
  assert_equal(:a, parameter.name)
  assert_instance_of(Entry::RequiredParameter, parameter)
end

#test_singleton_method_using_other_receiver_is_not_indexedObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby_indexer/test/method_test.rb', line 30

def test_singleton_method_using_other_receiver_is_not_indexed
  index(<<~RUBY)
    class Foo
      def String.bar
      end
    end
  RUBY

  assert_no_entry("bar")
end

#test_singleton_method_using_self_receiverObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby_indexer/test/method_test.rb', line 19

def test_singleton_method_using_self_receiver
  index(<<~RUBY)
    class Foo
      def self.bar
      end
    end
  RUBY

  assert_entry("bar", Entry::SingletonMethod, "/fake/path/foo.rb:1-2:2-5")
end