module Expresenter::Common
Common
collection of methods.
Constants
- SPACE
White space.
Attributes
@return [#object_id] Returned value by the challenged subject.
@return [String] A readable string of the matcher and any expected values.
@return [Exception, nil] Any possible raised exception.
@return [#object_id] The expected value.
@return [#object_id] The result of the boolean comparison between the
actual value and the expected value through the matcher.
@return [:MUST, :SHOULD, :MAY] The requirement level of the expectation.
Public Instance Methods
Express the result with one colored char.
@return [String] The colored char that identify the result.
# File lib/expresenter/common.rb, line 87 def colored_char color(char) end
The colored string representation of the result.
@return [String] A string representing the result.
# File lib/expresenter/common.rb, line 94 def colored_string color(to_bold_s) end
The state of error.
@return [Boolean] The test raised an error?
# File lib/expresenter/common.rb, line 45 def error? !error.nil? end
A string containing a human-readable representation of the result.
@return [String] The human-readable representation of the result.
# File lib/expresenter/common.rb, line 59 def inspect "#{self.class}(actual: #{actual.inspect}, " \ "definition: #{definition.inspect}, " \ "error: #{error.inspect}, " \ "expected: #{expected.inspect}, " \ "got: #{got.inspect}, " \ "negate: #{negate?.inspect}, " \ "level: #{level.inspect})" end
The value of the negate instance variable.
@return [Boolean] Evaluated to a negative assertion?
# File lib/expresenter/common.rb, line 38 def negate? @negate end
Did the test pass?
@return [Boolean] The spec passed or failed?
# File lib/expresenter/common.rb, line 31 def passed? !failed? end
The state of success.
@return [Boolean] The test was a success?
# File lib/expresenter/common.rb, line 52 def success? got.equal?(true) end
The summary of the result.
@return [String] A string representing the summary of the result.
# File lib/expresenter/common.rb, line 72 def summary if error? error.message elsif actual.is_a?(::Exception) actual.message elsif actual == expected ["expected", negation, "to", definition].compact.join(SPACE) else ["expected", actual.inspect, negation, "to", definition].compact.join(SPACE) end end
Titre for the result.
@return [String] A string representing the titre.
# File lib/expresenter/common.rb, line 108 def titre if error? error.class.name else to_sym.to_s.capitalize end end
The representation of the result.
@return [String] A string representing the result.
# File lib/expresenter/common.rb, line 101 def to_s "#{titre}: #{summary}." end
Protected Instance Methods
The negation, if any.
@return [String, nil] The negation, or an empty string.
# File lib/expresenter/common.rb, line 121 def negation "not" if negate? end
The representation of the result with the title in bold.
@return [String] A string representing the result with the title in bold.
# File lib/expresenter/common.rb, line 128 def to_bold_s "\e[1m#{titre}\e[22m: #{summary}." end