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.



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

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

Instance Attribute Details

#failuresObject (readonly)

Returns the value of attribute failures.



774
775
776
# File 'lib/core_assertions.rb', line 774

def failures
  @failures
end

Instance Method Details

#for(key) ⇒ Object



781
782
783
784
785
786
# File 'lib/core_assertions.rb', line 781

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

#foreach(*keys) ⇒ Object



788
789
790
791
792
793
794
795
796
797
# File 'lib/core_assertions.rb', line 788

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

#messageObject



799
800
801
802
803
804
805
806
807
# File 'lib/core_assertions.rb', line 799

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)


809
810
811
# File 'lib/core_assertions.rb', line 809

def pass?
  @failures.empty?
end