Class: Spec::Runner::SpecParser

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/runner/spec_parser.rb

Overview

Parses a spec file and finds the nearest spec for a given line number.

Instance Method Summary collapse

Instance Method Details

#spec_name_for(io, line_number) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/spec/runner/spec_parser.rb', line 5

def spec_name_for(io, line_number)
  source  = io.read
  context = context_at_line(source, line_number)
  spec    = spec_at_line(source, line_number)
  if context && spec
    "#{context} #{spec}"
  elsif context
    context
  else
    nil
  end
end