Function: projectile-test-at-point-ruby-name

projectile-test-at-point-ruby-name is a byte-compiled function defined in projectile.el.

Signature

(projectile-test-at-point-ruby-name NODE)

Documentation

Return the test name for the Ruby NODE at point.

Handles both dialects: an RSpec it/describe call whose first argument is a string, and a Minitest def test_foo method.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-test-at-point-ruby-name (node)
  "Return the test name for the Ruby NODE at point.
Handles both dialects: an RSpec `it'/`describe' call whose first
argument is a string, and a Minitest `def test_foo' method."
  (pcase (treesit-node-type node)
    ("method"
     (when-let* ((name-node (treesit-node-child-by-field-name node "name"))
                 (name (treesit-node-text name-node t)))
       (when (string-prefix-p "test_" name)
         name)))
    ((or "call" "method_call")
     (when-let* ((method (treesit-node-child-by-field-name node "method"))
                 (method-name (treesit-node-text method t)))
       (when (member method-name '("it" "describe" "context" "specify"))
         (when-let* ((args (treesit-node-child-by-field-name node "arguments"))
                     (arg (treesit-node-child args 0 t)))
           (when (equal (treesit-node-type arg) "string")
             ;; Strip the surrounding quotes.
             (let ((text (treesit-node-text arg t)))
               (if (> (length text) 1) (substring text 1 -1) text)))))))))