Test::Unit::Assertions::AssertionMessage (Class)

In: test/unit/assertions.rb
Parent: Object

Methods

add_period   convert   literal   new   template   to_s  

Attributes

use_pp  [RW] 

Included Modules

Public Class methods

[Source]

# File test/unit/assertions.rb, line 420
        def self.literal(value)
          Literal.new(value)
        end

[Source]

# File test/unit/assertions.rb, line 426
        def initialize(head, template_string, parameters)
          @head = head
          @template_string = template_string
          @parameters = parameters
        end

Public Instance methods

[Source]

# File test/unit/assertions.rb, line 462
        def add_period(string)
          (string =~ /\.\Z/ ? string : string + '.')
        end

[Source]

# File test/unit/assertions.rb, line 432
        def convert(object)
          case object
            when Exception
              "Class: <\#{convert(object.class)}>\nMessage: <\#{convert(object.message)}>\n---Backtrace---\n\#{filter_backtrace(object.backtrace).join(\"\\n\")}\n---------------\n".chop
            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

[Source]

# File test/unit/assertions.rb, line 458
        def template
          @template ||= Template.create(@template_string)
        end

[Source]

# File test/unit/assertions.rb, line 466
        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

[Validate]