Module: Inferno::DSL::Messages

Included in:
Entities::TestGroup, Entities::TestSuite
Defined in:
lib/inferno/dsl/messages.rb

Overview

This module contains methods to add meessages to runnable results

Instance Method Summary collapse

Instance Method Details

#add_message(type, message) ⇒ void

This method returns an undefined value.

Add a message to the result.

Parameters:

  • type (String)

    error, warning, or info

  • message (String)


18
19
20
# File 'lib/inferno/dsl/messages.rb', line 18

def add_message(type, message)
  messages << { type: type.to_s, message: format_markdown(message) }
end

#info(message = nil) ⇒ void

This method returns an undefined value.

Add an informational message to the results of a test. If passed a block, a failed assertion will become an info message and test execution will continue.

Examples:

# Add an info message
info 'This message will be added to the test results'

# The message for the failed assertion will be treated as an info
# message. Test exection will continue.
info { assert false == true }

Parameters:

  • message (String) (defaults to: nil)


35
36
37
38
39
40
41
42
43
44
# File 'lib/inferno/dsl/messages.rb', line 35

def info(message = nil)
  unless block_given?
    add_message('info', message) unless message.nil?
    return
  end

  yield
rescue Exceptions::AssertionException => e
  add_message('info', e.message)
end

#warning(message = nil) ⇒ void

This method returns an undefined value.

Add a warning message to the results of a test. If passed a block, a failed assertion will become a warning message and test execution will continue.

Examples:

# Add a warning message
warning 'This message will be added to the test results'

# The message for the failed assertion will be treated as a warning
# message. Test exection will continue.
warning { assert false == true }

Parameters:

  • message (String) (defaults to: nil)


59
60
61
62
63
64
65
66
67
68
# File 'lib/inferno/dsl/messages.rb', line 59

def warning(message = nil)
  unless block_given?
    add_message('warning', message) unless message.nil?
    return
  end

  yield
rescue Exceptions::AssertionException => e
  add_message('warning', e.message)
end