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.



750
751
752
753
# File 'lib/core_assertions.rb', line 750

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

Instance Attribute Details

#failuresObject (readonly)

Returns the value of attribute failures.



748
749
750
# File 'lib/core_assertions.rb', line 748

def failures
  @failures
end

Instance Method Details

#for(key) ⇒ Object



755
756
757
758
759
760
# File 'lib/core_assertions.rb', line 755

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

#foreach(*keys) ⇒ Object



762
763
764
765
766
767
768
769
770
771
# File 'lib/core_assertions.rb', line 762

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

#messageObject



773
774
775
776
777
778
779
780
781
# File 'lib/core_assertions.rb', line 773

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)


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

def pass?
  @failures.empty?
end