Class: RSpec::DescriptionConsistency::ConsitencyVerifier

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/description_consistency/consitency_verifier.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:, configuration:) ⇒ ConsitencyVerifier

Returns a new instance of ConsitencyVerifier.



10
11
12
13
# File 'lib/rspec/description_consistency/consitency_verifier.rb', line 10

def initialize(context:, configuration:)
  @context = context
  @configuration = configuration
end

Class Method Details

.callObject



6
7
8
# File 'lib/rspec/description_consistency/consitency_verifier.rb', line 6

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject

rubocop:disable Metrics/AbcSize,Metrics/MethodLength



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rspec/description_consistency/consitency_verifier.rb', line 15

def call # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  return unless top_level_example_group?(context)
  return unless (method_example_group_context = find_method_description_example_group(context))

  description = method_example_group_context[:description]

  klass = if context[:described_class].is_a?(String)
    ::Object.const_get(method_example_group_context[:described_class])
  else
    context[:described_class]
  end

  include_private = method_example_group_context[:private]

  return if method_example_group_context[:description_consistency] == false
  return if correct_method_example_group?(description, klass, include_private: include_private)

  Thread.current[EVALUATION_PERSISTENCE_KEY].add_entry(
    class_name: klass,
    method_name: description,
    payload: method_example_group_context[:location]
  )
end