Class: DTest::Test::FailureMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/dtest/result.rb

Overview

module BAResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, name, message, backtrace) ⇒ FailureMessage

Returns a new instance of FailureMessage.



45
46
47
48
49
50
51
# File 'lib/dtest/result.rb', line 45

def initialize(parent, name, message, backtrace)
  @parent = parent
  @nane = name
  @message = message

  @file, @line, @error_line = DTest::failure_line(backtrace)
end

Instance Attribute Details

#error_lineObject

Returns the value of attribute error_line.



43
44
45
# File 'lib/dtest/result.rb', line 43

def error_line
  @error_line
end

#fileObject

Returns the value of attribute file.



43
44
45
# File 'lib/dtest/result.rb', line 43

def file
  @file
end

#lineObject

Returns the value of attribute line.



43
44
45
# File 'lib/dtest/result.rb', line 43

def line
  @line
end

#nameObject

Returns the value of attribute name.



42
43
44
# File 'lib/dtest/result.rb', line 42

def name
  @name
end

#parentObject

Returns the value of attribute parent.



42
43
44
# File 'lib/dtest/result.rb', line 42

def parent
  @parent
end

Instance Method Details

#allObject



61
62
63
# File 'lib/dtest/result.rb', line 61

def all
  location + @message
end

#locationObject



53
54
55
56
57
58
59
# File 'lib/dtest/result.rb', line 53

def location
  if file && line
    "#{file}:#{line}\n"
  else
    ""
  end
end


65
66
67
68
69
70
71
72
# File 'lib/dtest/result.rb', line 65

def print
  #str += "[#{parent}]" if parent
  #str += "  '#{name}'\n" if name
  str = @message
  str += "  Failure/Error: #{error_line}\n" if error_line
  str += "  # #{file}:#{line}\n" if file && line
  puts "#{str}\n"
end