Class: Test::Unit::CoreAssertions::AllFailures

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAllFailures

Returns a new instance of AllFailures.



780
781
782
783
# File 'lib/core_assertions.rb', line 780

def initialize
  @count = 0
  @failures = {}
end

Instance Attribute Details

#failuresObject (readonly)

Returns the value of attribute failures.



778
779
780
# File 'lib/core_assertions.rb', line 778

def failures
  @failures
end

Instance Method Details

#for(key) ⇒ Object



785
786
787
788
789
790
# File 'lib/core_assertions.rb', line 785

def for(key)
  @count += 1
  yield key
rescue Exception => e
  @failures[key] = [@count, e]
end

#foreach(*keys) ⇒ Object



792
793
794
795
796
797
798
799
800
801
# File 'lib/core_assertions.rb', line 792

def foreach(*keys)
  keys.each do |key|
    @count += 1
    begin
      yield key
    rescue Exception => e
      @failures[key] = [@count, e]
    end
  end
end

#messageObject



803
804
805
806
807
808
809
810
811
# File 'lib/core_assertions.rb', line 803

def message
  i = 0
  total = @count.to_s
  fmt = "%#{total.size}d"
  @failures.map {|k, (n, v)|
    v = v.message
    "\n#{i+=1}. [#{fmt%n}/#{total}] Assertion for #{k.inspect}\n#{v.b.gsub(/^/, '   | ').force_encoding(v.encoding)}"
  }.join("\n")
end

#pass?Boolean

Returns:

  • (Boolean)


813
814
815
# File 'lib/core_assertions.rb', line 813

def pass?
  @failures.empty?
end