Class: Test::Unit::CoreAssertions::AllFailures
- Inherits:
-
Object
- Object
- Test::Unit::CoreAssertions::AllFailures
- Defined in:
- lib/core_assertions.rb
Instance Attribute Summary collapse
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
Instance Method Summary collapse
- #for(key) ⇒ Object
- #foreach(*keys) ⇒ Object
-
#initialize ⇒ AllFailures
constructor
A new instance of AllFailures.
- #message ⇒ Object
- #pass? ⇒ Boolean
Constructor Details
#initialize ⇒ AllFailures
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
#failures ⇒ Object (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 |
#message ⇒ Object
799 800 801 802 803 804 805 806 807 |
# File 'lib/core_assertions.rb', line 799 def i = 0 total = @count.to_s fmt = "%#{total.size}d" @failures.map {|k, (n, v)| v = v. "\n#{i+=1}. [#{fmt%n}/#{total}] Assertion for #{k.inspect}\n#{v.b.gsub(/^/, ' | ').force_encoding(v.encoding)}" }.join("\n") end |
#pass? ⇒ Boolean
809 810 811 |
# File 'lib/core_assertions.rb', line 809 def pass? @failures.empty? end |