Class: Test::Unit::Assertions::AssertionMessage
- Inherits:
-
Object
- Object
- Test::Unit::Assertions::AssertionMessage
- Includes:
- Util::BacktraceFilter
- Defined in:
- lib/test/unit/assertions.rb
Overview
:stopdoc:
Defined Under Namespace
Constant Summary
Constants included from Util::BacktraceFilter
Util::BacktraceFilter::TESTUNIT_FILE_SEPARATORS, Util::BacktraceFilter::TESTUNIT_PREFIX, Util::BacktraceFilter::TESTUNIT_RB_FILE
Class Attribute Summary collapse
-
.use_pp ⇒ Object
Returns the value of attribute use_pp.
Class Method Summary collapse
Instance Method Summary collapse
- #add_period(string) ⇒ Object
- #convert(object) ⇒ Object
-
#initialize(head, template_string, parameters) ⇒ AssertionMessage
constructor
A new instance of AssertionMessage.
- #template ⇒ Object
- #to_s ⇒ Object
Methods included from Util::BacktraceFilter
Constructor Details
#initialize(head, template_string, parameters) ⇒ AssertionMessage
Returns a new instance of AssertionMessage.
565 566 567 568 569 |
# File 'lib/test/unit/assertions.rb', line 565 def initialize(head, template_string, parameters) @head = head @template_string = template_string @parameters = parameters end |
Class Attribute Details
.use_pp ⇒ Object
Returns the value of attribute use_pp.
526 527 528 |
# File 'lib/test/unit/assertions.rb', line 526 def use_pp @use_pp end |
Class Method Details
Instance Method Details
#add_period(string) ⇒ Object
600 601 602 |
# File 'lib/test/unit/assertions.rb', line 600 def add_period(string) (string =~ /\.\Z/ ? string : string + '.') end |
#convert(object) ⇒ Object
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/test/unit/assertions.rb', line 571 def convert(object) case object when Exception <<EOM.chop Class: <#{convert(object.class)}> Message: <#{convert(object.)}> ---Backtrace--- #{filter_backtrace(object.backtrace).join("\n")} --------------- EOM else if(self.class.use_pp) begin require 'pp' rescue LoadError self.class.use_pp = false return object.inspect end unless(defined?(PP)) PP.pp(object, '').chomp else object.inspect end end end |
#template ⇒ Object
596 597 598 |
# File 'lib/test/unit/assertions.rb', line 596 def template @template ||= Template.create(@template_string) end |
#to_s ⇒ Object
604 605 606 607 608 609 610 611 612 613 614 615 |
# File 'lib/test/unit/assertions.rb', line 604 def to_s = [] if (@head) head = @head.to_s unless(head.empty?) << add_period(head) end end tail = template.result(@parameters.collect{|e| convert(e)}) << tail unless(tail.empty?) .join("\n") end |