Class: RubyLens::Index::RSpecExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/rubylens/index/rspec_extractor.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

GROUP_METHODS =
Set.new(%w[describe context]).freeze
EXAMPLE_METHODS =
Set.new(%w[it specify]).freeze
SPEC_SEGMENTS =
Set.new(%w[spec specs]).freeze
PROXY_NAME_PREFIX =
"RSpec example group #"

Instance Method Summary collapse

Constructor Details

#initialize(graph:, manifest:, package_document_paths: Set.new, documents_with_paths: nil) ⇒ RSpecExtractor

Returns a new instance of RSpecExtractor.



16
17
18
19
20
21
# File 'lib/rubylens/index/rspec_extractor.rb', line 16

def initialize(graph:, manifest:, package_document_paths: Set.new, documents_with_paths: nil)
  @graph = graph
  @manifest = manifest
  @package_document_paths = package_document_paths
  @documents_with_paths = documents_with_paths
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rubylens/index/rspec_extractor.rb', line 23

def call
  groups = []
  method_count = 0

  spec_documents.each do |document, _relative|
    group_count, example_count = reference_counts(document.method_references)
    method_count += example_count
    group_count.times do
      groups << format("%s%06d", PROXY_NAME_PREFIX, groups.length + 1)
    end
  end

  Result.new(groups.freeze, method_count)
end