123456789_123456789_123456789_123456789_123456789_

Exception: Test::Unit::AssertionFailedError

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, StandardError
Instance Chain:
self, StandardError
Inherits: StandardError
  • Object
Defined in: lib/test/unit/assertion-failed-error.rb

Overview

Thrown by Assertions when an assertion fails.

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(message = nil, options = nil) ⇒ AssertionFailedError

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 25

def initialize(message=nil, options=nil)
  options ||= {}
  @expected = options[:expected]
  @actual = options[:actual]
  @inspected_expected = options[:inspected_expected]
  @inspected_actual = options[:inspected_actual]
  @user_message = options[:user_message]
  super(message)
  debug_on_failure
end

Class Attribute Details

.debug_on_failure=(boolean) (rw)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 14

def debug_on_failure=(boolean)
  @debug_on_failure = boolean
end

.debug_on_failure?Boolean (rw)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 18

def debug_on_failure?
  @debug_on_failure
end

Instance Attribute Details

#actual (rw)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 23

attr_accessor :expected, :actual, :user_message

#expected (rw)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 23

attr_accessor :expected, :actual, :user_message

#inspected_actual (rw)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 24

attr_accessor :inspected_expected, :inspected_actual

#inspected_expected (rw)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 24

attr_accessor :inspected_expected, :inspected_actual

#user_message (rw)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 23

attr_accessor :expected, :actual, :user_message

Instance Method Details

#debug_on_failure (private)

[ GitHub ]

  
# File 'lib/test/unit/assertion-failed-error.rb', line 37

def debug_on_failure
  return unless self.class.debug_on_failure?

  begin
    require "debug"
  rescue LoadError
    return
  end

  return unless binding.respond_to?(:break)

  frames = caller(0)
  pre = nil
  Util::BacktraceFilter.filter_backtrace(frames).each do |location|
    frame_index = frames.index(location)
    next if frame_index.nil?
    pre = "frame #{frame_index}"
    break
  end
  binding.break(pre: pre)
end