Module: DTest

Defined in:
lib/dtest/util.rb,
lib/dtest/dsl.rb,
lib/dtest/core.rb,
lib/dtest/test.rb,
lib/dtest/global.rb,
lib/dtest/report.rb,
lib/dtest/result.rb,
lib/dtest/runner.rb,
lib/dtest/failure.rb,
lib/dtest/version.rb,
lib/dtest/progress.rb,
lib/dtest/shared_context.rb

Overview

module Singleton

Defined Under Namespace

Modules: DSL, Global, Hook, SharedContext, Stopwatch, Test Classes: Abort, AbortGlobal, AbortTest, AbortTestCase, Block, Context, Progress, Report, Runner

Constant Summary collapse

VERSION =
'0.0.5'

Class Method Summary collapse

Class Method Details

.failure_line(backtrace) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/dtest/failure.rb', line 14

def self.failure_line(backtrace)
  file, line, method = parse_caller(backtrace)
  if file && line && File.exists?(file)
    [file, line, File.readlines(file)[line - 1].strip]
  else
    [file, line, "Unable to find #{file} to read failed line"]
  end
end

.parse_caller(at) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/dtest/failure.rb', line 3

def self.parse_caller(at)
  if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
    file = $1
    line = $2.to_i
    method = $3
    [file, line, method]
  else
    nil
  end
end