-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored logic for custom result block
Signed-off-by: Vanessa Fotso <[email protected]>
- Loading branch information
1 parent
f7d7ce9
commit 9004016
Showing
12 changed files
with
212 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module Inferno | ||
module DSL | ||
# This module contains methods to add meessages to runnable results | ||
module Messages | ||
# @private | ||
def messages | ||
@messages ||= [] | ||
end | ||
|
||
# Add a message to the result. | ||
# | ||
# @param type [String] error, warning, or info | ||
# @param message [String] | ||
# @return [void] | ||
def add_message(type, message) | ||
messages << { type: type.to_s, message: format_markdown(message) } | ||
end | ||
|
||
# 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. | ||
# | ||
# @param message [String] | ||
# @return [void] | ||
# @example | ||
# # 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 } | ||
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 | ||
|
||
# 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. | ||
# | ||
# @param message [String] | ||
# @return [void] | ||
# @example | ||
# # 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 } | ||
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 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.