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.
750 751 752 753 |
# File 'lib/core_assertions.rb', line 750 def initialize @count = 0 @failures = {} end |
Instance Attribute Details
#failures ⇒ Object (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 |
#message ⇒ Object
773 774 775 776 777 778 779 780 781 |
# File 'lib/core_assertions.rb', line 773 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
783 784 785 |
# File 'lib/core_assertions.rb', line 783 def pass? @failures.empty? end |