Class: Yardcheck::SpecObserver

Inherits:
Object
  • Object
show all
Includes:
Memoizable
Defined in:
lib/yardcheck/spec_observer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(rspec_arguments, namespace) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/yardcheck/spec_observer.rb', line 7

def self.run(rspec_arguments, namespace)
  tracer      = MethodTracer.new(Object.const_get(namespace))
  test_runner = TestRunner.new(rspec_arguments)

  test_runner.wrap_test(tracer.method(:trace))
  test_runner.run

  new(tracer.events)
end

Instance Method Details

#associate_with(documentation) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/yardcheck/spec_observer.rb', line 17

def associate_with(documentation)
  docs    = documentation.method_objects.group_by(&:method_identifier)
  calls   = events.group_by(&:method_identifier)
  overlap = docs.keys & calls.keys

  overlap.flat_map do |key|
    method_object = docs.fetch(key).first
    calls.fetch(key).map { |call| Observation.new(method_object, call) }
  end
end