Sha256: 6cd3ee6239d35d9832095d30ec72731369f88a5f45b57fbd47b6de9da7f8ed7c

Contents?: true

Size: 931 Bytes

Versions: 29

Compression:

Stored size: 931 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module RubyLsp
  module Rails
    module ActiveSupportTestCaseHelper
      extend T::Sig

      sig { params(node: Prism::CallNode).returns(T.nilable(String)) }
      def extract_test_case_name(node)
        message_value = node.message
        return unless message_value == "test" || message_value == "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) }
            T.cast(parts, T::Array[Prism::StringNode]).map(&:content).join
          end
        when Prism::StringNode
          first_argument.content
        end

        if content && !content.empty?
          content
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ruby-lsp-rails-0.3.31 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.30 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.29 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.28 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.27 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.26 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.25 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.24 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.23 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.22 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.21 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.20 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.19 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.18 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.17 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.16 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.15 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.14 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.13 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb
ruby-lsp-rails-0.3.12 lib/ruby_lsp/ruby_lsp_rails/support/active_support_test_case_helper.rb