Class: Rutema::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/rutema/core/framework.rb

Overview

Simple base for classes concerned with message passing to report test progress and failures

This class and its descendants can be utilized as a container for data relevant to tests and their results. Currently they are being emitted by the Engine and Runners instances and consumed by classes within the Reporters module.

Specialized descendants are ErrorMessage and RunnerMessage.

Direct Known Subclasses

ErrorMessage, RunnerMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Message

Initialize a new message from data passed in a hash

The following keys of the hash are being utilized:

  • :test - the test id/name of the test which originates the message
  • :text - the text of the message
  • :timestamp - most often the timestamp of the creation of the message, defaults to Time.now


35
36
37
38
39
40
# File 'lib/rutema/core/framework.rb', line 35

def initialize(params)
  @test = params.fetch(:test, "")
  @test ||= ""
  @text = params.fetch(:text, "")
  @timestamp = params.fetch(:timestamp, Time.now)
end

Instance Attribute Details

#testObject

The test whose execution originated the message



19
20
21
# File 'lib/rutema/core/framework.rb', line 19

def test
  @test
end

#textObject

The text of the message



22
23
24
# File 'lib/rutema/core/framework.rb', line 22

def text
  @text
end

#timestampObject

The timestamp of the message's creation



25
26
27
# File 'lib/rutema/core/framework.rb', line 25

def timestamp
  @timestamp
end

Instance Method Details

#to_sObject

Convert the instance to a convenient textual representation



44
45
46
47
48
49
# File 'lib/rutema/core/framework.rb', line 44

def to_s
  msg = ""
  msg << "#{@test} " unless @test.empty?
  msg << @text
  return msg
end