Module: RubyLsp::Rails::ActiveSupportTestCaseHelper
- Included in:
- CodeLens, DocumentSymbol
- Defined in:
- lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
Instance Method Summary collapse
-
#extract_test_case_name(node) ⇒ Object
: (Prism::CallNode node) -> String?.
Instance Method Details
#extract_test_case_name(node) ⇒ Object
: (Prism::CallNode node) -> String?
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb', line 8 def extract_test_case_name(node) = node. return unless == "test" || == "it" arguments = node.arguments&.arguments return unless arguments&.any? first_argument = arguments.first content = case first_argument when Prism::InterpolatedStringNode parts = first_argument.parts if parts.all? { |part| part.is_a?(Prism::StringNode) } parts #: as Array[Prism::StringNode] .map(&:content).join end when Prism::StringNode first_argument.content end if content && !content.empty? content end end |