Class: Test::Unit::Assertions::AssertionMessage
- Inherits:
-
Object
- Object
- Test::Unit::Assertions::AssertionMessage
show all
- Includes:
- Util::BacktraceFilter
- Defined in:
- lib/test/unit/assertions.rb
Overview
Defined Under Namespace
Classes: DelayedLiteral, Literal, Template
Constant Summary
Util::BacktraceFilter::TESTUNIT_FILE_SEPARATORS, Util::BacktraceFilter::TESTUNIT_PREFIX, Util::BacktraceFilter::TESTUNIT_RB_FILE
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
filter_backtrace
Constructor Details
#initialize(head, template_string, parameters) ⇒ AssertionMessage
Returns a new instance of AssertionMessage.
686
687
688
689
690
|
# File 'lib/test/unit/assertions.rb', line 686
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.
610
611
612
|
# File 'lib/test/unit/assertions.rb', line 610
def use_pp
@use_pp
end
|
Class Method Details
.convert(object) ⇒ Object
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
# File 'lib/test/unit/assertions.rb', line 620
def convert(object)
case object
when Exception
<<EOM.chop
Class: <#{convert(object.class)}>
Message: <#{convert(object.message)}>
---Backtrace---
#{Util::BacktraceFilter.filter_backtrace(object.backtrace).join("\n")}
---------------
EOM
else
if use_pp
begin
require 'pp' unless defined?(PP)
return PP.pp(object, '').chomp
rescue LoadError
self.use_pp = false
end
end
object.inspect
end
end
|
.delayed_literal(&block) ⇒ Object
616
617
618
|
# File 'lib/test/unit/assertions.rb', line 616
def delayed_literal(&block)
DelayedLiteral.new(block)
end
|
.literal(value) ⇒ Object
612
613
614
|
# File 'lib/test/unit/assertions.rb', line 612
def literal(value)
Literal.new(value)
end
|
Instance Method Details
#add_period(string) ⇒ Object
700
701
702
|
# File 'lib/test/unit/assertions.rb', line 700
def add_period(string)
(string =~ /\.\Z/ ? string : string + '.')
end
|
#convert(object) ⇒ Object
692
693
694
|
# File 'lib/test/unit/assertions.rb', line 692
def convert(object)
self.class.convert(object)
end
|
#template ⇒ Object
696
697
698
|
# File 'lib/test/unit/assertions.rb', line 696
def template
@template ||= Template.create(@template_string)
end
|
#to_s ⇒ Object
704
705
706
707
708
709
710
711
712
713
714
715
|
# File 'lib/test/unit/assertions.rb', line 704
def to_s
message_parts = []
if (@head)
head = @head.to_s
unless(head.empty?)
message_parts << add_period(head)
end
end
tail = template.result(@parameters.collect{|e| convert(e)})
message_parts << tail unless(tail.empty?)
message_parts.join("\n")
end
|